This file contains hidden or 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
| 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 |
This file contains hidden or 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 Puppy < String | |
| def __send__(method, *args, &block) | |
| @called ||= [] | |
| @called << method | |
| super | |
| end | |
| attr_reader :called | |
| end | |
| a = Puppy.new('grrrr') |
This file contains hidden or 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 '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__ = [] |
This file contains hidden or 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
| var SomeMixIn = { | |
| reusable: function(){} | |
| } | |
| var SomeOtherMixIn = function(class)){ | |
| with(class){ | |
| def(function moreAwesome(){ | |
| }); | |
| }; |
This file contains hidden or 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
| #!/bin/sh | |
| git init | |
| cat <<EOF > .gitignore | |
| .DS_Store | |
| log/* | |
| log/*.log | |
| tmp/[^.]* | |
| db/*.sqlite3 |
This file contains hidden or 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
| #!/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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| /* 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(); | |
| }; |
This file contains hidden or 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.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]] |
This file contains hidden or 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 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 |