Skip to content

Instantly share code, notes, and snippets.

Emanuele Vicentini baldowl

Block or report user

Report or block baldowl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View strip_exif_tags_filter.rb
# Custom filter to run exiftool to strip images of every Exif tag. exiftool
# must be installed separately on the system; the filter assumes a Unix-like
# environment.
class StripExifTagsFilter < Nanoc3::Filter
identifier :strip_exif_tags
type :binary
def run filename, params = {}
tool_present = system 'which exiftool >/dev/null 2>&1'
if tool_present
@baldowl
baldowl / capybara-workaround.rb
Created May 17, 2011
New cucumber-rails: adios Webrat!
View capybara-workaround.rb
require 'capybara/rails'
require 'capybara/cucumber'
@baldowl
baldowl / classic_app.rb
Created May 6, 2011
Rough, simple Rack::Csrf extension for Sinatra
View classic_app.rb
require 'sinatra'
require 'csrf'
use Rack::Session::Cookie
apply_csrf_protection
# Here follow the route handlers.
@baldowl
baldowl / gallery.rb
Created Apr 13, 2011
Rough gallery plugin for Jekyll
View gallery.rb
@baldowl
baldowl / multipart_upload.rb
Created Feb 18, 2011
Bad script to play with S3's multipart uploads and Fog
View multipart_upload.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'fog'
bucket_name = 'my_bucket'
object_name = 'big.zip'
# Part size must be between 5MB and 5GB.
# (http://docs.amazonwebservices.com/AmazonS3/latest/dev/qfacts.html)
# Let's say we've splitted the original file with split(1).
View .irbrc
require 'rubygems'
require 'irb/completion'
if ENV['RAILS_ENV']
# Redirecting ActiveRecord's messages to stdout. RoR2
require 'logger'
Object.const_set :RAILS_DEFAULT_LOGGER, Logger.new(STDOUT)
elsif Object.const_defined? :RAILS_ENV
# Redirecting ActiveRecord's messages to stdout. RoR3
ActiveRecord::Base.logger = Logger.new STDOUT
@baldowl
baldowl / gist:771629
Created Jan 9, 2011
Using OS X's Directory Service instead of /etc/hosts
View gist:771629
# Adding a host record.
sudo dscl . -create /Hosts/www.example.com ip_address 10.1.2.3
# Removing that same host record.
sudo dscl . -delete /Hosts/www.example.com
@baldowl
baldowl / rack-test-default-host.rb
Created Dec 6, 2010
Coercing Cucumber And Webrat To Cooperate
View rack-test-default-host.rb
Scenario: Deleting a user
When I go to the users page
And follow "Delete" for the 2nd user
Then I should be on the users page
And should not see "user2"
@baldowl
baldowl / before_migrate.rb
Created Nov 8, 2010
Using Chef and Bundler Together
View before_migrate.rb
# Drop it in config/deploy/
#
# It's evaluated inside the deploy resource's context.
#
# It assumes Gemfile and Gemfile.lock are present and satisfy Bundler's
# requirements for the --deployment option.
current_release_directory = release_path
running_deploy_user = new_resource.user
bundler_depot = new_resource.shared_path + '/bundle'
@baldowl
baldowl / Pinging Google with a POST request
Created Sep 17, 2010
Pinging Google With A Service Hook
View Pinging Google with a POST request
curl -d "payload=testinggithubservicehooks" \
http://www.google.com/webmasters/tools/ping?sitemap=http%3A%2F%2Fwww.example.com%2Fsitemap.xml
You can’t perform that action at this time.