Skip to content

Instantly share code, notes, and snippets.

Sokolov Yura funny-falcon

Block or report user

Report or block funny-falcon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mhash.h
/*
* Copyright (C) 2011, 2012, 2013, 2014 Mail.RU
* Copyright (C) 2011, 2012, 2013, 2014 Yuriy Vostrikov
* Copyright (C) 2014 Yuriy Sokolov aka funny_falcon
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
View has_many_improved.rb
class ActiveRecord::Associations::AssociationCollection
def has_finder_sql_with_select?
@finder_sql =~ /^\s*select\s/i
end
def find(*args)
options = args.extract_options!
# If using a custom finder_sql, scan the entire collection.
if has_finder_sql_with_select?
@funny-falcon
funny-falcon / dump.sh
Created Oct 20, 2010
dumps remote database
View dump.sh
DB_NAME=local_database
FILE_NAME=dump.sql
REMOTE_DB_NAME=remote_database
REMOTE_HOST=user@host.com
REMOTE_DBUSER=postgres
cat <<EOF > $FILE_NAME
\c postgres
DROP DATABASE $DB_NAME ;
CREATE DATABASE $DB_NAME ;
@funny-falcon
funny-falcon / rbx-1.2.1dev.run-1.webrick.log
Created Dec 22, 2010
simple testing sinatra application
View rbx-1.2.1dev.run-1.webrick.log
BENCH http://localhost:9294/h
** SIEGE 2.69
** Preparing 15 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 1945 hits
Availability: 100.00 %
Elapsed time: 19.99 secs
Data transferred: 0.01 MB
@funny-falcon
funny-falcon / config.ru
Created Mar 2, 2011
testing sinatra application with results for REE 2010.2 and 1.9.2
View config.ru
require File.dirname(__FILE__) + '/sin.rb'
run Sinatra::Application
@funny-falcon
funny-falcon / gist:870609
Created Mar 15, 2011
Monkey patch for speedup date/time parsing
View gist:870609
class Date
module Format
class Bag
A_FIELDS = %w{year mon mday hour min sec sec_fraction offset zone wday}
for fld in A_FIELDS + %w{_comp}
attr_accessor fld.to_sym
end
to_hash = A_FIELDS.map{|fld| "res[:#{fld}] = @#{fld} unless @#{fld}.nil?"}.join("\n")
class_eval <<-"END"
@funny-falcon
funny-falcon / sequel_time_parse.rb
Created Mar 15, 2011
speedup sequel datetime parse
View sequel_time_parse.rb
~/tmp/ruby-sequel$ ruby test_sequel_times.rb
user system total real
base 6.870000 0.200000 7.070000 ( 7.534538)
~/tmp/ruby-sequel$ ruby test_sequel_times.rb home_run
user system total real
home_run 5.350000 0.160000 5.510000 ( 5.856684)
~/tmp/ruby-sequel$ ruby test_sequel_times.rb fix
user system total real
fix 2.490000 0.150000 2.640000 ( 2.807951)
@funny-falcon
funny-falcon / fast_time_parse.rb
Created Mar 17, 2011
Fast parsing of db timestamp (useful for postgresql and sqlite3 adapters with sequel )
View fast_time_parse.rb
class Time
class << self
def relaxed_rfc3339(date)
if /\A\s*
(-?\d+)-(\d\d)-(\d\d)
[T ]
(\d\d):(\d\d):(\d\d)
(?:\.(\d+))?
(Z|[+-]\d\d(?::?\d\d)?)?
\s*\z/ix =~ date
@funny-falcon
funny-falcon / load.c.patch
Created Oct 8, 2011
Patch against ruby-1.9.3-p0 to futher improve load.c
View load.c.patch
diff --git a/load.c b/load.c
index 0ff4b60..019ccb9 100644
--- a/load.c
+++ b/load.c
@@ -18,6 +18,7 @@ VALUE ruby_dln_librefs;
#define IS_DLEXT(e) (strcmp((e), DLEXT) == 0)
#endif
+static int sorted_loaded_features = 1;
@funny-falcon
funny-falcon / mandelbrot.rb
Created Oct 18, 2011
mandelbrot rubinius
View mandelbrot.rb
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
#
# contributed by Karl von Laudermann
# modified by Jeremy Echols
# modified by Detlef Reichl
# modified by Joseph LaFata
# modified by Peter Zotov
# modified by Brian Ford
# modified by Yura Sokolov
You can’t perform that action at this time.