This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
require 'rubygems' | |
require 'plist' | |
require 'set' | |
LIBRARY = '/Users/d/Music/iTunes/iTunes Music Library.xml' | |
class String | |
def url_unescape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'sinatra' | |
require 'haml' | |
get '/' do | |
haml :index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'sinatra' | |
require 'haml' | |
get '/' do | |
haml :index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 : [] |