Skip to content

Instantly share code, notes, and snippets.

@chrismealy
chrismealy / zipper.rb
Created December 19, 2011 17:00 — forked from yhara/zipper.rb
Ruby implementation of Zipper (and its spec)
#
# Zipper has @left and @right.
# When a zipper represents [1, 2, 3, <cursor>, 4, 5],
# @left == [3, [2, [1, []]]], @right == [4, [5, []]]
# Note that @left is in reverse order.
#
class Zipper
include Enumerable
def self.make(*vals)
@chrismealy
chrismealy / zipper.rb
Created December 19, 2011 17:00 — forked from yhara/zipper.rb
Ruby implementation of Zipper (and its spec)
#
# Zipper has @left and @right.
# When a zipper represents [1, 2, 3, <cursor>, 4, 5],
# @left == [3, [2, [1, []]]], @right == [4, [5, []]]
# Note that @left is in reverse order.
#
class Zipper
include Enumerable
def self.make(*vals)
@chrismealy
chrismealy / Procfile
Created January 23, 2012 21:35 — forked from czottmann/Procfile
Example of a Foreman/Capistrano/upstart setup
worker: QUEUE=* bundle exec rake environment resque:work
scheduler: bundle exec rake environment resque:scheduler
@chrismealy
chrismealy / rename-db.sh
Created January 24, 2012 21:49 — forked from michaelmior/rename-db.sh
Simple script to move all tables from one database to another. Please don't use this in product as could fail horribly. Also, RENAME table doesn't work on views, so they won't be migrated.
#!/bin/sh
OLD_DB=$1
NEW_DB=$2
TABLES=`echo "SHOW TABLES IN $1;" | mysql -NB`
IFS="
"
@chrismealy
chrismealy / rbenv-install-system-wide.sh
Created February 13, 2012 00:06
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@chrismealy
chrismealy / Ubuntu rbenv
Created February 13, 2012 01:00
Installing Ruby 1.9.2 with OpenSSL on Ubuntu 11.04 using ruby-build and rbenv
# for more info: https://gist.github.com/1120938
@chrismealy
chrismealy / file1.sh
Created February 16, 2012 22:53 — forked from rojotek/file1.sh
Ruby with OpenSSL on OSX 10.7
rvm pkg install openssl
rvm remove 1.9.3
rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr --with-gcc=clang
@chrismealy
chrismealy / gist:2714207
Created May 16, 2012 21:44 — forked from kevindavis/gist:1868651
Bootstrap styling for jQuery UI autocomplete
.ui-autocomplete {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
float: left;
display: none;
min-width: 160px;
_width: 160px;
padding: 4px 0;
@chrismealy
chrismealy / async_resque.rb
Created July 17, 2012 13:22 — forked from michelson/async_resque.rb
Use async methods for Sidekiq & Resque
# -*- encoding : utf-8 -*-
module AsyncResque
extend ActiveSupport::Concern
included do
include Sidekiq::Worker
def perform(*args)
self.class.find(args.first).send(args.last)
end
end
@chrismealy
chrismealy / async_job.rb
Created July 17, 2012 13:27
A simple module to add async method to your activerecord or other ruby objects
module Resque
module AsyncJob
@@_queue= :default
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
# Set the default queue. chain method
def queue(new_queue = nil)