Skip to content

Instantly share code, notes, and snippets.

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|
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!"
class Foo
def huge
puts "huge"
end
end
module Bar
def new_huge
puts "small"
end
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|
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
require 'net/http'
require 'tempfile'
require 'taglib'
if ARGV[0].nil?
$stderr.puts "Syntax: #{$0} <uri>"
exit 1
end
uri = URI(ARGV[0])
ext = uri.path.split('.').last
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
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
require 'sequel'
LETTERS = {
'a' => 0,
'b' => 2,
'c' => 2,
'd' => 1,
'e' => 0,
'f' => 2,
'g' => 2,
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)