Skip to content

Instantly share code, notes, and snippets.

@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 / cookie_values
Created February 12, 2014 02:55
JavaScript one-liner for cookie values
@bds
bds / gist:9240609
Created February 26, 2014 22:58
Loop a shell command
for run in {1..10}
do
command
done
@bds
bds / query_params_rack_parse.rb
Last active August 29, 2015 13:57
Parse HTTP request query parameters with Rack::Utils
require 'rack'
params = "car[][color]=blue&car[][doors]=2&car[][model][name]=acme&car[][model][country]=usa"
Rack::Utils.parse_nested_query(params)
@bds
bds / green_line.rb
Created April 25, 2014 21:21
Ruby string to print a dotted green line
puts "\033[32m-\033[0m" * 79
@bds
bds / find_xargs_grep_sed.sh
Created June 3, 2014 03:45
find, xargs, grep and sed
find . -name *spec.rb |xargs grep -l 86400| xargs sed -i '' 's/86400/10/g'
@bds
bds / osx-i-love-you.rb
Last active August 29, 2015 14:02
say I love you
`say -v? | cut -f1 -d' '`.split("\n").each {|v| `say -v "#{v}" I love you`}
@bds
bds / exception-one-liner.rb
Created September 17, 2014 17:16
Ruby Exception Oneliner
(rdb:1) begin model.association.find_by(label: field["name"]); rescue => e; puts e.class; end
@bds
bds / keybase.md
Created September 18, 2014 00:41

Keybase proof

I hereby claim:

  • I am bds on github.
  • I am bds (https://keybase.io/bds) on keybase.
  • I have a public key whose fingerprint is F157 0BAD 213C 68E5 5989 5EB0 F101 7FA2 66D5 7F86

To claim this, I am signing this object:

@bds
bds / gist:7dff642d43bbe481457b
Created October 1, 2014 20:52
Mongoid Finder Methods
mongoid-3.1.6/lib/mongoid/criterion/modifiable.rb