Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'rubygems'
gem 'rack', '=0.9.1'
gem 'thin', '=1.0.0'
require 'sinatra'
get '/' do
content_type 'text/plain'
"Hello, world"
end
@woodie
woodie / Gemfile .rb
Created January 17, 2010 10:44
Mechanize with Hpricot on AppEngine
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
gem "appengine-rack"
gem "appengine-apis"
gem 'hpricot', '0.8.2'
gem 'mechanize', '0.8.5'
@pklaus
pklaus / push-to-mobile.ps1
Created March 4, 2010 18:40
Time-lapse Photography Using Python S60
obexftp.exe -b 00:14:5d:5b:53:fc -B 11 --chdir /E:/Python/ --put ./time_lapse.py
@pklaus
pklaus / form.py
Created March 5, 2010 00:23
Advanced example for an PyS60 application that makes use of appuifw.app.set_tabs().
#!/usr/bin/env python
# -*- encoding: UTF8 -*-
# Advanced example for an PyS60 application that makes use of appuifw.Form().
# originally found on <http://www.mobilenin.com/pys60/info_tabs_forms.htm>
# changed and adopted for the N95 by Philipp Klaus <philipp.l.klaus AT web-dot-de>
# Copyright (c) 2006 Jurgen Scheible
# This script creates a form
@dimus
dimus / Hash.from_xml using Nokogiri
Created March 17, 2010 14:29
Adding Hash.from_xml method using Nokogiri
# USAGE: Hash.from_xml:(YOUR_XML_STRING)
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
return { result.root.name.to_sym => xml_node_to_hash(result.root)}
require 'win32ole'
# Also possible using Daniel Berger's excellent windows-pr gem.
require 'Win32API'
CoInitialize = Win32API.new('ole32', 'CoInitialize', 'P', 'L')
threads = []
3.times do
threads << Thread.new do
begin
#!/usr/bin/env ruby
require 'ftools'
require 'fileutils'
require 'rubygems'
require 'RMagick'
include Magick
require 'open3'
def merge( files = [] )
@dahlia
dahlia / lisp.rb
Created September 2, 2010 07:52
30 minutes Lisp in Ruby
# 30 minutes Lisp in Ruby
# Hong Minhee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
@mislav
mislav / pagination.md
Created October 12, 2010 17:20
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@igrigorik
igrigorik / ruby-1.9-tips.rb
Created February 3, 2011 17:19
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"