Skip to content

Instantly share code, notes, and snippets.

View ilpoldo's full-sized avatar

Leandro Pedroni ilpoldo

  • Double Negative
  • London, UK
View GitHub Profile
@ilpoldo
ilpoldo / image.rb
Created February 24, 2010 18:37 — forked from bhauman/image.rb
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))
@defunkt
defunkt / browser
Created March 1, 2010 10:01
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
@r3ap3r2004
r3ap3r2004 / thubmnail_with_dimensions.rb
Created March 25, 2010 15:37
Paperclip processor to save dimensions of an image
# Filename: RAILS_ROOT/lib/paperclip_processors/thumbnail_with_dimensions.rb
# Required Configuration in the model
# has_attached_file :image,
# :styles => {
# :thumbnail => {
# :geometry => "100x100>",
# :format => :png,
# :processors => [:thumbnail_with_dimensions],
# :mystyle => :thumbnail
# },
@saimonmoore
saimonmoore / Gemfile
Created March 26, 2010 12:12 — forked from lifo/Gemfile
CRAMP Websocket example
gem 'cramp'
gem 'erubis', '2.6.5'
gem 'usher', "0.6.0"
Rails.configuration.middleware.use Rack::OpenID
Rails.configuration.middleware.use RailsWarden::Manager do |manager|
manager.default_strategies :remember_me_token, :password_form, :api_token, :openid
manager.failure_app = ExceptionsController
end
# Setup Session Serialization
class Warden::SessionSerializer
def serialize(record)
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
Package: require('node-asset').Package
# Coffee files
coffee_package: new Package 'where/you/want/output.js', [
'where/is/coffee/dir'
'or/file.coffee'
'coffee/type/also/support/file.js'
], {
type: 'coffee'
# Watch for changes
@paulelliott
paulelliott / integration_example_group.rb
Created July 7, 2010 03:32
RSpec Integration Example Group for Capybara
require 'action_dispatch'
require 'capybara/rails'
require 'capybara/dsl'
module RSpec::Rails
module IntegrationExampleGroup
extend ActiveSupport::Concern
include ActionDispatch::Integration::Runner
include RSpec::Rails::TestUnitAssertionAdapter
@nruth
nruth / cookie_steps.rb
Created July 21, 2010 17:16
Testing login "remember me" feature with Capybara (rack::test or selenium) - deleting the session cookie (only)
@ilpoldo
ilpoldo / templator.rb
Created September 2, 2010 14:30
My rails 3 app template
# Cleaning up and extending the Gemfile
remove_file 'Gemfile'
create_file 'Gemfile', <<-GEMFILE
source 'http://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'