Skip to content

Instantly share code, notes, and snippets.

View shostakovich's full-sized avatar
🚩
Focusing

Robert Curth shostakovich

🚩
Focusing
View GitHub Profile
@shostakovich
shostakovich / gist:3806384
Created September 30, 2012 10:11
LED USB LAMP
/* LED USB Lamp
This program controls a high power LED via PWM and reads in a touch pad.
The circuit: * LED attached from digital pin 3 to ground. * touch pad connected to pin 6 and 5
Created 18 Aug 2012 By Sebastian Schuster
*/
@shostakovich
shostakovich / prime_factor_decomposer.rb
Created September 29, 2012 15:37
Lessons from the prime factorization dojo
module PrimeFactorDecomposer
def decompose(number)
if number < 4
number
else
[2,2]
end
end
end
@shostakovich
shostakovich / gist:3803457
Created September 29, 2012 07:55
Prime factor
describe PrimeFactorDecomposer do
include PrimeFactorDecomposer
it "returns no prime factors for 1" do
decompose(1).should be_empty
end
end
describe "A way to extract address" do
it "creates a value object upon read" do
foo = Poi.new
foo.name = "test"
foo.company_name = "bar"
foo.title = "zzzzz"
foo.address.name.should == "test"
foo.address.company.should == "bar"
@shostakovich
shostakovich / set_experiments.rb
Created August 22, 2012 17:42
Nice stuff on set
require 'set'
Set.new([1, 2, 3])
#<Set: {1, 2, 3}>
Set.new([1, 2, 3]) do |val| val * 2 end
#<Set: {2, 4, 6}>
Set.new([1,2,3]) & Set.new([2,3,4])
#<Set: {2, 3}>
@shostakovich
shostakovich / fibonaci_sequence_generator.rb
Created August 20, 2012 19:18
Fibonaci Sequence Generator 1
class FibonaciSequenceGenerator
class SequenceToLongError < StandardError; end
def generate(length)
raise SequenceToLongError if length > 50
@sequence = []
1.upto(length) {|number| @sequence << fibonaci_number(number)}
@sequence
end
@shostakovich
shostakovich / bowling_game.rb
Created July 9, 2012 18:04
Bowling game 5th try
class BowlingGame
attr_reader :rolls
def initialize
@rolls = []
end
def roll(pins)
@rolls << pins
end
@shostakovich
shostakovich / bowling_game.rb
Created July 8, 2012 08:50
Bowling game 4th iteration
class BowlingGame
def initialize
@rolls = []
end
def roll(pins)
@rolls << pins
end
def score
@shostakovich
shostakovich / prime_factor_decomposer.rb
Created July 7, 2012 09:53
Prime Factors Kata 4th iteration
module PrimeFactorDecomposer
def decompose(number)
return [number] if prime?(number)
primes = []
2.upto(number / 2) do |candidate|
while (number % candidate).zero? do
primes << candidate
number = number / candidate
end
@shostakovich
shostakovich / freedom.sh
Created July 3, 2012 20:01
Freedom script for Mac OS X
#!/bin/bash
echo "Enough of this filthy internet" | cowsay -s
sudo route -n delete default &> /dev/null