Skip to content

Instantly share code, notes, and snippets.

View usergenic's full-sized avatar
💭
Manifesting dreams! 🦄

Brendan Baldwin usergenic

💭
Manifesting dreams! 🦄
View GitHub Profile
this = Test.new
:omg_ponies
Function.prototype.argumentNames=function(){
return this
.toString()
.replace(/[^(]+\(/,"")
.replace(/\).+/,"")
.match(/[^\n]+/)
.toString()
.split(/, /)
};
/**
* Here's an example of two doctests in comments
*
* # this become doctest title
* say(123);
* # => '123'.
*
* say(456);
* # => '456'.
*
// 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(){
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
# 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
class A
C = 1
def a
class << self
C
end
end
end
class B < A
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
★ 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)
#!/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
#