Author Archives: sam

Get latest git tag on master branch with bash

git describe origin/master 

Warning: If there are multiple tags (local or remote) for the HEAD of origin/master you will get one tag from this command, not a list.

I recommend using the –match parameter to make sure you get the tag you expect:

git describe origin/master --match="v*"

Reference: http://stackoverflow.com/questions/1404796/how-to-get-the-latest-tag-name-in-current-branch-in-git

Debug logging chef in Vagrant

Recently I wanted to enable debug level logging of chef-solo runs in a vagrant box. As it turns out there are two ways to do this and both appear to be undocumented:

 Vagrant.configure("2") do |config|
    # ...
    config.vm.provision :chef_solo do |chef|
      chef.arguments = '-l debug'
      # ...
    end
 end
 Vagrant.configure("2") do |config|
    # ...
    config.vm.provision :chef_solo do |chef|
      chef.log_level = :debug
      # ...
    end
 end

Sources: http://stackoverflow.com/a/18778690https://coderwall.com/p/covmpg

First time soldering: Raspberry Pi LCD kit

Adafruit has a great LCD+Keypad kit for the Raspberry Pi with excellent assembly instructions and  a nice Python library. I just had to order one along with my first Raspberry Pi.
Adafruit LCD+Keypad Kit
After it arrived I picked up a 25W Radioshack Pro-Line soldering iron, some 60/40 rosin-core solder and got to work. Luckily I had an old, dead iPod mini to tear apart and practice on. After soldering the first dozen points I felt like I was getting the hang of it. All-in-all I think it came out pretty well.

image

image

image

image

image

Where are all the good WordPress themes?

I just switched to the default WordPress theme Twenty Twelve because my old theme was dated and not mobile-friendly.

Why the default theme? 

Most free WordPress themes suck. They are displeasing to the eye, bloated, and just too “bloggy”. I want a modern, responsive, theme that complements my content. Why is the WordPress community still failing to grasp these concepts? (For the record, “premium” themes also fall short.)

I can’t wait for Ghost. Hopefully its community truly appreciates the concepts that make it a great blogging platform.

Debug your Apache mod_rewrite Rules!

Apache mod_rewrite is incredibly powerful but it’s also a PITA if you’re trying to do something advanced. Luckily, you can log mod_rewrite’s activities and better understand why your rules aren’t working.

Just add RewriteLogLevel and RewriteLog to your Apache VirtualHost config:

<VirtualHost *:80>
  # ...

  RewriteLogLevel 8
  RewriteLog /var/log/apache2/rewrite.log

  # ...
</VirtualHost>

I suggest log level 8 but you can try lower. Logging rewrites will be SLOW: do not enable in production.

Sample rewrite log output:

[perdir /var/www/local.dev/www/] RewriteCond: input='/small/asdfsadf/avatar.jpg' pattern='^(.*)/(.*)/(.*)' => matched
[perdir /var/www/local.dev/www/] RewriteCond: input='/var/www/local.dev/www/small/avatar.jpg' pattern='-f' => matched
[perdir /var/www/local.dev/www/] rewrite 'small/asdfsadf/avatar.jpg' -> '/small/avatar.jpg'
[perdir /var/www/local.dev/www/] internal redirect with /small/avatar.jpg [INTERNAL REDIRECT]

Details: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog