Skip to content

Instantly share code, notes, and snippets.

View toto's full-sized avatar

Thomas Kollbach toto

View GitHub Profile
@toto
toto / makes_levenshtein gem_ruby_1.9_compatible.diff
Created March 23, 2009 16:08
Patch to make the levenshtein gem ruby 1.9 compatible
3,9d2
< /* Ruby 1.8 compatibility macros, these are defined in Ruby 1.9
< so the ones below will only be used in 1.8.x */
< #ifndef RSTRING_PTR
< # define RSTRING_PTR(s) (RSTRING(s)->ptr)
< # define RSTRING_LEN(s) (RSTRING(s)->len)
< #endif
<
22,23c15,16
< s1 = RSTRING_PTR(rb_s1);
@toto
toto / bridge-reset.sh
Created June 19, 2009 13:23
OpenVPN gets you out of your HTTP-Proxy misery (With some OpenSolaris specific details)
#!/bin/sh
# For OpenSolaris
# The Bridge module from http://www.whiteboard.ne.jp/~admin2/tuntap/
# brings a brdgadm tool
# Removing
# $1 is the interface which will be brought up
pfexec /usr/local/bin/brdgadm -d $1
# the Network card name your system uses to connect to your local network
pfexec /usr/local/bin/brdgadm -d rge0
pfexec /usr/local/bin/brdgadm -a $1
@toto
toto / heise-feed.rb
Created June 22, 2009 19:50
Produces Fulltext Feeds for Heise Online
#!/opt/local/bin/ruby
require 'rubygems'
require 'scrubyt'
require 'open-uri'
require 'builder'
LIMIT = 5
res = []
#!/usr/bin/env ruby
# Uses some commands to determine the OpenSolaris system state and
require 'rubygems'
gem 'twitter'
require 'twitter'
ME_ON_TWITTER = 'mrtoto'
httpauth = Twitter::HTTPAuth.new('email', 'password')
$twitter = Twitter::Base.new(httpauth)
@toto
toto / jabber-messanger-for-ci-joe.rb
Created August 17, 2009 18:20
A simple jabber bot that tells you how a build went and some basic meta info
#!/usr/bin/env ruby
#
require 'rubygems'
gem 'xmpp4r-simple'
gem 'grit'
require 'xmpp4r-simple'
require 'grit'
include Grit
toto@glow:~$ /usr/bin/rsync --version
rsync version 2.6.9 protocol version 29
Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.
<http://rsync.samba.org/>
Capabilities: 64-bit files, socketpairs, hard links, symlinks, batchfiles,
inplace, IPv6, 64-bit system inums, 64-bit internal inums
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
@toto
toto / timeout_http_in_jruby.rb
Created September 16, 2009 15:16
Net/HTTP has some serious bugs regarding timeout in JRuby. Therefor it is useful to just use the Java classes to get a reliable timeout
require 'java'
import java.net
import java.io
uri = java.net.URL.new("http://127.0.0.1")
con = uri.openConnection()
con.setConnectTimeout(1000) # in millisecs so this is 1 sec
con.setReadTimeout(1000)
DEFAULT_OPTIONS.keys.each do |key|
define_method key do
return options[key.to_sym] unless options.nil?
end
define_method "#{key}=".to_sym do |value|
returning(options || {}) do |opt|
options[key.to_sym] = value
end
end
@toto
toto / sphinx-smf.xml
Created March 18, 2010 13:18
SMF Manifest for Sphinx on OpenSolaris
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="sphinx">
<service name="network/sphinx" type="service" version="0">
<dependency name="fs" grouping="require_all" restart_on="none" type="service">
<service_fmri value="svc:/system/filesystem/local"/>
</dependency>
<dependency name="net" grouping="require_all" restart_on="none" type="service">
<service_fmri value="svc:/network/loopback"/>
</dependency>
/*
Some sample code for a horizontal paged UIScrollView with a gap between each image (which looks nicer). Note - not using contentInset, we want each page to fill the iPhone screen and the gap only to be visible when scrolling (like Photos.app).
Taking the iPhone status bar into account - our viewport is 320x460
Our UIScrollView is therefore set in Interface Builder to 340x460 with a -10 X offset (so it's larger than the viewport but still centred)
Then we do the following...
*/
// Our image filenames