Skip to content

Instantly share code, notes, and snippets.

View NZKoz's full-sized avatar

Michael Koziarski NZKoz

View GitHub Profile
@NZKoz
NZKoz / A File
Created July 22, 2008 15:51
lulz?
WTFsrsly
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
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
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(-)
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
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)
[
["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
class BuggeredLogger
def initialize
@buffer = []
end
def maybe_flush
flush if @buffer.size > 10
end
require 'thread'
class BuggeredLogger
def initialize
@buffer = []
@mutex = Mutex.new
end
def maybe_flush
flush if @buffer.size > 10
require 'thread'
class BuggeredLogger
def initialize
@buffer = []
@mutex = Mutex.new
end
def maybe_flush
flush if @buffer.size > 10