Skip to content

Instantly share code, notes, and snippets.

View jaredatron's full-sized avatar

Jared Grippe jaredatron

View GitHub Profile
def banner(text_content, &block)
text_content = capture(block) if block_given?
haml_tag :div, {:class => 'banner fontface'} do
haml_tag :span, text_content
haml_tag :div, {:class => 'runner top'}
haml_tag :div, {:class => 'runner bottom'}
end
end
class Puppy < String
def __send__(method, *args, &block)
@called ||= []
@called << method
super
end
attr_reader :called
end
a = Puppy.new('grrrr')
require 'rubygems'
require 'blankslate'
# This wraps and object and controlls all the method calls sent to it
# in Object#__called__
class MethodSendRecorder < BlankSlate
def initialize(host)
@__host__ = host
@__called__ = []
var SomeMixIn = {
reusable: function(){}
}
var SomeOtherMixIn = function(class)){
with(class){
def(function moreAwesome(){
});
};
#!/bin/sh
git init
cat <<EOF > .gitignore
.DS_Store
log/*
log/*.log
tmp/[^.]*
db/*.sqlite3
#!/usr/bin/env ruby
# gets you ncss files 90% the way to sass
ARGV.each do |path|
next unless File.exists?(path)
sass_path = path.sub(/#{File.extname(path)}$/,'.sass')
File.open(sass_path, 'w').write File.open(path).read.
gsub(/([\w-]+):\s+(.*?);/, ':\1 \2'). # flopping the colon
gsub(/[ ]*(\{|\})[ ]*/, ''). # removing any { }
gsub(/(^[ ]+)\./, '\1&.'). # replacing nested .something selectors with &.something
When /^I view the response$/ do
save_and_open_page
end
When /^I puts the response$/ do
puts response.class if defined?(response)
puts response.inspect if defined?(response)
puts response_body.class
puts response_body.public_methods(false).inspect
end
/* Clone With Inheritance
*
* Creates a new object that inherits from the given object so it will reflect any
* future changes to the original object
*/
Object.cloneWithInheritance = function cloneWithInheritance(source){
var sourceClass = function(){};
sourceClass.prototype = source;
return new sourceClass();
};
Class.apply = function apply(klass, a){
return eval(
'new klass('+
a.map(function(v,i){ return 'a['+i+']'; }).join(',')+
')'
);
}
new Array([1,2,4,8]);
// => [[1,2,4,8]]
class Ass
def self.make_a_method(name, *org_args)
class_eval do
def temp_method(*args, &block)
puts args.inspect
puts org_args.inspect
puts block_given?.inspect
puts yield.inspect
end