Skip to content

Instantly share code, notes, and snippets.

@bds
bds / gist:6855724
Created October 6, 2013 16:01
Send a directory of CSV's through through an Awk script
$ for file in ./data/iraq_unrest_0*.csv; do awk -F, -f csv_clean.awk $file; done;
@bds
bds / gist:7434975
Created November 12, 2013 17:25
File history described as Git patches, follow renames and moves
git log --follow -p file
@bds
bds / creek.rb
Created November 29, 2013 17:19
Fetches static image from the City of Palo Alto "Creek Camera - San Francisquito Creek at West Bayshore Road", respecting response e-tag.
require 'open-uri'
require 'digest/sha1'
class CreekImage
attr_reader :etag, :data, :uri, :sha1
def initialize
@uri = 'http://archive.cityofpaloalto.org/earlywarning/creekcam/creekcam.jpg'
open(@uri) do |img|
require 'open-uri'
require 'nokogiri'
require 'twilio-ruby'
require 'spinning_cursor'
class Page
attr_reader :etag, :last_modified, :data, :uri
def initialize(uri)
@bds
bds / gist:7837545
Created December 7, 2013 05:13
Offline Ruby Core and Stdlib Documentation with Yard
# http://devrandom.postr.hu/offline-ruby-core-and-stdlib-documentation-with-yard
$ gem install yard
$ wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
$ tar xzvf ruby-2.0.0-p247.tar.gz
$ cd ruby-2.0.0-p247
$ yardoc *.c
$ yardoc -b .yardoc-stdlib -o doc-stdlib
$ yard server -m ruby-core2.0 .yardoc stdlib .yardoc-stdlib
@bds
bds / animate_images.sh
Last active December 30, 2015 13:49
Animate a set of time-lapse images with ffmpeg
#! /usr/bin/env sh
ffmpeg -r 12 -pattern_type glob -i '*.jpg' -c:v libx264 animation.mp4
@bds
bds / mp4_to_webm.sh
Last active December 30, 2015 15:49
ffmpeg .mp4 to .webm
#! /usr/bin/env sh
ffmpeg -i animation.mp4 animation.webm
@bds
bds / jpgs_to_gif.sh
Created December 7, 2013 22:48
Ceate a .gif from a sequence of images with ImageMagick
#! /usr/bin/env sh
convert *.jpg -loop 0 creek.gif
@bds
bds / gist:8107165
Created December 24, 2013 00:49
PagerDuty Incidents
require 'minitest/spec'
require 'minitest/pride'
require 'minitest/autorun'
require 'net/http'
require 'json'
describe "PagerDuty::Incident" do
before { @incident = PagerDuty::Incident.new }
@bds
bds / sunspot_keys.rb
Created January 8, 2014 03:58
Return 100 primary keys from a Rails Sunspot Solr search
Model.search { paginate :page => 1, :per_page => 100 }.hits.map(&:primary_key)