View has_many_improved.rb
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 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? |
View dump.sh
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
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 ; |
View rbx-1.2.1dev.run-1.webrick.log
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
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 |
View config.ru
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 File.dirname(__FILE__) + '/sin.rb' | |
run Sinatra::Application |
View patch-1.9.2-gc.patch
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
diff --git a/gc.c b/gc.c | |
--- a/gc.c | |
+++ b/gc.c | |
@@ -77,6 +77,41 @@ void *alloca (); | |
#ifndef GC_MALLOC_LIMIT | |
#define GC_MALLOC_LIMIT 8000000 | |
#endif | |
+#define HEAP_MIN_SLOTS 10000 | |
+#define FREE_MIN 4096 | |
+ |
View gist:870609
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 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" |
View sequel_time_parse.rb
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
~/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) |
View fast_time_parse.rb
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 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 |
View load.c.patch
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
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; | |
View mandelbrot.rb
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
# 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 |
OlderNewer