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 .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 / 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).
@baldowl
baldowl / gallery.rb
Created Apr 13, 2011
Rough gallery plugin for Jekyll
View gallery.rb
@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 / capybara-workaround.rb
Created May 17, 2011
New cucumber-rails: adios Webrat!
View capybara-workaround.rb
require 'capybara/rails'
require 'capybara/cucumber'
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 / gist:1299102
Created Oct 19, 2011
Nginx, try_files and the Accept-Language header
View gist:1299102
location / {
root /my/web/site;
# Note (1) the '/' before $lang and (2) the lack of '/' before $uri (which
# already starts with '/').
try_files /$lang$uri /$lang$uri.html /$lang$uri/ $uri $uri.html $uri/ =404;
}
@baldowl
baldowl / mds_ops.sh
Created Dec 27, 2011
Moving a Time Machine Disk
View mds_ops.sh
# disable indexing on the backup disk
sudo mdutil -i off /Volume/MyBackupDisk
# delete Spotlight's indexes
sudo rm -rf /Volume/MyBackupDisk/.Spotlight-V100
# re-enable indexing
sudo mdutil -i on /Volume/MyBackupDisk
@baldowl
baldowl / gist:1561249
Created Jan 4, 2012
Installing Xcode 4
View gist:1561249
open /Applications/Install\ Xcode.app/Contents/Resources/Xcode.mpkg
@baldowl
baldowl / import.rb
Created Jan 8, 2012 — forked from juniorz/import.rb
Import a blogger archive to jekyll (octopress version)
View import.rb
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
# usage: ruby import.rb my-blog.xml
# my-blog.xml is a file from Settings -> Basic -> Export in blogger.
data = File.read ARGV[0]
You can’t perform that action at this time.