Setting up Riak with Vagrant and Puppet

Setting up Riak is pretty easy and straight forward,
but depending on my needs there is the need to change configuration
depending on the current use case. This means that having one instance of it on
my development machine just doesn’t cut it. Luckily there is
Vagrant which provides a quick way to setup VMs as
needed for a given project, along with Puppet this allows me to bundle all the
configuration for a given project.

Basho provides a nice module to setup Riak with puppet, but is pretty complex
to handle all the different use cases. Since I just need it for development I
decided to make it easier for me and other devs by providing an easy to setup and
a quickly understandable module for my needs. It just installs the most recent
version of Riak from the debian-pkg provided for Ubuntu 12.04 LTS 64Bits. So here we go

Vagrant configuration is short and simple, puppet folder setup as well.

https://gist.github.com/sideshowcoder/6439548.js

while for riak_precise64 I just add a submodule via git

$ git submodule add
https://github.com/sideshowcoder/riak_precise64.git
./puppet/modules/riak_precise64

and here we go a simple

$ vagrant up

will give us a nice VM with riak ready to use, and any config nicely contained in app.config.

WordPress Plugin: WordPress Page Contact

Since WordPress does not provide any kind of author widget to go along with a post or page I decided to roll my own. I feel like it’s a nice thing to get the contact details for a person responsible for a specific section of the page right on this page, and a widget seemed like a perfect fit, so this is how WordPress Page Contact came into being, as my first listed WordPress plugin.

The structure is rather simple: create a database of contacts and associate them to a page or post via postmeta, which can be retrieved easily upon display. Rollup the information in a widget to display in the sidebar for any given entry and here we go.

Since I didn’t find anything similar I decided apply for it to be listed in the Plugin index so here we are. You can find it as WordPress Page Contact.

Enjoy!

Use a different single template per category in WordPress

In a recent WordPress project the posts are displayed on different pages differentiated by category instead of type. In this case different designs are loaded based on categories as well, since the theme needs to match the design of the current page. WordPress does not provide a build in mechanism to do this, it only does for post types.

The solution is rather simple, use the single.php file to first check the category and load the matching template. Since in my development environment the categories might match to different IDs than in the deployed instance it’s more practical to match by name instead of ID. Importantly first the category ID needs identification by name, and is stored to load the matching template, since matching via the $post variable can only be achieved via ID not name or slug. For anybody interested I put example code up on github.

https://gist.github.com/1272148.js

Scaling images in Titanium (JPGCompressor Update)

Since I wrote the initial version of jpgcompressor for titanium, I needed scaling of images as well. The only way to do this in titanium is to overlay an Ti.UI.imageView and grab the picture out. This is neither fast nor clean, and it seems to reduce the quality for some weird reason. Since I figured I’m not the only one facing this problem, I added the feature to jpgcompressor via the scale function. Documentation is available in the example. If there are any problems please let me know, the code is build against the new 1.7.2 version of Titanium but should work with previous versions as well by adjusting the manifest as well as titanium.xconfig.

Todo.txt TextMate Bundle

tmtodotxt.png

Todo.txt is a command line todo list manager completely based around a bash script to manage a txt file which holds the todos and an Android App is available as well. Since it is just a plain text file it is really nice to work with, and it syncs very easily, even if the machine you are working with doesn’t feature a GUI.
From time to time there is the need to edit the file not via the command line but via an editor. To ease my life doing this I was looking around for some support in TextMate, and since there was none I decided to start a TextMate bundle for it. Currently there is just some syntax highlighting but I plan on adding some commands as well as soon as I figure out what might be useful in the editor. The goal is not to replace the command line after all since it works perfectly well. So for anybody interested check it out, code is available on github.

UPDATE: Started to add commands, nice to use ruby to extend my text editor.