Skip to content

Instantly share code, notes, and snippets.

View jasiek's full-sized avatar

Jan Szumiec jasiek

View GitHub Profile
@jasiek
jasiek / trace.log
Created March 11, 2012 23:58
Langusta 0.2.1 profile trace
/home/jps/.rvm/rubies/ruby-1.9.3-p0/bin/ruby -I"lib:test/quality:lib:." -I"/home/jps/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib" "/home/jps/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/quality/test_*.rb"
% cumulative self self total
time seconds seconds calls ms/call ms/call name
55.46 624.54 624.54 40716 15.34 24.98 Array#include?
34.85 1016.96 392.42 43450242 0.01 0.01 Fixnum#==
1.14 1029.76 12.80 393881 0.03 0.05 Range#include?
0.94 1040.34 10.59 11030 0.96 105.86 Integer#times
0.76 1048.85 8.51 348944 0.02 0.07 Range#===
0.70 1056.70 7.85 85317 0.09 0.48 Langusta::NGram#normalize
0.56 1063.02 6.31 86501 0.07 0.35 Langusta::UnicodeBlock.of
@jasiek
jasiek / debase256.rb
Created May 24, 2012 12:48
Convert base-256 byte string to base-10
def debase256(string)
string.reverse.bytes.inject([0, 1]) do |(sum, pow), byte|
[pow * byte.ord, pow * 256]
end.first
end
class Post
include Mongoid::Document
include Mongoid::Timestamps
identity :type => String
field :title, :type => String
field :body, :type => String
end
require 'rubygems'
require 'net/http/persistent'
require 'pp'
require 'set'
$endpoint = URI.parse('http://localhost:7777/')
$tcpserver = TCPServer.new(44231)
candidates = {}
irb(main):002:0> Net::HTTP.get(URI.parse('http://www.google.com'))
IOError: Function not implemented
from org/jruby/ext/socket/RubyTCPSocket.java:110:in `initialize'
from org/jruby/RubyIO.java:1176:in `open'
from /usr/home/jps/.rvm/rubies/jruby-1.7.0/lib/ruby/1.9/net/http.rb:762:in `connect'
from org/jruby/ext/timeout/Timeout.java:105:in `timeout'
from /usr/home/jps/.rvm/rubies/jruby-1.7.0/lib/ruby/1.9/net/http.rb:762:in `connect'
from /usr/home/jps/.rvm/rubies/jruby-1.7.0/lib/ruby/1.9/net/http.rb:755:in `do_start'
from /usr/home/jps/.rvm/rubies/jruby-1.7.0/lib/ruby/1.9/net/http.rb:744:in `start'
from /usr/home/jps/.rvm/rubies/jruby-1.7.0/lib/ruby/1.9/net/http.rb:454:in `get_response'
WARNING: Error fetching data:
IOError: Function not implemented (http://rubygems.org/latest_specs.4.8.gz)
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
IOError: Function not implemented (http://rubygems.org/gems/bundler-1.2.0.gem)
linux: pid 23484 (java): syscall epoll_create not implemented
ruby -J-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -S irb
> java.lang.System.setProperty('java.nio.channels.spi.SelectorProvider','sun.nio.ch.PollSelectorProvider')
@jasiek
jasiek / install-fast-require.sh
Created November 1, 2012 12:05
Installs Ruby 1.9.3-p194 with a patch set for faster require. (http://bugs.ruby-lang.org/issues/7158)
#!/bin/bash
pushd /tmp
COMMITS="8243d294600ca6e635bb617be23f34172e7676ab c23b88eff207744cccc42fa74f991eacdb419957 bf0c8f0fe1643c011fe9fa7dd14faeed604bd797 c7ec412a92e279f7f8d1ae88a2b1673dd64312f6"
PATCHES=""
for f in $COMMITS; do
wget --no-check-certificate https://github.com/gnprice/ruby/commit/$f.patch
PATCHES=$PATCHES,/tmp/$f.patch
done
rvm install -n fast_require 1.9.3-p194 --patch $PATCHES