July 22, 2018
So, I’ve been teaching myself Python lately. This is partly due to work and partly due to wanting to do this for a few years now. Pretty quickly after I moved to Linux full time many years ago, the whole concept of programming and scripting really excited me. I quickly learned that with bash, I could make the computer do what would normally take me multiple hours of clicking here and clicking there and still not getting done.
Python for Work
At work, Python has come in handy with a number of projects that I’ve had added to my To Do List. We use a project management system that has a decent RESTful API. From there, I’m able to get lists of all projects in a certain state, all projects that have entered that state since the last time we checked it, etc. I have a whole set of scripts worked up for multiple reasons. Beyond our project management stuff, I’ve been using Python to work with our web hosting stuff, video encoding boxes, and multiple other applications.
Python for Me
I’ve been writing Python scripts for a few different reasons outside of work. First, I use a music streaming software that features an API and I’ve been working on a terminal based client for it. Right now, it’s pretty much useless, it just downloads songs based on a pre-selected list, but eventually, I want to build out a ncurses interface for it.
February 07, 2018
EDIT: Ignore this, I’ve moved back to Pelican because Python == ‘amazing’.
I’m now using Jekyll to create my blog. Since I’ve started working at The Church Online, I’ve seen a lot of dynamic sites at work and I must admit there is a definite draw there. I’m just not into dynamic content on my own personal site for a few main reasons.
1. I’m cheap.
First and foremost, I’m cheap. I really don’t want to spend a ton of money on a website/blog. Most of you are probably saying “You know you can get hosting for pennies on the dollar with x/y/z company, right?” Sure, that is an absolute possibility. On the other hand, you can see from my posting frequency, that my website is sort of waxing and wanning pursuit of mine. Sometimes, I’m really into it. Other times, meh. I’d prefer to keep my costs low.
2. I don’t really need crazy features (even though they are nice).
We’re constantly buying plugins and features to add into our Wordpress and Joomla sites at work and some of them are really compelling. Fortunately, I’m just not in great need of a lot of them right now. The previous version of this blog was simply a list of articles that I’d written with links to the pages that held them. I never used tags, categories, etc. and had no thought in my mind to use anything like comments or whatever new-fangled things the kids come up with now-a-days. I’m starting to use tags and categories now, since it’s built right into this platform and I’m getting more comfortable with the technology behind it, but it still feels a bit superfluous to me.
3. I like simple things.
The backends of the dynamic sites built on Wordpress, Joomla, and the like are gorgeous and give you a ton of flexibility when writing. It’s really not much different than if Microsoft Word (or LibreOffice, if you will) had a giant “publish” button at the end. My issue with it is that I swing back and forth between wanting these nice things laid out for me and wanting to get back to simplicity with just me and my terminal. Jekyll allows me to write posts using Jekyll-Admin or just popping into vim in a terminal and plugging away. On top of that, I’m messing with databases and all that jazz all day at work. I really don’t need to come home and do more of it. Database management is not one of my favorite parts of my work, I’d rather be learning to automate something or configuring a new piece of software that will help me automate something else.
4. Text files are archivable.
I LOVE TEXT FILES. Seriously, anyone who can’t find the joy in a solid txt is out of touch with the beautiful simplicity of it all. The use of text files to configure software is one of the things that drew me to Linux. Text files are so simple and yet so powerful. If tomorrow Jekyll ended development and shut down their site and for some odd reason, the executable stopped working: I’d still have all my text files in Markdown when I wanted to move them to a new platform/site. No mucking around with getting content out of a database or squeezing it through a converter. It’s right there. If I ever wanted to archive my posts, I could simply zip up my “posts” folder and be on my way. It would likely be less than a few kilobytes when all was said and done. I LOVE TEXT FILES.
Ultimately, it’s a personal preference thing. I get far more flexibility, security, and ease-of-use out of a static blogging platform like my previous static blog program, Pelican or my current platform, Jekyll than I ever would with Wordpress or Joomla.
July 29, 2017
Docker has been on the scene for a while now. It’s being used to simplify workflows all the way from the first steps of development through to launch and onward with support and upgrades. I’ve been messing with Docker for roughly a year or so now and I have to admit that I am in love. It’s changed the way that I do a lot of software testing and deployment, both at home and at work. The reason for this shift in my normal workflow is five fold.
1. Docker makes software testing simple.
Back in the day, installing and configuring new software was a matter of reading docs, changing config files, and ensure dependencies were all accounted for. Docker wraps up a lot of that into a quick and easy script called a Dockerfile. It installs dependencies, sets default configs (although main options are often editable), and gets everything up and running without a great deal of hassle.
Beyond this, due to Docker’s “containerization” feature, Docker doesn’t spread multiple version of libraries, programs, etc. all over your filesystem.
All of this contributes to Docker’s ability to make software testing simple. I love documentation and config editing as much as anyone else, but first and foremost, I want to see if the software has the features, abilities, and interface that benefits my users. Essentially, let’s just get it up and running and run some tests and if it seems like something I want to pursue further, I’ll dive further into the docs and setting it up for my specific use-case.
2. Docker performs the same everywhere.
One of the issues that I come up against often is that software reacts differently on different platforms. Varying version of this or that library mean that the website that worked beautifully on one server won’t even start on another. Again, Docker’s containerization feature makes this a thing of the past. Because each container acts like a self-contained unit, it works the same anywhere Docker can be installed. I used to have to use full fledged virtual machines to get this type of “work anywhere” functionality. Now I can do the same without all the wasted overhead.
3. Docker relies on already established skills and tools.
In a seemingly contradictory statement to the one in the first section, Docker allows me to use my previously learned skills of reading and understanding documentation, editing configuration files, and installing dependencies in a way that makes Docker completely custom.
Like I said, while I’m testing software, I just want it up and running. Once I have done my due diligence regarding the software, I want to be able to tweak and change almost everything about it to make it perfect. I can do that with my already existing knowledge of the Linux sub-system.
4. Docker increases system flexibility.
Normally, services will share the same instance of a program when they also share a server. Got a Wordpress and Joomla install on the same server? Chances are they are both using the same database server with separate databases. This is great when everything needs the same version, but what happens when they need different versions? What happens when you need to update a version for one application but it’s incompatible with the other application? Docker allows you to run different versions of the same software without problems or extra work. Tied into that is number 5.
5. Docker increases system uptime.
So we just found out that we can run separate instances of the same application in different versions. This can actually increase system uptime in general. Using our previous example, you have a Joomla instance and a Wordpress instance both using the same MySQL instance. Well, if Joomla does something and MySQL ends up dying, it kills not only your Joomla instance but also your Wordpress instance. With Docker, Joomla and Wordpress have their own MySQL containers. If the Joomla instance of MySQL dies, you’ll still have downtime on the Joomla site, but it won’t kill your Wordpress application at the same time. And just in case someone was worried that they have to watch so many different services now, Docker has built in tools to automatically notify you if something does “die” on it’s own. They can even restart on their own on failure!
Docker is pretty amazing and I’m fairly certain it will be a tool I use on almost a daily basis.
July 24, 2016
The Raspberry Pi is anything but a powerhouse, but it excels in a lot of lightweight applications that rely on 24/7 uptime. Its power-sipping processor makes it amazing for simple things like acting as an ssh gateway for your home network or hosting any number of network applications from inside your home network. Today, I’ll go over my process to set up ddclient on the Raspberry Pi to automatically update a domain that I have purchased with the external ip of my network.
Note: This assumes you have a working Raspberry Pi already on your network. Mine is running Raspbian Jessie. The domain is registered at NameCheap. This tutorial should work with almost any domain registrar or distribution, with some minor changes you’ll have to make yourself.
First, install ddclient on your Raspberry Pi:
sudo apt install ddclient
Second, create a config file on your Raspberry Pi:
sudo touch /etc/ddclient.conf
Third, open the file in your favorite editor (mine is vim):
sudo vim /etc/ddclient.conf
Fourth, plug in the relevant information according to this template:
# Configuration file for ddclient
password=*the password you get from the dyndns section of the namecheap website*
To clarify, if I wanted to make raspberrypi.brandonllocke.com resolve to my RPi, my config would look like this:
# Configuration file for ddclient
password=*the password you get from the dyndns section of the namecheap website*
This will allow you to update the ip address manually, however, I use Linux because it allows me to automate things easily. Therefore, lets daemonize this whole thing and let it run every so often to auto update the ip address whenever my ISP decides to change it.
First, create a file in /etc/default
sudo touch /etc/default/ddclient
Second, plug in the relevant information according to this template:
# Configuration for ddclient scripts
# Set to "true" if ddclient should be run every time DHCP client ('dhclient'
# from package isc-dhcp-client) updates the systems IP address.
# Set to "true" if ddclient should be run every time a new ppp connection is
# established. This might be useful, if you are using dial-on-demand.
# Set to "true" if ddclient should run in daemon mode
# If this is changed to true, run_ipup and run_dhclient must be set to false.
# Set the time interval between the updates of the dynamic DNS name in seconds.
# This option only takes effect if the ddclient runs in daemon mode.
You can set the interval to anything you might want. I would recommend not setting it super low, as this can hammer online resources and that’s a really good way to upset people and push resources offline.
You can start ddclient’s daemon with the following command:
sudo service ddclient start
It should start up automatically on reboot, but after you reboot you can check on the status of the service by running:
sudo service ddlclient status
You should be set! I hope this helped!
July 22, 2016
Syncthing is a great tool for liberating your data from cloud storage providers. While Dropbox, SpiderOak, and Google Drive are great services, the trade-off for such a great and simple product is privacy and loss of control. As an example, Copy.com was a great service that had an excellent Linux client and even a headless client for server installs, unfortunately, it was just shut down a few days ago when Baracuda decided to abandon that service. I had it installed on my parent’s computer as an alternative backup and completely forgot until my mother sent me a message saying the computer was telling her her data would be deleted. I had long since removed it from my workflow and since I was often just using my laptop, it wasn’t necessary. I’ve reintroduced my desktop to my workflow and soon the need for such software arose again.
While Syncthing isn’t available in the repos, there is a repo officially run by Syncthing. Add it to your apt sources like this:
# Add the release PGP keys:
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
# Add the "release" channel to your APT sources:
echo "deb http://apt.syncthing.net/ syncthing release" | sudo tee /etc/apt/sources.list.d/syncthing.list
Then update your repos and install syncthing:
sudo apt-get update
sudo apt-get install syncthing
Note: doing this on one machine only won’t do much of anything. There is nothing to sync with,so you’ll want to do this on each computer you want to sync.
Now that the application is installed, let’s run it!
Open up your browser and go to:
You’ll be greeted with a nice web interface where you can find your ID and add other “devices” using their IDs. Once you do that, you can add folders and share them with your devices. The web interface is very intuative and easy to use.
I’ve been using it for a few days now and it works very well! It really only works if you have a machine that will remain on all the time. I use my htpc/server as a main hub and then it populates my laptop and desktop with changes made from each other. At first, I thought I was missing the web interface that allows me to grab a single file from anywhere. The truth is, there are still a ton of ways to do that. I could use ftp, scp, or even http, if I wanted to set it up and secure it. I just don’t really need it right now. I can just pull it down with my phone over ssh.
July 21, 2016
A few months ago, I was having issues with my home network. Moving more than 10 feet away from the router would drop my connection percentage down to under 50%, which means I was connecting at less than half of the already slow 56Mb connection. I’ve grown used to Gb ethernet from when I only had desktop boxes, so I can only stand wireless data transfers with small files in small numbers. Anyone with even a small understanding of wireless networking can problem guess what the issue was…. interference from nearby networks. I live in a small town and the houses are very close together, in addition to that, a lot of the nearby houses have been converted to multiple apartment units in each house, therefore, the spectrum is just overrun with everyone’s own personal routers. From my apartment, I can easily scan close to 35 different SSIDs!
The solution was pretty obvious, find a way to make my wifi network a little more “unique”. I was already utilizing a good channel, switching to the less occupied channel 1 (those poor souls on channel 6 were all stuck messing with each other), but it still was crowded. So I decided to join the rest of the modern tech world and invest in some dual band equipment. The only thing I hate more than slow and inconsistent wifi are giant dongles hanging off of my tiny 11” laptop. I bought this thing small for a reason, I don’t want to have to struggle with a usb interface that is nearly the same height as my keyboard. I found the Edimax EW-7711ulc. As far as I can tell, its the only “nano” sized device capable of the 5ghz band. I have not found a single dual band nano adapter in my research. I figured I already had 2.4ghz built in to the laptop, so I really just needed an interface for 5ghz. So I picked one up.
THE SECOND PROBLEM
Unfortunately, Debian (and as far as I can tell, no version of Linux) currently supports the EW-7711ulc out of the box. I can build things from source, that’s not an issue and something you actually get pretty used to when running Debian Stable. Anyways, Edimax does provide the driver on their website for Linux. Downloaded it, went to compile it, and….. no dice. It kept giving me this very vague error that I couldn’t make heads or tails of. This doesn’t appear to be a very popular chipset either, so I couldn’t get much info on fixing the issue.
THE SECOND SOLUTION
I did however, come across a bitbucket repo that sported a different driver for the same chipset (the MediaTek mt7610u). I gave it a shot and it worked immediately!
After solving that issue, I just updated my wireless interface in wicd-curses to reflect the new wireless adapter and was able to find my 5ghz SSID immediately. Now my home wifi network flies and I do not have to worry about interference from my neighbors at all!