Skip to content

Instantly share code, notes, and snippets.

View biow0lf's full-sized avatar

Igor Zubkov biow0lf

  • 07:53 (UTC +01:00)
View GitHub Profile
@xaviershay
xaviershay / require-performance-fix-r31758.patch
Created May 27, 2011 23:53
Patch to make ruby require much faster than it used to be.
diff --git a/.gitignore b/.gitignore
index 57557c9..7955376 100644
--- a/.gitignore
+++ b/.gitignore
@@ -129,3 +129,4 @@ y.tab.c
# /win32/
/win32/*.ico
+ext/win32ole/.document
diff --git a/array.c b/array.c
require 'benchmark'
class Simple
attr_accessor :next
end
def current_mem
`ps -o "%mem rss" -p #{$$}`.split("\n").last.split(/\s+/)[1..-1]
end
@taf2
taf2 / load.patch
Created June 5, 2011 13:05
Ruby 1.9.2-p180 require performance patch
--- a/load.c 2010-10-23 05:36:38.000000000 -0400
+++ b/patchload.c 2011-06-05 08:58:00.000000000 -0400
@@ -40,14 +40,6 @@
VALUE ary;
long i;
- for (i = 0; i < RARRAY_LEN(load_path); ++i) {
- VALUE str = rb_check_string_type(RARRAY_PTR(load_path)[i]);
- if (NIL_P(str) || !rb_is_absolute_path(RSTRING_PTR(str)))
- goto relative_path_found;
@kreed131
kreed131 / BotvaBot.hs
Created June 17, 2011 15:27
Bot for browser mmorpg botva.ru written in Haskell
{--
kreed131.blogspot.com
--}
import Prelude hiding (catch)
import Data.Char (isDigit)
import Data.Maybe (fromMaybe)
import qualified Data.Map as M (lookup)
import System.IO
import System.Random (randomRIO)
/**
NOTE: The template in this example relies on itemView, which is not yet
in SproutCore 2.0 master, but is coming
*/
MyApp.Selection = SC.Object.extend({
name: null,
isSelected: false
});
require 'date'
require 'benchmark'
puts "patchlevel: #{RUBY_PATCHLEVEL}, release_date: #{RUBY_RELEASE_DATE}, ruby_version: #{RUBY_VERSION}, ruby_platform: #{RUBY_PLATFORM}"
puts '*'*80
Benchmark.bm(10) do |bm|
bm.report("Date.today") do
500_000.times { Date.today }
@aroop
aroop / gist:1132829
Created August 8, 2011 21:37
Stacktrace of the exception
[ pid=18421 thr=70134877964720 file=utils.rb:176 time=2011-06-08 01:21:06.693 ]: *** Exception PGError in application (server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
) (process 18421, thread #<Thread:0x7f9318f99360>):
from /usr/local/rvm/gems/ruby-1.8.7-p334/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:273:in `query'
from /usr/local/rvm/gems/ruby-1.8.7-p334/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:273:in `clear_cache!'
from /usr/local/rvm/gems/ruby-1.8.7-p334/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `each_value'
from /usr/local/rvm/gems/ruby-1.8.7-p334/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `clear_cache!'
from /usr/local/rvm/gems/ruby-1.8.7-p334/gems/activerecord-3.1.0.rc
[ pid=30190 thr=9726520 file=utils.rb:176 time=2011-08-08 17:47:57.433 ]: *** Exception PGError in application (server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
) (process 30190, thread #<Thread:0x0000000128d470>):
from /mnt/nrimovies-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0.rc5/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `exec'
from /mnt/nrimovies-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0.rc5/lib/active_record/connection_adapters/postgresql_adapter.rb:272:in `block in clear_cache!'
from /mnt/nrimovies-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0.rc5/lib/active_record/connection_adapters/postgresql_adapter.rb:271:in `each_value'
from /mnt/nrimovies-production/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0.rc5/lib/active_record/connection_adapters/postgresql_adapter.rb:271:in `clear_cache!'
from /mnt/nrimovies-production/shared/bundle/ruby/1.9
@julik
julik / unfuck_osx_readline_for_ruby.txt
Created August 24, 2011 13:10
Decent Readline support for irb/pry on Leopard and above for decent UTF8 input, with RVM
Ensure that your ~/.inputrc contains this
set convert-meta off
set input-meta on
set output-meta on
Install the REAL GNU readline from source
$ curl ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz | tar xfz - && cd readline-6.2 && ./configure --enable-multibyte && make && sudo make install
@kirs
kirs / gist:1180272
Created August 30, 2011 05:51
NginX config for Rails 3.1 & Unicorn
upstream example_backend {
server unix:/var/www/example.com/shared/unicorn.sock;
}
server {
listen 80;
server_name example.com www.example.com;
access_log off;
error_log off;
client_max_body_size 20M;