Skip to content

Instantly share code, notes, and snippets.

View banister's full-sized avatar
🇳🇱

John Mair banister

🇳🇱
View GitHub Profile
class Blah
def add(x, y)
x + y
end
end
# => nil
class Symbol
def call(*args, &block)
->(o) { o.send(self, *args, &block) }
end
### Keybase proof
I hereby claim:
* I am banister on github.
* I am banisterfiend (https://keybase.io/banisterfiend) on keybase.
* I have a public key whose fingerprint is 4DE2 CE74 F739 8BE1 F95A 1CD2 D551 92EA 0E1F 312C
To claim this, I am signing this object:
class UserCreator
def initialize(listener)
@listener = listener
end
def create(attributes)
user = User.new(attributes)
if user.save
# send email
class Proc
def |(other)
->(*args) { self.(*args) || other.(*args) };
end
def &(other)
->(*args) { self.(*args) && other.(*args) }
end
end
[1] pry(main)> def returns(type)
[1] pry(main)* ->(method_name) {
[1] pry(main)* old_method = instance_method(method_name)
[1] pry(main)* define_method(method_name) do |*args, &block|
[1] pry(main)* return_value = old_method.bind(self).call(*args, &block)
[1] pry(main)* unless return_value.class <= type
[1] pry(main)* raise TypeError, "Return value is not of type #{type}!"
[1] pry(main)* end
[1] pry(main)* return_value
[1] pry(main)* end
require 'deferrable_gratification'
class Promise
def initialize
@df = EM::DefaultDeferrable.new
DG.enhance! EM::DefaultDeferrable
end
def done(&block)
tap { @df.callback(&block) }
class CircuitsController < ApplicationController
layout 'circuit_landing_page'
skip_before_filter :authenticate_user!
before_filter :set_programs, only: :show
respond_to :html
CIRCUIT_PROGRAM_IDS = {
'web-design-circuit' => 3689,
'data-analysis-circuit' => 4105
}
static int
include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super)
{
VALUE p, iclass;
int method_changed = 0, constant_changed = 0;
const st_table *const klass_m_tbl = RCLASS_M_TBL(RCLASS_ORIGIN(klass));
while (module) {
int superclass_seen = FALSE;
def check_bounds
if @y > Common::SCREEN_Y*3 || @y < -Common::SCREEN_Y || @x >Common::SCREEN_ X*3 || @x < -Common::SCREEN_X then
@expired = true
end
end
this error:
require 'rubygems'
require 'object2module'
class Object
include Object2module
def gen_extend(*objs)
objs.each_with_index { |v, i|
if !v.instance_of?(Module) then