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
WTFsrsly |
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
def subclasses_of(*superclasses) #:nodoc: | |
subclasses = [] | |
superclasses.each do |sup| | |
ObjectSpace.each_object(class << sup; self; end) do |k| | |
if k != sup && (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id")) | |
subclasses << k | |
end | |
end | |
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 'pp' | |
class Time | |
class << self | |
alias_method :_original_load, :_load | |
def _load(marshaled_time) | |
time = _original_load(marshaled_time) | |
# utc = time.send(:remove_instance_variable, '@marshal_with_utc_coercion') | |
time | |
# utc ? time.utc : time | |
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
From 233020a2d01e9c4f0bfdd54657062312d2039a57 Mon Sep 17 00:00:00 2001 | |
From: Michael Koziarski <[email protected]> | |
Date: Thu, 11 Sep 2008 16:03:38 +0200 | |
Subject: [PATCH] Flesh out the parameterize method to support non-ascii text and underscores. | |
--- | |
activesupport/lib/active_support/inflector.rb | 2 +- | |
activesupport/test/inflector_test_cases.rb | 5 ++++- | |
2 files changed, 5 insertions(+), 2 deletions(-) | |
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
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -I/opt/local/include/pgsql8 -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -c compat.c | |
In file included from compat.c:16: | |
compat.h:38:2: error: #error PostgreSQL client version too old, requires 7.3 or later. | |
In file included from compat.c:16: | |
compat.h:121: error: redefinition of typedef ‘PQnoticeReceiver’ | |
/opt/local/include/pgsql8/libpq-fe.h:141: error: previous declaration of ‘PQnoticeReceiver’ was here | |
compat.h:125: error: redeclaration of enumerator ‘PQERRORS_TERSE’ | |
/opt/local/include/pgsql8/libpq-fe.h:102: error: previous definition of ‘PQERRORS_TERSE’ was here | |
compat.h:126: error: redeclaration of enumerator ‘PQERRORS_DEFAULT’ | |
/opt/local/include/pgsql8/libpq-fe.h:103: error: previous definition of ‘PQERRORS_DEFAULT’ was here |
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
begin | |
require_library_or_gem 'pg' | |
rescue LoadError => e | |
begin | |
require_library_or_gem 'postgres' | |
class PGresult | |
alias_method :nfields, :num_fields unless self.method_defined?(:nfields) | |
alias_method :ntuples, :num_tuples unless self.method_defined?(:ntuples) | |
alias_method :ftype, :type unless self.method_defined?(:ftype) | |
alias_method :cmd_tuples, :cmdtuples unless self.method_defined?(:cmd_tuples) |
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
[ | |
["a", "fr-FR", "xxx"], | |
["b", "fr-FR", "yyy"], | |
["c", "fr-FR", "zzz"], | |
["a", "en-US", "aaa"], | |
["b", "en-US", "bbb"], | |
["c", "en-US", "ccc"] | |
].each do |row| | |
Category.create! :code=>row.first, :language=>row.second, :name=>row.third |
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 BuggeredLogger | |
def initialize | |
@buffer = [] | |
end | |
def maybe_flush | |
flush if @buffer.size > 10 | |
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 'thread' | |
class BuggeredLogger | |
def initialize | |
@buffer = [] | |
@mutex = Mutex.new | |
end | |
def maybe_flush | |
flush if @buffer.size > 10 |
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 'thread' | |
class BuggeredLogger | |
def initialize | |
@buffer = [] | |
@mutex = Mutex.new | |
end | |
def maybe_flush | |
flush if @buffer.size > 10 |
OlderNewer