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
import XCTest | |
protocol Matchable : Equatable, Comparable { } | |
class Matcher<T : Matchable> { | |
let subjectWrapper: T[] | |
var subject: T { | |
get { | |
return subjectWrapper[0] |
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
function execute_loop() { | |
var vmfunc, pathtab, path; | |
var pathstart, pathend; | |
if (resumefuncop) { | |
//qlog("### at resume time, storing value " + resumevalue + " at funcop " + resumefuncop.key); | |
store_operand_by_funcop(resumefuncop, resumevalue); | |
resumefuncop = null; | |
resumevalue = 0; | |
} |
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
# This lets you define user roles as methods, | |
# i.e. checking the role of "admin" on a user | |
# will delegate to user.admin? | |
# | |
# This is helpful because in ActiveRecord, boolean | |
# attributes automatically have their query method | |
# defined; a boolean field "admin" will define | |
# the "admin?" method for you. | |
# | |
# If your logic is more complex, you can write your |
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 Book extends ActiveRecordModel { | |
static $belongs_to = array( | |
array('publisher'), | |
array('author', 'readonly' => true, 'select' => 'name', 'conditions' => "name != 'jax'"), | |
array('another', 'class_name' => 'SomeModel') | |
); | |
static $has_many = array( | |
array('revisions'), | |
array('editors', 'through' => 'revisions') |
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 Book < ActiveRecord::Base | |
belongs_to :publisher | |
belongs_to :author, :select => [:id, :name], :conditions => "name != 'jax'" | |
belongs_to :another, :class_name => "SomeModel" | |
has_many :revisions | |
has_many :editors, :through => :revisions | |
has_one :something |
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
[13:20][ian@ian-terrells-macbook-pro:~/src/test/i18ntest]$ ./script/console | |
Loading development environment (Rails 2.3.2) | |
>> o = Order.create | |
=> #<Order id: 1, created_at: "2009-05-25 17:21:00", updated_at: "2009-05-25 17:21:00"> | |
>> t = OtherThing.create | |
=> #<OtherThing id: 1, created_at: "2009-05-25 17:21:05", updated_at: "2009-05-25 17:21:05"> | |
>> o.payments.create | |
=> #<Payment id: 1, payable_id: 1, payable_type: "Order", created_at: "2009-05-25 17:21:11", updated_at: "2009-05-25 17:21:11"> | |
>> o.payments.create | |
=> #<Payment id: 2, payable_id: 1, payable_type: "Order", created_at: "2009-05-25 17:21:13", updated_at: "2009-05-25 17:21:13"> |
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
[14:04][ian@ian-terrells-macbook-pro:~]$ ruby --version | |
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0] | |
[14:04][ian@ian-terrells-macbook-pro:~]$ irb | |
>> class X | |
>> end | |
=> nil | |
>> class Y < X | |
>> end | |
=> nil | |
>> X.subclasses |
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
Loading development environment (Rails 2.3.2) | |
>> class Z < User; end | |
=> nil | |
>> User.subclasses | |
NoMethodError: protected method `subclasses' called for #<Class:0x22ce974> | |
from (irb):2 | |
>> User.send(:subclasses) | |
=> [Z(id: integer, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, activation_code: string, activated_at: datetime, state: string, deleted_at: datetime, editor: boolean, has_promise: boolean, reset_code: string)] | |
>> |
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
PATH=$PATH:/Library/PostgreSQL/9.0/bin/ env ARCHFLAGS="-arch x86_64" gem install pg |
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 'redis' | |
class Redis | |
alias :__flushall :flushall | |
alias :__flushdb :flushdb | |
def flushall(confirm=false) | |
if confirm | |
__flushall | |
else |
OlderNewer