Skip to content

Instantly share code, notes, and snippets.

@code
code / woot.txt
Created July 22, 2008 13:40
Just a little test.
Love this.
How do I tell it that I want this to be ruby?
@code
code / tab_view.html.haml
Created July 31, 2008 04:59
Adding a simple tab view, nothing fancy just easy.
-# File: application.html.haml
-# Include YUI in your head
=yui_loader_includes
-# File: _tab_view.html.haml
-# To use a component in one of your views, call yui_require
-# Components are loaded using the yui loader, dependencies are managed
-# Any code added to yui_script filter will be rolled into single init function and outputted with the loader
# File: ec2_bundle.rb
# Author: Luke Hubbard
# Gist: http://gist.github.com/gists/8770
# License: MIT
# Desc: Simple script to bundle and upload an EC2 instance
require 'open-uri'
# Helpers
def read(file)
# File: robot.rb
# Author: Luke Hubbard
# Gist: http://gist.github.com/gists/18289
# License: MIT
# Description: Ruby version of robot to solve Google Treasure Hunt.
def robot(rows, cols)
matrix = Array.new(rows).collect{ Array.new(cols) }
x, y = rows-1, cols-1
x.downto(0) do |row|
# File: c_version_robot.rb
# Author: Luke Hubbard
# Gist: http://gist.github.com/gists/18325
# License: MIT
# Description: C version of the robot for Google Treasure Hunt.
# Bugs: Cant handle big grids, numbers too big.
require 'rubygems'
require 'inline'
@code
code / swf.rb
Created October 29, 2008 17:30
# File: swf.rb
# Author: Luke Hubbard
# Gist: http://gist.github.com/20755
# License: MIT
# NOTE THIS HAS NOW BEEN REPLACE BY
# http://github.com/code/swf_object_helper
# SWFObject Embed Helper - Easy swf embed using SWFObject and ruby magic
#
# File: password_generator.rb
# Author: Luke Hubbard
# Gist: http://gist.github.com/21812
# License: MIT
require 'digest'
class PasswordGenerator
CHARS = (('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l 0)
SIZE = 9
@code
code / dreamhost_adapter.rb
Created November 3, 2008 06:24
Quick and dirty api for dreamhost uisng mechanize. Add / remove domains, users, and databases.
# File: dreamhost_adapter.rb
# Author: Luke Hubbard
# Gist: http://gist.github.com/gists/21814
# License: MIT
require 'rubygems'
require 'mechanize'
require 'logger'
# Need to monkey patch the CookieJar so it accepts SSL cookies!
# File: kuler.rb
# Author: Luke Hubbard
# Gist: http://gist.github.com/21838
# License: MIT
# Description: Little API wrapper for Kuler, Adobe's color site. http://kuler.adobe.com. Not you need an api key!
require 'rubygems'
require 'active_support'
require 'syndication/rss'
require 'open-uri'
class Fixnum
def even?
num = self
stack = [1]
while(stack.last < num)
stack.push(stack.last*2)
end
while(num > 1)
val = stack.pop