Skip to content

Instantly share code, notes, and snippets.

View pjkelly's full-sized avatar

PJ Kelly pjkelly

  • Orange County, CA
View GitHub Profile

On the iMac:

brew install --HEAD --force riak -v

On the MacBook

brew update
# get Erlang R14B03
brew install erlang

install the HEAD riak (and NOT also install HEAD Erlang.)

@pjkelly
pjkelly / install-apt-file.sh
Created July 7, 2011 01:00
Not sure what apt-get package contains a file?
# credit: http://crshlv.ly/qkAzW0
#
# I found this especially useful when trying
# to figure out equivalent apt-get packages
# for certain Perl CPAN modules.
apt-get install apt-file
apt-file update
apt-file search URI::Escape
@pjkelly
pjkelly / setup-vmware-image-with-static-IP.markdown
Created July 7, 2011 01:06
VMWare Fusion Images with a static IP Address on Mac OS X Snow Leopard

How to setup your VMWare Fusion images to use static IP addresses on Mac OS X

At Crush + Lovely, we use Railsmachine's Moonshine to automate the configuration of our servers. When writing our deployment recipes, VMWare Fusion's ability to take snapshots and rollback to these snapshots is a huge timesaver because it takes just seconds to roll a server image to it's original state.

When you're just configuring a single server, having a static IP address for your server image isn't too important, but when you're configuring multi-server setups, it can be useful to duplicate a number of server images and give each a static IP address so you can consistently deploy to them. While not documented well at all, it turns out that this is relatively easy to accomplish in four simple steps.

1. Determine the MAC address of your guest machine

Let's say you have a guest machine with the name ubuntu-lucid-lynx-base a

@pjkelly
pjkelly / check-packages-installed.sh
Created July 7, 2011 01:08
What packages are installed via apt-get?
# credit: http://crshlv.ly/pSqu6l
# show all packages installed
dpkg --get-selections
# show all packages installed containing "php"
dpkg --get-selections | grep php
@pjkelly
pjkelly / README.markdown
Created July 7, 2011 17:04
Unattended interactive installers with Puppet/Moonshine

Three options:

  1. If an apt-get package is available, use it, then tweak configuration files after installation.
  2. If no package is available, see if the installer has a "noninteractive" mode. For instance, apt-get can be forced to auto-answer all questions with the defaults using ENV['DEBIAN_FRONTEND'] = "noninteractive".
  3. If a noninteractive mode is not available, try feeding the installer an answer file. e.g.
pecl install apc < answers.txt 
@pjkelly
pjkelly / import.rb
Created July 21, 2011 02:16
Converting JSON to Google Spreadsheets
require 'rubygems'
require 'yajl'
require 'to_google_spreadsheet'
json = File.new('sizes.json', 'r') # file with more than one json
parser = Yajl::Parser.new
data = parser.parse(json)
GoogleSpreadsheet.config do |c|
c.email = "[email protected]"
@pjkelly
pjkelly / example.rb
Created July 21, 2011 02:16
JSON Encoding in Rails 1.2.x
# In Rails 1.2.x, the default JSON encoder doesn't quote
# attributes. To force quoting, set the following option
# to false. From the ActiveSupport::JSON docs:
#
# When +true+, Hash#to_json will omit quoting string or symbol keys
# if the keys are valid JavaScript identifiers. Note that this is
# technically improper JSON (all object keys must be quoted), so if
# you need strict JSON compliance, set this option to +false+.
# mattr_accessor :unquote_hash_key_identifiers
# @@unquote_hash_key_identifiers = true
@pjkelly
pjkelly / installer.sh
Created August 11, 2011 18:59
Installing PHPUnit via Pear on Ubuntu Lucid
# Uninstall any pre-existing packaged
# versions of phpunit
sudo apt-get remove phpunit
# Install pear via apt-get
sudo apt-get install php-pear
# Update existing pear channels
sudo pear channel-update pear.php.net
@pjkelly
pjkelly / instructions.md
Created February 27, 2012 07:57
Crush + Lovely Development Environment Setup for Mac OS X Lion

Before you start

These instructions work best on a fresh system. While I've gotten them to work on a system where I just upgraded from Snow Leopard to Lion and had a previously working development environment (using an older version of Cinderella in my case), it was not without difficulty. It's much easier to start from scratch.

These instructions are for Mac OS X 10.7.x (Lion) only.

SSH Keys

If you have SSH keys setup already

@pjkelly
pjkelly / calculate-construction-cost.md
Created March 8, 2012 00:38
Calculating Time and Cost of Building Floors in Tiny Tower

Calculating Construction Cost

According to the Tiny Tower Wiki the equation for calculating how much it costs to build a given floor is:

cost = 150 × floor_number 2

A simple way to evaluate this equation in Ruby would be: