View ahoward.rb
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 'gems' | |
require 'nokogiri' | |
require 'octokit' | |
require 'open-uri' | |
doc = Nokogiri::HTML(open('https://rubygems.org/profiles/45069')) | |
repo_names = doc.search('.profile-list ol li a.profile-rubygem').map do |element| | |
gem = Gems.info(element.text.split(/\s+/)[1]) | |
gem['info'].match('kicks the ass') && gem['homepage_uri'].match(%r{github\.com/ahoward/(\w*)})[1] |
View pmap.rb
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
def pmap(enum) | |
return to_enum(:pmap, enum) unless block_given? | |
enum.map { |e| Thread.new { yield e } }.map(&:value) | |
end | |
# Returns elements in order, as expected. | |
pmap(1..10) { |e| e } #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
# Returns elements in nondeterministic order on MRI >= 1.9.3. | |
# Works as expected on JRuby, Rubinius, and earlier versions of MRI. |
View exposable.rb
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 'set' | |
module Lotus | |
module Action | |
module Exposable | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods |
View stratus-installation.html
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
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$.stratus({ | |
key: "Enter your Client ID here", | |
links: "https://soundcloud.com/zedsdead/sets/somewhere-else-ep" | |
}); | |
}); | |
</script> |
View stratus-customization.html
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
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$.stratus({ | |
auto_play: true, | |
download: false, | |
key: "Enter your Client ID here", | |
links: 'http://soundcloud.com/qotsa', | |
random: true | |
}); | |
}); |
View 404_image_swap.js
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
$(document).ready(function() { | |
$('img').error(function(){ | |
$(this).attr('src', 'not_found.png'); | |
}); | |
}); |
View classes.rb
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 | |
nodes = [] | |
edges = {} | |
ObjectSpace.each_object(Class) do |klass| | |
# Skip classes outside the global namespace | |
next if klass.to_s.include?(':') | |
# Skip classes like ARGF.class | |
next if klass.to_s.include?('.') |
View winner.rb
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 'curb' | |
require 'json' | |
followers_response = Curl::Easy.http_get("http://twitter.com/followers/ids/perpetually.json") | |
followers = JSON.parse(followers_response.body_str) | |
winner_id = followers[rand(followers.length)] | |
users_response = Curl::Easy.http_get("http://twitter.com/users/show/#{winner_id}.json") | |
winner = JSON.parse(users_response.body_str) | |
puts "We have a winner!" |
View config.rb
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
MerbAdmin.config User do | |
label "Users" # @model.pretty_name | |
list do | |
before do | |
puts "Called before list" | |
end | |
fields :name, :description # All columns | |
filters :publication_date, :retired # All booleans |
OlderNewer