This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
class Object | |
def singleton_class | |
class << self | |
self | |
end | |
end | |
end | |
# X.singleton_class | |
# - > X |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
class Proc | |
def merge_binding!(other_binding) | |
other_binding.eval("local_variables").each do |var| | |
var_id = other_binding.eval(var.to_s).object_id | |
binding.eval("#{var} = ObjectSpace._id2ref(#{var_id})") | |
end | |
end | |
end | |
x = 3 |
The following document is a written account of the Code School screencasting framework. It should be used as a reference of the accompanying screencast on the topic.
You're probably aren't going to take the time to read this document if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.
# coding: utf-8 | |
require 'eventmachine' | |
module EM | |
module Strand | |
extend self | |
# Fires up EventMachine in a fiber, ready to take orders. | |
# | |
# @return EM::Strand |
require 'rack' | |
class Object | |
def to_webapp | |
def self.call(env) | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func || :inspect, *attrs)] | |
end | |
self | |
end |
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
# Rake task for compiling CoffeeScript and SASS (Compass). | |
# | |
# Author: Kim Burgestrand <http://burgestrand.se/> | |
# Date: 6th October 2010 | |
# License: X11 License (MIT License) | |
# URL: http://gist.github.com/gists/613114 | |
desc "Compiles CoffeeScript using Barrista (but only if they changed)" | |
task 'coffee:compile' => :environment do | |
require 'barista' | |
abort "'#{Barista::Compiler.bin_path}' is unavailable." unless Barista::Compiler.available? |
/*! | |
* jQuery TextChange Plugin | |
* http://www.zurb.com/playground/jquery-text-change-custom-event | |
* | |
* Copyright 2010, ZURB | |
* Released under the MIT License | |
*/ | |
(function ($) { | |
$.event.special.textchange = { |