Skip to content

Instantly share code, notes, and snippets.

View igrigorik's full-sized avatar
:octocat:

Ilya Grigorik igrigorik

:octocat:
View GitHub Profile
# $Id: dns_cache.rb 5040 2007-10-05 17:31:04Z francis $
#
#
require 'rubygems'
require 'eventmachine'
require 'resolv'
module EventMachine
# example for multi-fiber workers
require "fiber"
require "eventmachine"
results = []
work = [:a, :b, :c]
EventMachine.run {
Fiber.new do
require 'rubygems'
require 'neo4j'
include Neo4j
Transaction.new
# create some people
andreas = Node.new :name => 'andreas'
peter = Node.new :name => 'peter'
kalle = Node.new :name => 'kalle'
@karmi
karmi / .gitignore
Created May 19, 2010 05:33
Script to generate PDF cards suitable for planning poker from Pivotal Tracker [http://www.pivotaltracker.com/] CSV export. Inspired by Bryan Helmkamp's http://github.com/brynary/features2cards/
.DS_Store
*.csv
*.pdf
anonymous
anonymous / tail-recursive.rb
Created July 9, 2010 23:49
notes on Ruby Tail Call Optimization
# First, I suppose you have ruby 1.9.1 or 1.9.2
# Open irb. Execute this:
# RubyVM::InstructionSequence.compile_option = { tailcall_optimization: true, trace_instruction: false }
# Note, RubyVM::InstructionSequence.compile_option() doesn't have item :trace_instruction, still, you need to specify it. WTF?
# Also, it doesn't work if you just put it to the script. Don't know why yet. Tell me (@rofh) if you know.
# Then open the file:
# require "./tail-recursive"
# Then execute function:
# fact(30000)
require "date"
require "time"
# converts base10 integers into NewBase60
def num_to_sxg(num=nil)
sxg = ""
vocabulary = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz"
return 0 if num.nil? || num.zero?
anonymous
anonymous / parse_delicious_xml.py
Created August 28, 2010 04:43
#!/usr/bin/env python
# encoding: utf-8
"""
parse_delicious_xml.py
First download your bookmarks and restrict to specific tags if desired:
$ curl --user 'username':'password' -o delicious.xml 'https://api.del.icio.us/v1/posts/all'
Extract and count most common domains:
class Proc
def <<(other)
case other
when Proc
Proc.new do |*args|
call(other.call(*args))
end
else
call(other)
end
require 'java'
begin
require 'jar/netty-3.2.2.Final'
rescue LoadError
require 'fileutils'
FileUtils.mkdir_p 'jar'
system "wget -O jar/netty-3.2.2.Final.jar http://repository.jboss.org/nexus/content/groups/public-jboss/org/jboss/netty/netty/3.2.2.Final/netty-3.2.2.Final.jar"
require 'jar/netty-3.2.2.Final'
end
@tmm1
tmm1 / gist:630606
Created October 17, 2010 06:42
changes made to mongrel ragel parser in Thin
--- mongrel/ext/http11/http11_parser_common.rl 2010-10-13 01:08:57.000000000 -0700
+++ thin/ext/thin_parser/common.rl 2010-06-18 18:36:01.000000000 -0700
@@ -11,11 +11,12 @@
safe = ("$" | "-" | "_" | ".");
extra = ("!" | "*" | "'" | "(" | ")" | ",");
reserved = (";" | "/" | "?" | ":" | "@" | "&" | "=" | "+");
- unsafe = (CTL | " " | "\"" | "#" | "%" | "<" | ">");
+ sorta_safe = ("\"" | "<" | ">");
+ unsafe = (CTL | " " | "#" | "%" | sorta_safe);
national = any -- (alpha | digit | reserved | extra | safe | unsafe);