Archive for the 'Open Source' Category

This year in open source

December 23rd, 2011 by pyrat

Tame deer above Glen Brittle
Tame deer above Glen Brittle

So the year is coming to a close and I’d like to communicate some wee open source tools I’ve been working on this past year.

Below is a list of open source tools I have released recently. I would not go as far as to call them open source projects as there is rarely anyone involved in these projects apart from me. I learnt at frozen rails that its great to get involved with other peoples open source projects instead of going out on your own all the time. (something I have a habit of doing.)

If anything here catches your eye, or you want to use it, get involved.

Chef Cookbooks

I have been building a fair amount of server infrastructure lately and have been using the excellent chef tool to help with this.

Along the way I have released a few cookbooks which I have extracted from the work I have been doing. These are in a relatively rough state but do work and are in production use. If you want to help me improve any of these, please go for it.

chef-squid
chef-oh-my-zsh
chef-ipcoffeetables
chef-backup
chef-locales

Deployment recipiez

I have been doing a lot of varied application deployments, all with capistrano. For the last couple of years I have been maintaining a collection of customs scripts which I was including in each project. Versioning was becoming difficult and git submodules are not an amazing workflow.

With bundler its possible to manage dependencies well and it can be used outside of rails projects. Recently I have been writing messaging apis in NodeJS and deploying quite successfully with capistrano and a few setup scripts.

With recipiez its possible to setup a node deployment with upstart, nginx, logrotate and monit. This creates a nice “production ready” environment for deploying node apps.

I have packaged it up and released it as a gem. Instructions for use are in the Readme.

recipiez

OpenSSL Extensions

This is a library written by Nathaniel Bibler of Ruby5 fame. I have used this extensively in an SSL certificate reselling app I have been working on which has not yet seen the light of day.

This library was my first github pull request success. Where you open a pull request, discuss the change with the author, make a few alterations, then it gets merged upstream!

openssl-extensions

Wee Flickr

This is a little sinatra app which is meant to get deployed to heroku. It allows me to include images in blog posts very easily and give me a little textile snippet to paste into blog posts.

This scratches a very specific itch but is a example of a sinatra app communicating with the flickr api. It also has a random image function which give a random image from your flickr stream. This is used on my random flickr desktop script which I use at work.

wee_flickr

Solon

This is a gem for integrating with sage pay server. It lacks the standard api of activemerchant but as the service is offsite it doesnt work that well with the activemerchant api.

Using it might help you if you are doing a sage pay integration within a rails app.

solon

Merry Christmas!

Skinning in front of Store Vengetind
Skinning in front of Store Vengetind

Random Desktop Background Flickr Mac

September 16th, 2011 by pyrat

Recently I wanted to change my desktop pic randomly and use flickr as a source. The currently working solution (a bit dirty) as it stands is as follows.

Every half an hour a cronjob runs which runs the following script.

change_desktop.sh

  #!/bin/bash
 
  utime=`date +%s`
  file="/tmp/#{$utime}.jpg"
  curl -L http://weeflickr.heroku.com/random_image > $file
 
  /path/to/change_desktop.rb $file

It makes a call to the wee flickr app which redirects to a random photo from your photostream. (Chooses a random set, then a random photo within that set.) This file is then saved to disk and is passed to a ruby script.

change_desktop.rb

  #!/usr/bin/env ruby
 
  # Author: Alastair Brunton
 
  require 'rubygems'
  require 'appscript'
 
  include Appscript
 
  file_path = ARGV[0]
 
  app("Finder").desktop_picture.set(MacTypes::FileURL.path(file_path))

This ruby script uses
rb-appscript
to link into apple script and change the mac desktop background.

Note: This has only been tested on snow leopard and the scripts are currently pretty brittle.

The random flickr photo functionality is available from wee_flickr photopicker.

You also need to delete the /tmp photos now and again so I have a little dirty cron that runs once per day.

  #!/bin/bash
 
  cd /tmp && rm *.jpg

Wee Flickr Photopicker

June 6th, 2011 by pyrat

008_7
Orienteering Flag

This is a little tool for embedding flickr images on blog posts. For some reason flickr makes this hard to achieve through the web interface so this little sinatra application solves the problem.

This may be a violation of the flickr terms of service, so you might want to remember to credit flickr on the blog posts.

This app is designed to be deployed to heroku.

Steps to deploy

  • git clone git://github.com/pyrat/wee_flickr.git
  • sign up for heroku account (heroku.com)
  • (sudo) gem install heroku
  • edit FLICKR_USERNAME in app.rb to yours
  • commit change locally (git commit -v -a)
  • heroku create [your app name]
  • git push heroku master

ALL DONE!

If you click the paste board a textile snippet is copied to your clipboard. It assumes that you are writing your blog posts in textile! And this can be pasted into your blog post.

You may want to use this tool as a base for a markdown or plain html embed code system.

Source is on github, wee_flickr