Poor Man’s Continuous Integration

I created the following script which saves a few seconds of switching to a terminal and typing grunt on each change to my source files.

I can just leave this running in a terminal window and glance at the output to make sure there were no errors.

Reduce PNG sizes from Mac Finder

When I save a screenshot on my systems, it doesn’t try to automatically crush/minify the PNG. Here’s how on a Mac I’ve added a context menu item for images to crush them. This can help save storage space or make web pages load faster.

  1. Ensure you have pngquant installed. Other tools may work for you, but this post is pngquant-specific. I got it via Homebrew.
  2. Open Automator.
  3. Choose Service.
  4. In the Service Receives drop-down, select image files.
  5. In the left pane, select Utilities under Library.
  6. From the middle pane, drag Run Shell Script to the right pane.
  7. On the top of the box that was just created, use /bin/bash as the shell and pass input as arguments.
  8. Paste in the following code for the shell script:
  9. Choose a name to save the script as which is how you’d like to see in when right-clicking to get the context menu. I named mine png_crush.

Now when you right-click a PNG in Finder, go to Services, and click on the entry for png_crush. Works for multiple-selected files as well.

Macbook sd card reader always in read-only mode

Most of the time when I insert an SD card into the slot on my mid-2014 Macbook Pro, it mounts in read-only mode and I don’t notice until I try to delete a file. When that happens, the option to “Move to Trash” is missing. After checking that the tiny sliding switch on the side is, in fact, set to the unlocked position, I consulted the Googs.

I found a page suggesting that when inserting the card, pressing in the card on the side closest to me rather than the display helped. But still after several tries I couldn’t get it work. One part of that possible solution piqued my interest, though. It was the phrase “bad tolerances.”

On a whim, I pushed the card’s lock button only one or two millimeters down towards the locked position and tried again. It worked! Wooo!

Tunnelblick disconnect fails to remove route

Tunnelblick is an awesome OpenVPN client, which I have been using a lot lately on my Mac. I had a problem where it would connect the first time just fine, but then would never reconnect; it would seem to hang while trying to handshake with the server. I could get it to work again if I rebooted my machine, but that’s powerfully inconvenient.

TL;DR temporary fix:
On disconnect, Tunnelblick fails to remove a static route it used while active. I created a script that I run after disconnecting which drops the static route. It basically just does this:

The 192 address makes an assumption that you didn’t customize that part of the config, so YMMV.

Unison dependency hell

UnisonI would really like to rid myself of Dropbox, but all the alternatives I’ve tried are too bloated, beta- or alpha-quality stage, too complicated to set up, or just plain don’t do what Dropbox does (minus the sharing stuff, which I don’t care about). I don’t want btsync, it’s closed-source. Seafile is too complicated, and makes dubious security claims. Owncloud is a cool project, but their file sync is slow, error prone, and has other limitations. There are some good services, but they don’t run on all the platforms I need, including Mac OSX, Linux x86 (32 and 64-bit), Linux ARMv6 (my Raspberry Pi B) and Android. I ran Syncthing for a while, but the continuous memory usage is pretty steep for the Pi, and I’ve experienced random silent file truncation in my shared directories with it. So I needed something else. Continue reading “Unison dependency hell”

Long Live ControlPlane!

I’ve written about Locamatic before, and while it’s good at what it does, there are some definite drawbacks. For one, the most recent version is alpha quality and stated for use on Mountain Lion since prior versions won’t work anymore on a newer system. But as of this writing, Mountain Lion was two major releases ago. I think it’s safe to say that development has stalled, and that’s OK. Continue reading “Long Live ControlPlane!”

Re-map the Caps Lock Key to Esc on Mac

Seil IconSeil is a very cool utility for key re-mapping / enabling international keys on a Mac. I wanted to re-map the mostly useless Caps Lock key to Esc, which I use constantly in vi. If you’re a regular vi user, you know exactly what I’m talking about. Now I just have to develop the muscle memory to start using it regularly instead of reaching way up for the usual Esc key.

Machine-readable Dates

I had some directories named in the format of “Jul 18, 2012”. Thanks, iPhoto export, but no thanks.

Note: gdate is GNU date after doing homebrew install coreutils.
Continue reading “Machine-readable Dates”

something wicked this way comes

When I ping fujipi, it reports the correct IP – it’s in my hosts file! For the record, the host key should not have changed. Continue reading “something wicked this way comes”