Skip to content

Instantly share code, notes, and snippets.

View madebydna's full-sized avatar

Andrea Singh madebydna

  • Ad Hoc, LLC
  • CA
  • 21:43 (UTC -07:00)
View GitHub Profile
# "Lookup" Tables modeled on USDA data
class Food
has_many :nutrients
has_many :weights
end
class Nutrient
belongs_to :food
has_one :nutrient_definition
rvmrc = <<-RVMRC
rvm_gemset_create_on_use_flag=1
rvm_trust_rvmrcs=1
rvm gemset use #{app_name}
RVMRC
create_file ".rvmrc", rvmrc
# Attempting to create/activate gemset and install gems via Bundler
@madebydna
madebydna / lyric.rb
Created August 26, 2010 23:12 — forked from ruanwz/lyric.rb
class Song
def initialize
@bottles = 99
end
def sing
@bottles.downto(0) do |bottle|
if bottle > 1
puts "#{bottle} bottles of beer on the wall, #{bottle} bottles of beer."
puts "Take one down and pass it around, #{bottle - 1} bottles of beer on the wall.\n"
@madebydna
madebydna / lyric.rb
Created August 26, 2010 23:12 — forked from ruanwz/lyric.rb
require 'net/http'
class Song
def initialize
end
def sing
end
end
#!/usr/bin/env ruby -wKU
puts `ps -o rss= -p #{$$}`.to_i
current_fib = 1
fib_numbers = []
for i in 1..4000000 do
if i == current_fib * 2
fib_numbers << i
require 'json'
class Caterpillar
def pig_out(tree)
climb_tree(File.read(tree))
@tree_height = @tree.length - 1
@tree_height.downto(0) do |branch|
(0..(branch-1)).each do |twig|
@tree[branch - 1][twig] += [@tree[branch][twig], @tree[branch][twig+1]].max
# Triangle Problem:
def triangle(a, b, c)
raise TriangleError if [a,b,c].detect{|arg| arg <= 0 }
if a == b && a == c
:equilateral
elsif (a == b) || (a == c) || (b == c)
h = Hash.new(0)
[a,b,c].each do |v|
h[v] += 1