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
!!! | |
%html | |
%head | |
%style(type="text/css") | |
:plain | |
body { | |
color: blue; | |
background: yellow; | |
} | |
%body |
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
# the more proper miniskirt who doesn't have to walk the rails | |
class Minidress | |
@@factories = {} | |
class << self | |
def define(name, &block) | |
@@factories[name.to_s] = block | |
end | |
def build(name, attrs = {}) |
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
Debugger entered--Lisp error: (error "Command attempted to use minibuffer while in minibuffer") | |
execute-extended-command(nil) | |
call-interactively(execute-extended-command nil nil) |
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 Image < ActiveRecord::Base | |
before_create, :set_width_and_height | |
has_attached_file :img, | |
:url => "/system/images/:attachment/:id/:basename.:extension", | |
:path => "#{Rails.root}/public/system/images/:attachment/:id/:basename.:extension" | |
def set_width_and_height | |
# this next line is the magic line | |
geo = Paperclip::Geometry.from_file(img.to_file(:original)) |
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
Factory.define :business_user, :parent => :user do |i| | |
def i.build_some_outlets | |
(1..5).collect {|x| Factory.build(:outlet_without_user) } | |
end | |
i.outlets { i.build_some_outlets } | |
i.sequence(:name) {|n| "Business User #{n}" } | |
i.is_business true | |
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
// Simple JavaScript Templating | |
// John Resig - http://ejohn.org/ - MIT Licensed | |
(function(){ | |
var cache = {}; | |
this.tmpl = function tmpl(str, data){ | |
// Figure out if we're getting a template, or if we need to | |
// load the template - and be sure to cache the result. | |
var fn = !/\W/.test(str) ? | |
cache[str] = cache[str] || |
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
// This is a port of the prototype.js PeriodcialExecuter | |
// This should be framework independent | |
// Valuable if you like to/have to program in jQuery | |
function PeriodicalExecuter(callback, frequency) { | |
this.callback = callback; | |
this.frequency = frequency; | |
this.currentlyExecuting = false; | |
this.registerCallback(); | |
} |
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 'amqp' | |
require 'mq' | |
AMQP.start(:host => 'localhost' ) do | |
q = MQ.new.queue('tasks') | |
q.subscribe do |msg| | |
puts msg | |
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
require 'rubygems' | |
require 'carrot' | |
q = Carrot.queue('tasks') | |
10.times {|x| q.publish('Message number ' + x.to_s) } | |
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
width = 200 | |
height = 200 | |
mag = MiniMagick::Image.from_file( file_path ) | |
mag.combine_options do |i| | |
i.resize "#{width}x#{height}^" | |
i.gravity 'Center' | |
i.extent "#{width}x#{height}" | |
end |