Skip to content

Instantly share code, notes, and snippets.

View solars's full-sized avatar

Christoph Blank solars

View GitHub Profile
this is a test blah
require 'rubygems'
require 'active_record'
require 'active_support'
ActiveRecord::Base.establish_connection(
:adapter => :mysql,
:socket => '/var/run/mysqld/mysqld.sock',
:username => 'root',
:database => 'ngrams',
:password=> 'xxx'
-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.1.0.v20100503
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
require "rubygems"
require "nokogiri"
f = File.open "ota/samples/rateplan-rs.xml"
doc = Nokogiri::XML(f)
f.close
ns = {"http://www.opentravel.org/OTA/2003/05"=>"http://www.opentravel.org/OTA/2003/05", "xmlns:ota"=>"http://www.opentravel.org/OTA/2003/05", "xmlns:seekda"=>"http://connect.seekda.com/2009/04"}
xp = ".//ota:RatePlans"
puts doc.xpath(xp, ns)
require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'dm-migrations'
DataMapper::setup(:default, "sqlite3://#{File.expand_path(File.dirname(__FILE__))}/tmp/participants.db")
class Participant
include DataMapper::Resource
@solars
solars / gist:861843
Created March 9, 2011 07:49
redis mem usage
require 'rubygems'
require 'redis'
def main(opts={})
r = Redis.new(opts)
um = 0
while true do
newum = r.info['used_memory']
if newum != um && um != 0
diff = newum.to_i-um.to_i
# create availabilities for hotels
# each set contains the hotels which have availability
# for a particular day (specified by id) / guest-count
redis = Redis.new
redis.flushall
oldmem = redis.info['used_memory'].to_i
(1..3000).each do |hotel|
# see https://github.com/antirez/redis/blob/master/redis.conf
# set set-max-intset-entries 512 to 4096 for our purpose (3000 hotels)
# https://github.com/kni/redis-sharding
# http://groups.google.com/group/redis-db/browse_thread/thread/ba41db36013c7cb9
#
require 'rubygems'
require "redis"
require 'date'
# temporary (for gem)
gem 'activeldap'
gem 'net-ssh'
gem 'money'
#gem 'seekda-comm'
gem 'sinatra'
gem 'haml'
gem 'pdfkit'
gem 'wkhtmltopdf-binary'
class Event < Ohm::Model
attribute :name
reference :venue, Venue
set :participants, Person
counter :votes
index :name
def validate
assert_present :name