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 'json' | |
require 'net/http' | |
require 'bigdecimal' | |
require 'bigdecimal/util' | |
class BitcoinClient | |
def initialize(config_file = File.expand_path("~/.bitcoin/bitcoin.conf"), host = '127.0.0.1', port = 8332) | |
raise "missing config file" if !File.exist?(config_file) | |
config = File.read(config_file).each_line.inject({}) do |hash, line| |
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
birthday = Date.parse("YYYY-MM-DD") # XXX: Change me | |
today = Date.today | |
total_days = (today - birthday).to_i | |
mondays = (total_days / 7) | |
if ((total_days % 7) + birthday.wday) % 7 >= 1 | |
mondays += 1 | |
end | |
puts "You've had #{mondays} Mondays!" |
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 Foo | |
def huge | |
puts "huge" | |
end | |
end | |
module Bar | |
def new_huge | |
puts "small" | |
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
require 'rubygems' | |
require 'mechanize' | |
require 'open-uri' | |
a = Mechanize.new | |
a.redirect_ok = false | |
retries = 0 | |
a.get("http://www.illegal-art.net/allday/") do |page| | |
begin | |
result = page.form_with(:action => "allday.php") do |f| |
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 Fixnum | |
def prime? | |
bound = Math.sqrt(self).floor | |
bound < 2 || (2..bound).all? { |i| self % i > 0 } | |
end | |
def palindrome? | |
str = self.to_s | |
len = str.length | |
last = len - 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 'forgery' | |
require 'csv' | |
require 'blundersaur' | |
require 'pp' | |
original = CSV.open("original.csv", "w") | |
fudged = CSV.open("fudged.csv", "w") | |
headers = %w{id first_name last_name dob age street_address city state zip ssn} | |
original << headers |
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
PATH="/usr/bin:/usr/openwin/bin:/usr/ucb:/usr/sfw/bin:/usr/sfw/bin:/usr/ccs/bin" | |
CC="cc -xc99" | |
CPPFLAGS="-I/opt/csw/include -I/usr/local/include" | |
CFLAGS="-O -xlibmieee" | |
F77=f95 | |
FFLAGS=-O | |
CXX="$CC -library=stlport4" | |
CXXFLAGS=-O | |
FC=f95 | |
FCFLAGS=$FFLAGS |
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 'sequel' | |
LETTERS = { | |
'a' => 0, | |
'b' => 2, | |
'c' => 2, | |
'd' => 1, | |
'e' => 0, | |
'f' => 2, | |
'g' => 2, |
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 "open-uri" | |
require "rubygems" | |
require "json" | |
USERNAME = "viking" | |
query = ARGV.first.downcase | |
gists = JSON.parse(open("https://api.github.com/users/#{USERNAME}/gists").read) |