This file contains hidden or 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
class Object | |
def local_methods | |
parent = self.class.superclass | |
(parent ? self.methods - parent.instance_methods : self.methods).sort | |
end | |
alias_method :m, :local_methods | |
end |
This file contains hidden or 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
class Person | |
def initialize(options = {}) | |
options.each do |key, value| | |
self.instance_variable_set(:"@#{key}", value) | |
self.class.send(:define_method, key) do | |
self.instance_variable_get(:"@#{key}") | |
end | |
self.class.send(:define_method, "#{key}=".intern) do |*args| |
This file contains hidden or 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
syntax on | |
"font | |
color github | |
set cursorline | |
set guifont=Monaco:h12 | |
set guioptions-=T | |
set linespace=1 | |
set vb |
This file contains hidden or 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
" Vim color file | |
" | |
" Author: Anthony Carapetis <[email protected]> | |
" | |
" Note: Based on github's syntax highlighting theme | |
" Used Brian Mock's darkspectrum as a starting point/template | |
" Thanks to Ryan Heath for an easy list of some of the colours: | |
" http://rpheath.com/posts/356-github-theme-for-syntax-gem | |
hi clear |
This file contains hidden or 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 'yaml' | |
PAIR_EMAIL = "[email protected]" | |
AUTHORS = YAML.load(`cat ~/.pair.yml`) | |
unless File.exists?(".git") | |
puts "This doesn't look like a git repository." |
This file contains hidden or 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
window.console = window.console || {}; | |
["log", "info", "debug", "warn", "error"].forEach(function(level) { | |
console[level] = console[level] || function(){} | |
}); |
This file contains hidden or 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
desc "Checks the JavaScript files with JSLint" | |
task :jslint do | |
failed_files = [] | |
skipped_files = ["jquery-1.4.js", "jquery-json-2.1.js"] | |
rhino_path = File.join(RAILS_ROOT, "vendor", "jslint", "js.jar") | |
jslint_path = File.join(RAILS_ROOT, "vendor", "jslint", "jslint.js") | |
Dir['public/**/*.js'].reject{|path| skipped_files.include?(path.match(/.*\/(.*)/)[1])}.each do |name| | |
cmd = "java -jar #{rhino_path} #{jslint_path} #{name}" |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>name</key> | |
<string>GitHub</string> | |
<key>settings</key> | |
<array> | |
<dict> | |
<key>settings</key> |
This file contains hidden or 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
var rows = ["alice apple", "bob banana", "charlie cherry", "alice date", "bob eggplant"]; | |
var mapped = rows.map(function(row) { | |
return row.split(" "); | |
}); | |
var reduced = mapped.reduce(function(hash, pair) { | |
var key = pair[0], | |
val = pair[1]; |
This file contains hidden or 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
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
meth, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, [send(meth, *attrs).to_s]] | |
end |