Skip to content

Instantly share code, notes, and snippets.

perl -e '@_=(shift,pop);$*={ord"<"=>[sub{printf"%s",shift;join$&,
@ARGV[$.,$|]}]};$\=(($,)=$"=~?( )?)&&qq; $_[$#_]\n;;print+chop$,,
$*->{$=}->[$[]->($_)foreach($_[$|++]);' Just another Perl hacker,
@bclennox
bclennox / ext-all-sandbox-4.2.js
Last active December 28, 2015 22:09
Example of an Ext4_2 sandbox
(function(Ext){
// contents of ext-all.js
})(this.Ext4_2 || (this.Ext4_2 = {}));
@bclennox
bclennox / errors_controller.rb
Last active December 19, 2015 10:09
Generate static error pages from normal Rails templates.
class ErrorsController < ApplicationController
layout 'errors'
caches_page :show
def show
render action: params[:id]
end
end
@bclennox
bclennox / article.rb
Created January 26, 2012 18:31
Rails 3.1.* bug
class Article < ActiveRecord::Base
has_many :comments
end
@bclennox
bclennox / Text•UnComment Selection.scpt
Created September 13, 2011 18:34
BBEdit Menu Script to act like TextMate's commenter
on menuselect(menuName, itemName)
tell application "BBEdit"
if (length of (selection of text window 1) > 0) then
return false
else
set documentMode to source language of text document 1
if (documentMode is "Ruby" or documentMode is "Unix Shell Script") then
set commentDelimiter to "# "
else
set commentDelimiter to "// "
// set the parent container's height to the height of its tallest child
var $container = $("...");
var max_height = 0;
$container.children("section").each(function (){
max_height = Math.max(max_height, $(this).height());
});
$container.height(max_height);
# app/models/address.rb
class Address < ActiveRecord::Base
end
# app/models/event.rb
class Event < ActiveRecord::Base
belongs_to :address
end
describe ChildrenController
belongs_to :parent
describe "GET :index" do
before(:each) do
@children = stub_index(Child)
end
it_should_find_and_assign :children
it_should_render_template "index"
describe ChildrenController do
before(:each) do
@parent = mock(Parent, :id => 1)
@children = mock("children")
@parent.stub!(:children).and_return(@children)
Parent.should_receive(:find).with(@parent.id.to_s).and_return(@parent)
end
def expect_children_build
@children.should_receive(:build).with(any_args()).and_return(@child)