Skip to content

Instantly share code, notes, and snippets.

require 'bigdecimal'
require 'bigdecimal/math'
class Integer
def fact
return self * (self-1).fact if self > 1
return 1
end
end
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
#! /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
See https://github.com/paddor/em-simple_telnet
#! /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 ...
#! /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.
#