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 = Test.new | |
:omg_ponies |
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.prototype.argumentNames=function(){ | |
return this | |
.toString() | |
.replace(/[^(]+\(/,"") | |
.replace(/\).+/,"") | |
.match(/[^\n]+/) | |
.toString() | |
.split(/, /) | |
}; |
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
/** | |
* Here's an example of two doctests in comments | |
* | |
* # this become doctest title | |
* say(123); | |
* # => '123'. | |
* | |
* say(456); | |
* # => '456'. | |
* |
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
// We can't use super because it's apparently reserved in some JS implementations. | |
var superf = function(){}; | |
function overload(object, methodName, callback){ | |
var superMethod = object[methodName]; | |
object[methodName] = function(){ | |
var _superf = superf; | |
var me = this; | |
superf = function(){ |
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
SimpleConfig.class_eval do | |
def method_missing_with_rails_env(m,*a,&b) | |
method_missing_without_rails_env(m,*a,&b) | |
rescue NoMethodError => e | |
if has_key?(RAILS_ENV) | |
env = self[RAILS_ENV] | |
return env[m] if env.has_key?(m) | |
end | |
raise e | |
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
# Run this as a script and then paste into IRB | |
# for a little surprise. | |
c1 = Class.new | |
c2 = Class.new | |
puts "c1.name == #{c1.name}" | |
puts "c2.name == #{c2.name}" | |
A1 = c1 |
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 A | |
C = 1 | |
def a | |
class << self | |
C | |
end | |
end | |
end | |
class B < A |
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
Cucumber::Ast::Scenario.class_eval do | |
def accept_with_transactions(visitor) | |
repository.transaction.commit do |t| | |
accept_without_transactions(visitor) | |
t.rollback | |
end | |
end | |
alias_method :accept_without_transactions, :accept |
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
★ rvm use 1.9.1 | |
Now using ruby 1.9.1 p376 | |
★ irb | |
irb(main):001:0> def a(x,y) x.send(y) end; puts RubyVM::InstructionSequence.disasm(method(:a)) | |
== disasm: <RubyVM::InstructionSequence:a@(irb)>======================== | |
local table (size: 3, argc: 2 [opts: 0, rest: -1, post: 0, block: -1] s1) | |
[ 3] x<Arg> [ 2] y<Arg> | |
0000 trace 8 ( 1) |
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
#!/bin/bash | |
# This script deals with the weirdness of how googlecl downloads txt format documents from | |
# google. Theres some weird header bytes on the file it gets and my emacs has no idea how | |
# to preserve the newline form, so we transform before sending to emacs. Your mileage may vary. | |
# | |
# You can invoke this script like this: | |
# | |
# $ google docs edit --editor google-edit --format txt --title yourtitlehere | |
# |
OlderNewer