Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'rubygems'
require 'RMagick'
include Magick
NAME = "cord"
FOLDER = "/Users/d/Desktop/"
# Mattes an image using another image as the alpha channel
#!/usr/local/bin/ruby
require 'rubygems'
require 'plist'
require 'set'
LIBRARY = '/Users/d/Music/iTunes/iTunes Music Library.xml'
class String
def url_unescape
#!/usr/bin/env ruby
# This is my ordered hash in Ruby.
# There are many like it, but this one is mine.
class OrderedHash < Hash
def initialize(*args)
super
@order = []
end
#!/usr/bin/env ruby
# Simple respond_to implementation, for use in something like Sinatra.
# Real simple, but does the trick.
def format
:json
end
class RespondTo
>> puts "###$$$".split('').map{|c| c[0] }.inspect
[35, 35, 52, 57, 53, 51, 50, 36]
>> puts '###$$$'.split('').map{|c| c[0] }.inspect
[35, 35, 35, 36, 36, 36]
#!/usr/bin/env ruby
# Parses addresses from Portland CraigsList, more or less.
StreetNames = open("#{File.dirname(__FILE__)}/streets.txt").read.split("\n")
Counties = %w{portland milwaukie tigard gresham clackamas beaverton cornelius gladstone}
StreetSuffixes = %w{avenue street boulevard court ct crt way place pl lane ave st blvd}
Word = /(\b([A-Za-z]+)\b)/i
SomeWords = /#{Word}{1,5}/i
@qwzybug
qwzybug / content-editable.html
Created September 8, 2009 22:38
Minimal inline editing example. Video http://gallery.me.com/wyntir#100163
<html>
<head>
<title>MadLib</title>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css">
.field { text-decoration: underline; }
</style>
</head>
<body>
<p>
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'
get '/' do
haml :index
end
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'
get '/' do
haml :index
end
#!/usr/bin/env ruby
# Look what you fucking made me do, Lynagh, I wrote an ORM.
# Or, an OHM. That might be even worse.
module Hashable
def self.included klass
klass.instance_eval do
class << self; attr_accessor :attr_names; end
@attr_names = superclass.respond_to?(:attr_names) ? superclass.attr_names : []