Skip to content

Instantly share code, notes, and snippets.

@kirel
kirel / gist:3060
Created July 29, 2008 10:44
Scraping ugly tables...
#!/usr/bin/ruby
require 'rubygems'
gem 'RubyInline', '=3.6.3'
require 'scrubyt'
bus_data = Scrubyt::Extractor.define do
fetch 'http://rvm-online.de'
route = { :place_origin => "everswinkel",
:name_origin => "mitte",
#!/usr/bin/ruby
class A
def dsl &block
puts "dsl active"
instance_eval &block
end
private
def priv
puts "This is private - please stay out"
end
#!/usr/bin/ruby1.9
def Hash.smash(keys, values)
h = {}
keyiterator,valueiterator = keys.each, values.each
loop { h[keyiterator.next] = valueiterator.next }
h
end
Hash.smash [1,2,3,4], [5,6,7,8] # => { 1=>5, 2=>6, 3=>7, 4=>8 }
class Distance
FACTORS = {
:kilometers => 1000.0,
:meters => 1.0,
:decimeters => 0.1,
:centimeters => 0.01,
:millimeters => 0.001,
}
// add methods to existing
template<class T>
class TemplateProperty<T> {
public:
// convenience methods
EqualCondition& valueEqual(const T& value, const ConditionalAction& action = NoAction(), const ConditionalAction& elseaction = NoAction()) {
return dynamic_cast<EqualCondition&>(addCondition(EqualCondition<T>(0, this, value, action, elseaction)));
}
LessCondition& valueLess(const T& value, const ConditionalAction& action = NoAction(), const ConditionalAction& elseaction = NoAction()) {
return dynamic_cast<LessCondition&>(addCondition(LessCondition<T>(0, this, value, action, elseaction)));
<calendar>
<calendarsection id="terminkalender" start="4/5/2008" end="5/6/2008"/>
<data id="geburtstage" type="iCal" src="geburtstage.ics"/>
<data id="termine" type="CSV" src="termine.csv" format="%s %s"/>
</calendarsection>
<calendarsection id="addressen" pagenumber="6">
<data id="adressen" type="CSV" format="%s %s" src="blub.csv"/>
</calendarsection>
</calendar>
@kirel
kirel / pbwiki.js
Created April 22, 2009 06:28
ubiquity commands
// first beta command
CmdUtils.CreateCommand({
name: "pbwiki",
//icon: "http://example.com/example.png",
//homepage: "http://example.com/",
author: { name: "Daniel Kirsch", email: "[email protected]"},
license: "GPL",
description: "Searches in your pbwiki",
help: "Help! Dunno!",
takes: {"term": noun_arb_text},
class Foo
def foo
puts "parent"
end
end
class Foobar < Foo
def foo
puts "child"
super
command line gist test
@kirel
kirel / canvas.html
Created April 29, 2009 13:14
canvas experiments
<!DOCTYPE html>
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
</head>
<body>
<canvas id="tafel" width="400" height="400" style="border:solid 1px black;">
Hier ist eine Tafel zum drauf malen...
</canvas>
<div id="info"></div>