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
# 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 |
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 '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 |
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 -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 |
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 'net/http' | |
class Song | |
def initialize | |
end | |
def sing | |
end | |
end |
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
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" |
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
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 |
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
# "Lookup" Tables modeled on USDA data | |
class Food | |
has_many :nutrients | |
has_many :weights | |
end | |
class Nutrient | |
belongs_to :food | |
has_one :nutrient_definition |
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
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) |
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
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 |
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
<?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äulenordnungen, Formengrammatik</keywords> | |
</sphinx:document> |
OlderNewer