Skip to content

Instantly share code, notes, and snippets.

@baldowl
baldowl / multipart_upload.rb
Created February 18, 2011 07:21
Bad script to play with S3's multipart uploads and Fog
#!/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 April 13, 2011 09:19
Rough gallery plugin for Jekyll
@baldowl
baldowl / classic_app.rb
Created May 6, 2011 06:49
Rough, simple Rack::Csrf extension for Sinatra
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 18:03
New cucumber-rails: adios Webrat!
require 'capybara/rails'
require 'capybara/cucumber'
@baldowl
baldowl / strip_exif_tags_filter.rb
Created July 24, 2011 17:00
Stripping Exif Tags
# 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 October 19, 2011 17:51
Nginx, try_files and the Accept-Language header
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 / gist:1561249
Created January 4, 2012 18:07
Installing Xcode 4
open /Applications/Install\ Xcode.app/Contents/Resources/Xcode.mpkg
@baldowl
baldowl / gist:1772132
Created February 8, 2012 18:50
Deleting EBS Snapshots with aws-sdk
require 'rubygems'
require 'active_support/time'
require 'aws-sdk'
threshold = 2.months.ago
ec2 = AWS::EC2.new
ec2.shapshots.with_owner(:self).
select {|s| s.volume_id == 'vol-12345678' && s.start_time < threshold}.
each {|s| puts "Bye-bye #{s.description}"; s.delete}
@baldowl
baldowl / gist:2900406
Created June 9, 2012 10:04
My First Standalone ATmega328p
# Clone of "Arduino UNO", without bootloader
unowithoutbl.name=Arduino Uno (w/o bootloader)
unowithoutbl.upload.maximum_size=32768
unowithoutbl.bootloader.low_fuses=0xff
unowithoutbl.bootloader.high_fuses=0xdf
unowithoutbl.bootloader.extended_fuses=0x05
unowithoutbl.bootloader.unlock_bits=0x3F
unowithoutbl.bootloader.lock_bits=0x0F
unowithoutbl.build.mcu=atmega328p
unowithoutbl.build.f_cpu=16000000L
@baldowl
baldowl / Content of an ATmega1284P
Created October 27, 2012 15:45
Bigger AVR MCU: ATmega1284P
Atmega chip detector.
Entered programming mode OK.
Signature = 1E 97 05
Processor = ATmega1284P
Flash memory size = 131072
LFuse = 62
HFuse = 99
EFuse = FF
Lock byte = FF
Clock calibration = 81