Skip to content

Instantly share code, notes, and snippets.

@bds
bds / gist:9240609
Created February 26, 2014 22:58
Loop a shell command
for run in {1..10}
do
command
done
@bds
bds / cookie_values
Created February 12, 2014 02:55
JavaScript one-liner for cookie values
@bds
bds / gist:8946724
Created February 11, 2014 23:40
Parse 1st JSON result
JSON.parse(open("https://www.scripted.com/formats/").read).take(1)
@bds
bds / gist:8553090
Created January 22, 2014 03:34
Find Ruby puts statements polluting test output
find spec/ -type file | xargs grep "p " | cut -d " " -f 1 | sort | uniq
@bds
bds / gist:8544104
Created January 21, 2014 17:16
Remove trailing whitespace from Vim
:%s/\s\+$//
@bds
bds / gist:8359654
Last active January 2, 2016 20:49
Mongo console commands
show dbs
use my_db
show collections
db.printCollectionStats()
db.things.find( {}, { _id:1 } ) # All documents ids
db.things.find ( { _id: ObjectId("daf3424234dsf12334f") } ).count()
@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)
@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 / 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 / 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