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. | |
# |
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
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/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
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
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
#!/bin/bash | |
DEFAULT_URI='http://production.cf.rubygems.org/' | |
GEM_MARSHAL_VERSION=`ruby -e 'puts Gem.marshal_version'` | |
SPECS_FILE_Z="specs.$GEM_MARSHAL_VERSION.gz" | |
AVAILABLE_GEMS=`mktemp /tmp/available_gems.XXX` | |
GEMS_ALREADY_DOWNLOADED=`mktemp /tmp/gems_already_downloaded.XXX` | |
GEMS_TO_DOWNLOAD=`mktemp /tmp/gems_to_download.XXX` | |
GEMS_TO_REMOVE=`mktemp /tmp/gems_to_remove.XXX` | |
PARALLEl_DOWNLOAD=15 |
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' | |
n = 5_000 | |
sum = BigDecimal.new('0') | |
dx = BigDecimal.new('1') / n | |
1.upto(n) { |i| sum += dx * (dx * i) ** 2 } | |
puts sum | |
puts sum.to_s | |
puts sum.to_f |
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
* root servers | |
- no hassle with finding a good location with clean, cool air and stable electicity | |
- broken hard disk? we exchange it within 1 hour | |
* virtualization | |
- choose what you need, no less and no more | |
- super fast deployment | |
* special linux distribution | |
- compatible to everything | |
- super efficient | |
- rock stable |
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 'rbnacl' | |
require 'celluloid/zmq' | |
Celluloid::ZMQ.init | |
# Monkey patching | |
module Celluloid | |
module ZMQ | |
module ReadableSocket | |
# Reads a multipart message, stores it into the given buffer and returns | |
# the buffer. |
OlderNewer