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
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load --bundler (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/Le/Library/Application Support/TextMate/Bundles/rspec.tmbundle/Support/lib/spec/mate.rb:16
from /tmp/textmate-command-12505.rb:2:in `require'
from /tmp/textmate-command-12505.rb:2

If I run p RUBY_DESCRIPTION from an rb file in textmate I get "ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]"

@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'
require 'spec_helper'
require (File.expand_path("../../../app/helpers/routes_helper",File.dirname(__FILE__)))
describe ApplicationController, "route generation" do
it "should map tasks to /:owner_id/:project/tasks" do
include RoutesHelper
@project = Factory :public_project
tasks_path(@project).should == "/#{@project.owner.to_param}/#{@project.name_url}/tasks"
@ilpoldo
ilpoldo / javascript_minifier.rb
Created March 9, 2010 14:18
metal-based asset packagers
require 'jsmin'
require 'fileutils'
require 'benchmark'
module JavascriptMinifier
class NotFound < StandardError; end
class Responder
@asset_folder = "#{Rails.root}/public/javascripts"
require 'grit'
module ApplicationAssetsHelper
ASSETS_FOLDERS = %w[javascripts stylesheets]
ASSET_FORMATS = {'javascripts' => :js,
'stylesheets' => :css}
#LEDO?: create some sort of compile directives for the asset packager
def self.included(base)
@ilpoldo
ilpoldo / sos.md
Created March 3, 2010 18:14
1 to 1 for app prototype.

1 to 1 for webapp prototype

Hi,

I'm currently developing a webapp prototype for a friend's startup company which is linked to the vfx and indie cinema industry. We feel we need some help to polish up the project, and are looking for a developer experienced with Ruby and Rails, what are considered best practices and BDD; based in London, 2 years experience, to work with me in person during this phase of development. The app is written in rails 2.3.5 and we are testing using rspec and cucumber. In case you are wondering if this job can't be done remotely the answer is 'yes, but...': for us to share code over the wire I'll have to ask for an even stronger commitment to clean coding style and good practices.

Thank you,

Leandro

@ilpoldo
ilpoldo / paperclip.rb
Created February 27, 2010 13:22 — forked from stympy/paperclip.rb
mongomapper paperclip
module Paperclip
module ClassMethods
def has_attached_file name, options = {}
include InstanceMethods
write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
attachment_definitions[name] = {:validations => []}.merge(options)
after_save :save_attached_files
before_destroy :destroy_attached_files
@ilpoldo
ilpoldo / .bashrc
Created February 26, 2010 11:40 — forked from henrik/.bashrc
Prompt when git branch is dirty
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@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))
Given /^"([^\"]*)" task ran$/ do |task_name|
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
task = Rake::Task[task_name]
task.reenable
task.invoke