Skip to content

Instantly share code, notes, and snippets.

class Object
def metaclass
class << self; self; end
end
end
class Foo
def self.hello
puts "hello"
end
class Object
# The hidden singleton lurks behind everyone
def metaclass
class << self
self
end
end
def meta_eval &blk
metaclass.instance_eval &blk
klass.send :define_method, "translated_#{attr_name}", lambda {|*loc|
loc = loc.first || I18n.locale
globalize.fetch loc, attr_name
}
klass.send :define_method, "set_translated_#{attr_name}", lambda {|loc, val|
globalize.stash loc, attr_name, val
self[attr_name] = val
}
From c10e9ebe037cd6671cfe250dff9c8289d524bc3a Mon Sep 17 00:00:00 2001
From: hukl <contact@smyck.org>
Date: Mon, 3 Aug 2009 16:54:06 +0200
Subject: [PATCH] helper method to create translation table no considers table_prefixes
---
lib/globalize/model/active_record/translated.rb | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/globalize/model/active_record/translated.rb b/lib/globalize/model/active_record/translated.rb
# put this in RAILS_ROOT/lib
module AccessToken
class << self
def current=(token)
Thread.current[:token] = token
end
def current
#!/bin/sh
#
# PROVIDE: cccms
# REQUIRE: nginx cleanvar
. /etc/rc.subr
name=cccms
rcvar=`set_rcvar`
Output root of a given branch (second commit from the top of the output)
git for-each-ref refs/heads | while read sha rest; do git merge-base $sha <branchname>; done | git log --date-order --no-walk --stdin
ruby-1.8.7-p249 > posts = Post.all
Post Load (0.4ms) SELECT * FROM "posts"
Post::Translation Load (0.4ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 2)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 2)
+----+--------
class CrazyHash < Hash
def initialize init_hash
super.merge! init_hash
end
def to_s
"do something different and important so the literal {} wont work"
end
end
# Install SQLite3 with FTS3
1. cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/databases/sqlite3/
2. vi Portfile
3. add -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS to configure.cppflags