git: Ignoring files during development

git: Ignoring files during development

I use git a lot, and often find myself needing to make changes to a file that I absolutely don’t want to commit to the repo. For example, a default configuration file may be in the repo, but I want to change which database it is pointing to during development. Or maybe I’ll gut a CPU intensive method during preliminary testing, but I obviously don’t want the gutting method committed back to the repo.

Sure, I could stash these changes before and after every commit, but that can be a real hassle. What I like to do instead is use the assume unchanged feature.

To tell git to assume a file is unchanged, use this command:

git update-index --assume-unchanged 

To undo this, use this command:

git update-index --no-assume-unchanged 

A file that has been marked as assume unchanged won’t show up when you run git status. It won’t be added to a commit when you run git add -a. Pretty awesome.

If you need to figure out which files have been marked as assume unchanged, you can use this command:

git ls-files -v | grep "^[[:lower:]]"

The ls-files list with the -v option will show every file and its status, with lowercase letters for the status of assume unchanged files. The grep command will only show files that have that lowercase letter.

Read More

Block all AWS traffic to a server

Block all AWS traffic to a server

AWS servers are cheap and plentiful. Unfortunately this makes them the frequent source of screen scrapers. My servers aren’t running on AWS, and there isn’t any legitimate reason for an AWS server to be talking to my servers, so I decided to just block all AWS traffic.

You can get my AWS Blocker bash script on GitHub. It is free and public domain.

Amazon publishes a list of AWS IP ranges in JSON format. The bash script uses curl to download this file, then jq to parse it. It then adds each range to iptables, rejecting any connections made from an AWS IP.

The script is safe to run as many times as you want. It only takes a few seconds to run. The AWS rules are put in their own chain, and the chain is flushed before running. I’d recommend running the script as a cron.

Read More

Get your belt tension right with this inexpensive tool

Get your belt tension right with this inexpensive tool

I love maintaining my 2007 Toyota Yaris. It isn’t a perfect car, but it is incredibly reliable and easy to work on.

One issue I’ve had is that the serpentine belt loves to squeal. It is such a common issue on this model that Toyota actually increased the recommended belt tension after the car came out. So to fix the squeal, you just have to tighten the belt more.

But how much more? Too loose and it will still squeal (and ruin the belt). Too tight and you can damage more expensive components in the car.

The solution is an inexpensive Gates 91132 belt tension tester. I paid about $11 on Amazon. The price fluctuates a bit so you may have to pay a few dollars more if you want it now.


This little gizmo is very easy to use. You simply align it in the center of the belt and push. When you hear it click, you stop pushing and check the value.

To check the belt tension on a 2007 Toyota Yaris, you have to crawl under the car and push up on the middle of the belt between the crank and the air conditioner. The proper tension is 102-103 Ft. Lbs.

It also helps to have a belt tensioner. I added one to my car a few years ago, and it has saved me so much time when changing the belt.

Read More

View your media anywhere using Plex

View your media anywhere using Plex

I bought an Amazon Fire TV Stick a few months ago and love it. It is ultra fast, starts most shows instantly without having to buffer, and was super cheap.

The one thing I was missing was the ability to watch my other media, like DVDs and videos of my kids. The solution I settled on is called Plex. I also used Handbrake to get all of my DVDs onto my hard drive.

Plex is awesome. It works on everything: Android, iOS, Amazon Fire TV, Roku, Chromecast, and more. It automatically determines if your media file is in a format that your device can understand, and if it isn’t Plex will transcode it to an appropriate format for you.

The first step is to install the server component. My desktop is always on so I just installed it there. This part is always free. Once the server is installed, you tell it where your media is located. This was also easy, but mainly because I hadn’t picked a folder structure for my files yet. It was easy to organize them in the way best suited for Plex. If you need help, check the step by step quick-start guide.

Plex automatically downloads media information for your files, such as the cast, director, artwork, MPAA rating, synopsis, etc… It even found info for most of my old church films.

