Skip to content

Instantly share code, notes, and snippets.

View leomayleomay's full-sized avatar

Hao Liu leomayleomay

View GitHub Profile
class Foo
def foo
h1 # this is allowed
end
def self.bar
h1 # this is not allowed
end
private
class A
a = 1
end
how could I get the value of a outside of class A?
A.send(:local_variables)
=> ["_"]
there's no local variables named a in the class A.
$ nanite-agent --token bob
[Sat, 31 Oct 2009 20:39:58 +0800] INFO: [setup] setting log level to INFO
[Sat, 31 Oct 2009 20:39:58 +0800] INFO: [setup] setting log level to INFO
[Sat, 31 Oct 2009 20:39:58 +0800] INFO: [setup] loading /Users/hliu/Sandbox/nanite/examples/simpleagent/actors/simple.rb
[Sat, 31 Oct 2009 20:39:58 +0800] INFO: [actor] Simple
[Sat, 31 Oct 2009 20:39:58 +0800] INFO: SEND [register] bob, services: /simple/echo, /simple/time, /simple/gems, /simple/yielding, /simple/delayed, tags:
[Sat, 31 Oct 2009 20:40:13 +0800] INFO: RECV [advertise]
[Sat, 31 Oct 2009 20:40:13 +0800] INFO: SEND [register] bob, services: /simple/echo, /simple/time, /simple/gems, /simple/yielding, /simple/delayed, tags:
[Sat, 31 Oct 2009 20:40:27 +0800] INFO: RECV [request] <a73fc2ba6daaf3d3545d081346907e24> /simple/echo from mapper
$ ./cli.rb
[Sat, 31 Oct 2009 20:40:11 +0800] INFO: [setup] setting log level to INFO
[Sat, 31 Oct 2009 20:40:11 +0800] INFO: [setup] setting log level to INFO
[Sat, 31 Oct 2009 20:40:11 +0800] INFO: [setup] starting mapper
[Sat, 31 Oct 2009 20:40:13 +0800] INFO: SEND [advertise] to nanite-bob
[Sat, 31 Oct 2009 20:40:13 +0800] INFO: RECV [register] bob, services: /simple/echo, /simple/time, /simple/gems, /simple/yielding, /simple/delayed, tags:
[Sat, 31 Oct 2009 20:40:27 +0800] INFO: SEND [request] <a73fc2ba6daaf3d3545d081346907e24> /simple/echo from mapper to bob
[Sat, 31 Oct 2009 20:40:41 +0800] INFO: Nanite nanite-bob timed out
system '/usr/bin/scp hekin@remote_machine:/home/hekin/test .'
author.posts.find(:last, :conditions => ["tag = ?", 'Ruby'], :order => "updated_at ASC")
function isNumeric(val) {
return !isNaN(val.split(",").join(""));
}
function isCurrency(val, options) {
var val = val.replace(/^\$?/, '');
return isNumeric(val);
}
An error has occurred, all later migrations canceled:
undefined method `set_price' for #<Order:0xc943728>
$ diff debugger console
1a2,7
> AASM::Persistence::ActiveRecordPersistence::WriteStateWithoutPersistence
> AASM::Persistence::ActiveRecordPersistence::WriteState
> AASM::Persistence::ActiveRecordPersistence::ReadState
> AASM::Persistence::ActiveRecordPersistence::InstanceMethods
> AASM::Persistence::ActiveRecordPersistence
> AASM
30d35
< Delayed::MessageSending
Say I have a Person model,
app/models/person.rb
class Person < ActiveRecord::Base
validates_uniquess_of :name
end
db/migrate/2010009912_add_index_to_people.rb