Skip to content

Instantly share code, notes, and snippets.

View madebydna's full-sized avatar
🏠
Working from home

Andrea Singh madebydna

🏠
Working from home
  • Ad Hoc, LLC
  • CA
  • 12:27 (UTC -07:00)
View GitHub Profile
# 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
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
#!/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
@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
@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"
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
# "Lookup" Tables modeled on USDA data
class Food
has_many :nutrients
has_many :weights
end
class Nutrient
belongs_to :food
has_one :nutrient_definition
@madebydna
madebydna / table_simple.rb
Created January 7, 2011 03:39
simple table implementation with tests
class Table
attr_reader :rows, :headers, :header_support
def initialize(data = [], options = {})
@header_support = options[:headers]
@headers = @header_support ? data.shift : []
@rows = data
end
def column_index(pos)
class Address < ActiveRecord::Base
DELTA = 0.001
validates :line1, :city, :presence => true
belongs_to :country
belongs_to :organisation
belongs_to :person
belongs_to :address_type
belongs_to :service
<?xml version="1.0" encoding="UTF-8"?>
<sphinx:docset>
<sphinx:schema>
<sphinx:field name="keywords"/>
.... other fields and attributes omitted
</sphinx:schema>
<sphinx:document id="163">
<title>Logic of Architecture</title>
<keywords>Architekturtheorie, Entwurfsprozess in der Architektur, Computer Aided Design, S&#228;ulenordnungen, Formengrammatik</keywords>
</sphinx:document>