Skip to content

Instantly share code, notes, and snippets.

View andreacampi's full-sized avatar

Andrea Campi andreacampi

  • Apple, inc
  • London, UK
View GitHub Profile
require 'find'
namespace :db do
namespace :fixtures do
desc 'Dumps all models into fixtures.'
task :dump => :environment do
models = []
Find.find(RAILS_ROOT + '/app/models') do |path|
unless File.directory?(path) then models << path.match(/(\w+).rb/)[1] end
end
1) che differenza c'è tra un metodo definito con def self.nomemetodo end e def nomemetodo end
2) Se la variabile pippo è un array e gino è il nome di un metodo nella chiamata gino(*pippo) che significato ha l'asterisco?
3) Che fa il method synchronize nella classe Mutex?
# app:sync
# Local and production synchronization
# - require yaml_db plugin
namespace :app
namespace :sync do
task :all => [:files, :db]
task :files do
`rsync -azv user@host:'/apps/myawesomeapp/shared/files/' #{Rails.root + 'files'}`
@andreacampi
andreacampi / resources.html
Created August 26, 2011 05:56
last-page flag
<!-- This won't work, the second grid will be picked up, leaving an unsightly empty column if there isn't enough content -->
<div class="grid article cols-2 page-1">
<div class="container col-1 cols-2" data-sizes="title"></div>
<div class="container col-1 cols-2" data-sizes="author"></div>
<div class="column"></div>
<div class="container col-3 cols-1" data-sizes="thumbnail"></div>
<div class="column col-3"></div>
</div>
<figure>
<div data-sizes="ad-half-600" class="dynamic-ad ad-half-600" height="600"></div>
<div data-sizes="ad-half-500" class="dynamic-ad ad-half-500" height="500"></div>
<div data-sizes="ad-half-400" class="dynamic-ad ad-half-400" height="400"></div>
</figure>
@andreacampi
andreacampi / gist:1222130
Created September 16, 2011 13:27
Quick tip: how to monkey-patch a Merb controller
Merb::BootLoader.after_app_loads do
class Cookbooks
before :authenticate_every, :only => [ :create, :update ]
end
end
@andreacampi
andreacampi / gist:1222137
Created September 16, 2011 13:31
Before
class Cookbooks < Application
before :authenticate_every
# ...
end
Exception c0000005, at 1EEE3416
Access violation: attempting to read memory at address 00000004
Native function stack data: 0,3f49c0,20201,801c6,65637845,6f697470,3063206e,30303030
base="https://raw.github.com/Treesaver/treesaver.walkthrough/master"
mkdir -p public
mkdir -p public/img
for a in 01-down-the-rabbit-hole.html resources.html treesaver-0.9.2.js
do
curl -o public/$a ${base}/$a
done
@andreacampi
andreacampi / gist:1270657
Created October 7, 2011 16:02
walkthrough
$curry-line-height: 22px;
$curry-plain-grid-outer-width: 280px;
$curry-plain-grid-margin: 25px;
$curry-plain-h2-font-size: 32px;
@import "curry/plain";
.controls {
background-color: #222;