This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $Id: dns_cache.rb 5040 2007-10-05 17:31:04Z francis $ | |
# | |
# | |
require 'rubygems' | |
require 'eventmachine' | |
require 'resolv' | |
module EventMachine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example for multi-fiber workers | |
require "fiber" | |
require "eventmachine" | |
results = [] | |
work = [:a, :b, :c] | |
EventMachine.run { | |
Fiber.new do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DS_Store | |
*.csv | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Proc | |
def <<(other) | |
case other | |
when Proc | |
Proc.new do |*args| | |
call(other.call(*args)) | |
end | |
else | |
call(other) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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); |
OlderNewer