Skip to content

Instantly share code, notes, and snippets.

View joshrickard's full-sized avatar

Josh Rickard joshrickard

View GitHub Profile
@joshrickard
joshrickard / gist:2049584
Created March 16, 2012 10:57
Ruby Prawn - horizontally & vertically center a table within its container
# inspiration from: https://gist.github.com/2045188
# horizontally & vertically center a table within its container
t = make_table(table_data, { :position => :center })
move_down((bounds.height - t.height) / 2.0)
t.draw
# calculate the table's offset from its container
x_offset = (bounds.width - t.width) / 2
y_offset = (bounds.height - t.height) / 2
@joshrickard
joshrickard / setup.sh
Last active December 28, 2015 16:59
Setup ruby environment on Ubuntu 14.04.1 desktop.
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential curl git-core redis-server
# setup git
git config --global user.name "Josh Rickard"
git config --global user.email josh.rickard@gmail.com
# install RVM
curl -L https://get.rvm.io | bash
@joshrickard
joshrickard / setup.sh
Last active December 31, 2015 21:58
Database
apt-get -y update
apt-get -y upgrade
apt-get -y install build-essential curl gettext mysql-server redis-server
@joshrickard
joshrickard / setup.sh
Last active January 1, 2016 01:19
Parser
apt-get -y update
apt-get -y upgrade
apt-get -y install build-essential curl gettext
wget http://download.mono-project.com/sources/mono/mono-3.2.5.tar.bz2
tar jxf mono-3.2.5.tar.bz2
cd mono-3.2.5/
./configure --prefix=/usr/local; make; make install
@joshrickard
joshrickard / gist:44c15bd3a63b59adb851
Last active August 29, 2015 14:14
Ubuntu Server 14.04 LTS with Ruby
sudo apt-get -y update
sudo apt-get -y dist-upgrade
sudo apt-get -y install apticron build-essential curl git-core ntp sendmail
sudo apt-get -y autoremove
# reboot
shutdown -r now
# update email address for update notifications
#
@joshrickard
joshrickard / word_search.rb
Created May 25, 2015 19:39
Starting with a word, change one letter at a time to get to the target word.
$words_attempted = { } # global list of words already attempted
$word_dictionary = { } # global dictionary of valid words
# Returns the indicies for current_word as an array. Setting
# optimized to true will place non-matching characters between
# the current and target words at the beginning of the array.
def get_letter_indicies(optimized, current_word, target_word)
[].tap do |letter_indicies|