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 'bigdecimal' | |
require 'bigdecimal/math' | |
class Integer | |
def fact | |
return self * (self-1).fact if self > 1 | |
return 1 | |
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
warn "Opening database connection ..." | |
DB = Sequel.postgres(:host=>'localhost', :user=>'logs', :database=>'logs') | |
warn "Running COPY command with data ..." | |
DB.run copy_command | |
DB.synchronize do |conn| | |
ret = conn.put_copy_data(copy_data) # or raise "could not send COPY data" | |
warn "Sent COPY data: #{ret}" | |
ret = conn.put_copy_end # or raise "could not send COPY end" | |
warn "Sent COPY end: #{ret}" | |
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
#! /usr/local/bin/ruby | |
class Car | |
# excetion raised when not enough fuel left to drive given distance | |
class NotEnoughFuel < RuntimeError | |
end | |
# constructor with one parameter | |
def initialize vendor |
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
See https://github.com/paddor/em-simple_telnet |
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 | |
nummern = [ | |
"+41 ( 0 ) 79-123 4567", | |
"+41-79-123 4567", | |
"079 123 45 67", | |
"+41 ( 079 ) 123 67 90", | |
] | |
# fuer jede nummer ... |
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 | |
# File : to_num.rb | |
# Author : Patrik Wenger <paddor@gmail.com> | |
# Date : 26th September 2008 | |
# Version : 0.2 | |
# | |
# It would be nice if there were fancy strings like %i, %f and %n for integers, | |
# floats and numbers, respectively. This library attempts to solve this problem. | |
# |
NewerOlder