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
### Keybase proof | |
I hereby claim: | |
* I am mikeycgto on github. | |
* I am mikeycgto (https://keybase.io/mikeycgto) on keybase. | |
* I have the public key with fingerprint 3339 7AF8 1078 43C9 B661 B3AE 9EB4 65BB A866 703F | |
To claim this, I am signing this object: |
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
require 'fileutils' | |
require 'nokogiri' | |
require 'open-uri' | |
doc = Nokogiri::HTML(open('http://lyrics.wikia.com/The_National')) | |
doc.css('h2').each do |header| | |
img = header.next_element | |
list = img.next_element if img | |
if list && list.name == 'ol' |
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 'sinatra' | |
# simple script to serve static files from an arbitrary directory via Sinatra | |
# usage: rserve [/path/to/dir] [port] | |
# path will default to '.' | |
pub = File.expand_path(ARGV.shift || '.') | |
puts "Setting Public to #{pub}" |
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
describe "Something" do | |
before do | |
# __name__ defined in MiniTest::Unit::TestCase | |
VCR.insert_cassette(__name__) | |
end | |
after do | |
VCR.eject_cassette | |
end | |
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
require 'httparty' | |
require 'nokogiri' | |
require 'date' | |
require 'json' | |
abort 'usage: ruby nfl.rb [WEEK NUM]' if ARGV.size < 1 | |
resp = HTTParty.get("http://m.nfl.com/scores/reg/#{ARGV.shift}/") | |
parser = Nokogiri::HTML(resp.body) |
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
// attempts to call a function; returns undef if function is not defined | |
Object.prototype.try = function(name, args){ | |
return this[name] ? this[name].apply(this, args) : undefined; | |
}; | |
// more robust version | |
Object.prototype.try = function(name){ | |
return this[name] ? this[name].apply(this, Array.prototype.slice.call(arguments, 1)) : undefined; | |
}; |
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
class Settings | |
attr_reader :config | |
def initialize(fname) | |
@file_name = fname | |
config = YAML.load_file(fname) rescue false | |
@config = config || {} | |
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
(function($){ | |
var prop = 'VisibilityState'; | |
var evt = 'visibilitychange'; | |
var vendors = ['webkit', 'ms']; | |
var vendor; | |
function set_state(state){ | |
$(window).trigger('visibilitychange', state); | |
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
class ApplicationControllerTest < ActionController::TestCase | |
def setup | |
# create and initialize anonymous controller | |
@controller = Class.new(ApplicationController) do | |
def index | |
# what goes here all depends on the situation and the method your trying to test | |
end | |
end::new | |
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
var LocationHash = (function(ev){ | |
var hash, changed = []; | |
function read_hash(){ | |
var list = location.hash.substr(1).split('&'); | |
hash = {}; | |
for (var i = 0, pair; pair = list[i]; i++){ | |
var split = pair.split('='); | |
OlderNewer