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
describe PrimeFactorDecomposer do | |
include PrimeFactorDecomposer | |
it "returns no prime factors for 1" do | |
decompose(1).should be_empty | |
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
module PrimeFactorDecomposer | |
def decompose(number) | |
if number < 4 | |
number | |
else | |
[2,2] | |
end | |
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
/* 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 | |
*/ |
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
#!/bin/sh | |
USERNAME=shostakovich | |
mkdir ~/tmp | |
cd ~/tmp | |
# Install GCC + Git | |
curl https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg > GCC-10.7-v2.pkg | |
sudo installer -pkg GCC-10.7-v2.pkg -target / |
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
# given enumerable object. | |
def |(enum) | |
dup.merge(enum) | |
end | |
alias + | ## | |
alias union | ## | |
# Returns a new set built by duplicating the set, removing every | |
# element that appears in the given enumerable object. | |
def -(enum) |
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 EratosthenesGenerator < PseudoPrimeGenerator | |
def initialize | |
@last_prime = nil | |
super | |
end | |
def succ | |
@last_prime = @last_prime ? EratosthenesSieve.instance.next_to(@last_prime) : 2 | |
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 PseudoPrimeGenerator | |
include Enumerable | |
def initialize(ubound = nil) | |
@ubound = ubound | |
end | |
def upper_bound=(ubound) | |
@ubound = ubound | |
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 Sensor | |
OFFSET_IN_MBAR = 1000 | |
def current_pressure | |
OFFSET_IN_MBAR + random_pressure(); | |
end | |
private | |
def random_pressure |
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
def [](name) | |
@table[name.to_sym] | |
end | |
def []=(name, value) | |
modifiable[new_ostruct_member(name)] = value | |
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
[push] | |
default = current | |
[alias] | |
pfush = "push --force" |