Next you install the client app on whatever device you’ll be using. The client apps typically cost a few dollars, depending on the platform’s marketplace. For example, it is $4.99 in the Apple app store. It is often free in the Amazon app store, so you can get it for Android or Fire TV without paying anything.

There are also some premium features that you can choose to pay for on a subscription basis. The only premium feature that I find compelling is the ability to sync a file for offline viewing. We paid for a single month of Plex so we could sync a few movies to our iPad for a recent trip. Totally worth it.

Read More

Add geotagging to any camera for free

Add geotagging to any camera for free

Ever since I got my DSLR, I’ve wanted to geotag my photos. Unfortunately, the GPS module for the Nikon D7000 is expensive, bulky, and has mixed reviews. Instead of using the bulky Nikon GPS unit, you can use your cell phone. This works for any brand of camera, even point and shoot models.

Synchronize the date/time

The first step is to make sure your cell phone and camera are set to the same date, time, and time zone. Syncing the time on the two devices will ensure your photos are tagged correctly.


Log your photo shoot

Before starting your photo shoot, start a GPS recording app, such as the free My Tracks. Wait to get a good GPS signal. Leave the app running during your entire shoot. This will track where you are with your camera.

2015-01-05 17.25.01

When you are done taking photos, save your GPS track to your computer. My Tracks makes this easy by syncing with your Google Drive. Sometimes this doesn’t work automatically and you need to choose the Export option. Open your Google Drive and download the file.

Convert your .kml to .gpx

My Tracks exports kml files. Most software expects a gpx file. To quickly and easily convert your kml to gpx, use the GPS Visualizer converter page.

Apply your track to your photos

I like to use Adobe Lightroom. If you don’t have Lightroom, you can use Pictomio for free.

In Lightroom, select the photos from your shoot in the Library section.

Go to the Map section, then load your gpx file by going to Map→Tracklog→Load Tracklog….


Click the tracklog icon and select Auto-Tag Selected Photo.


BAM! Your photos are now geotagged and you didn’t even have to buy anything! Yay!

Read More

Use BFG to completely remove a file from your git repo

Use BFG to completely remove a file from your git repo

I like to keep my blogs in git repos. For small blogs this works great, but for blogs with a ton of images this quickly becomes a problem. For example, my wife’s blog has 4GB of images. git isn’t really designed to handle that.

So I decided to take out the images. Specifically, I decided to exclude wp-content/uploads from her git repo. Just removing the images isn’t good enough, because they are saved in the history of the repo. For a quick and easy way to remove one or more files completely from git, use BFG.

These are the steps I took:

  1. Create a backup of my clone that has all the images in it. Always have a backup when doing something like this.
  2. Remove the files from git without deleting them locally: git rm -r –cached wp-content/uploads
  3. Add wp-content/uploads to my .gitignore
  4. Commit and push the changes.
  5. Download BFG. It is a jar so you’ll need java installed, too.
  6. For convenience, I created an alias in my .bashrc file: alias bfg=’java -jar /root/bfg-1.11.10.jar’
  7. Clone a bare repo: git clone –mirror git://
  8. Remove references to the images in the repo history: bfg –delete-folders uploads some-big-repo.git
  9. Purge the old files from the repo: git reflog expire –expire=now –all && git gc –prune=now –aggressive
  10. Push your changes into the remote repo: git push

The last step is to clone a fresh copy of the repo. You’ve modified the history of the repo, so you shouldn’t use any existing clones. Be careful not to lose your images! They aren’t in git anymore!

It is important to note that in step #8 you cannot use a full folder path. It won’t let you even if you try. So if you have something else called uploads or with uploads in the path that you’ve previously deleted, it’ll be wiped out, too.

It is also important to note that step #8 won’t do anything if you skip step #2. BFG makes the assumption that you don’t want to get rid of anything that is in your latest commit.

This also works great for removing sensitive information from a repo, for example if you commit a password to a public repo. BFG even lets you search and replace text, so you can simply replace an accidentally committed password with something else instead of deleting the files.

Read More