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
# 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? |
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
# coding: utf-8 | |
require 'eventmachine' | |
module EM | |
module Strand | |
extend self | |
# Fires up EventMachine in a fiber, ready to take orders. | |
# | |
# @return EM::Strand |
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 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 |
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 Object | |
def singleton_class | |
class << self | |
self | |
end | |
end | |
end | |
# X.singleton_class | |
# - > X |
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
require 'ostruct' | |
require 'delegate' | |
module Hallon | |
class Enumerator < SimpleDelegator | |
attr_reader :size | |
def initialize(size, pointer, &block) | |
@pointer = pointer | |
@items = Array(0...size) |
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 Proc | |
alias :/ :call | |
end | |
def s | |
optmap = { | |
"x" => Regexp::EXTENDED, | |
"i" => Regexp::IGNORECASE, | |
"m" => Regexp::MULTILINE | |
} |
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
# Eval a string of code, returning a hash of all local variables and their values. | |
# | |
# @param [String] code | |
# @param [Binding] binding | |
# @param [String] file (shows up in backtrace if an error occurs) | |
# @param [Integer] line (shows up in backtrace if an error occurs) | |
# @return [Hash] a map of :local_var => value_of_that_var | |
def eval!(__code__, binding = nil, file = __FILE__, line = (__LINE__ + 1)) | |
eval <<-SOURCE, binding, file, line | |
#{__code__} |
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
module Instruments | |
def self.set_logger(l, m) | |
@logger = l | |
@method = m | |
end | |
def self.logger | |
@logger | |
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
# coding: utf-8 | |
class Whitespace | |
def initialize(&block) | |
@data = 0 | |
@pos = -1 | |
instance_eval(&block) | |
end | |
def | |
tap { @pos += 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
// Original - @Gozola. This is a reimplemented version (with a few bug fixes). | |
window.WeakMap = window.WeakMap || (function () { | |
var privates = Name() | |
return { | |
get: function (key, fallback) { | |
var store = privates(key) | |
return store.hasOwnProperty("value") ? | |
store.value : fallback | |
}, |
OlderNewer