Skip to content

Instantly share code, notes, and snippets.

@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 / 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
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 / 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|
@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 / 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:6576210
Created September 16, 2013 02:43
Minitest Cheat Sheet
# Credit - http://mattsears.com/articles/2011/12/10/minitest-quick-reference
#
# must_be list.size.must_be :==, 0
# must_be_close_to subject.size.must_be_close_to 1,1
# must_be_empty list.must_be_empty
# must_be_instance_of list.must_be_instance_of Array
# must_be_kind_of list.must_be_kind_of Enumerable
# must_be_nil list.first.must_be_nil
@bds
bds / gist:6556881
Created September 13, 2013 22:27
Get google.com every 60 seconds for 100 minutes. Helped me keep network connection "alive". Sure there is a better way to do this (curl and bash would be simpler, including only requesting HEAD)
while max <= 100 do; puts Net::HTTP.get('www.google.com', '/'); max +=1; sleep 60; end
@bds
bds / gist:4192180
Created December 3, 2012 02:11
Subset an R dataframe by a list of dates
subset(df, sprint.end.date %in% as.Date(c("2012-11-16", "2012-11-30")))
@bds
bds / gist:3733733
Created September 16, 2012 18:49
Ignore EOL characters in a git diff
git diff HEAD --ignore-space-at-eol