Skip to content

Instantly share code, notes, and snippets.

View mikeymckay's full-sized avatar

Mike McKay mikeymckay

View GitHub Profile
# If you, like me, have all of your various source-code-like projects in ~/src/
# this is how to give yourself per-project shell history.
#
# I wish I'd done this years ago.
#
# First, in your .bashrc file, you redefine the cd, pushd and popd builtins to be "do the builtin bit,
# then do one other thing (set_src_history.sh, below) like so:
cd () {
@janoskk
janoskk / couchclone.sh
Created May 28, 2014 22:27
Create (if necessary) and replicate all databases from a couchdb server to another one
#!/bin/sh
#
# Janos Kasza (@janoskk)
#
# Creates (if necessary) and replicates all databases from a couchdb server to another one
#
if [ -z "$2" ]; then
cat <<EOF
Usage: $0 <sourceUrl> <targetUrl>
@championofblocks
championofblocks / wav-mp3
Last active March 18, 2024 20:08
Command line bash to convert all wav to mp3
for i in *.wav; do lame -b 320 -h "${i}" "${i%.wav}.mp3"; done
@mcotton
mcotton / gist:2631131
Created May 7, 2012 22:43
Forward ssh ports for couchdb

This is handy for seeing the couchdb futon interface without making it publicly available. It still will only accept connections from localhost.

Syntax:
ssh -L <local port>:porxy:<remote port> <user>@<remote host>

Example for CouchDB:

ssh -L 5984:localhost:5984 ubuntu@10.0.99.115

@caseyjustus
caseyjustus / median.js
Created August 23, 2011 19:34
calculate the median of an array with javascript
function median(values) {
values.sort( function(a,b) {return a - b;} );
var half = Math.floor(values.length/2);
if(values.length % 2)
return values[half];
else
return (values[half-1] + values[half]) / 2.0;
mu:inception tom$ make
gcc -g -Wall -m32 -c -o inception.o inception.c
gcc -g -Wall -m32 -g -o inception inception.o -lpthread
mu:inception tom$ ./inception
Dreamer [Fischer], level [1], priority [19], policy [OTHER]
Dreamer [Cobb], level [1], priority [19], policy [OTHER]
Dreamer [Ariadne], level [1], priority [19], policy [OTHER]
Dreamer [Arthur], level [1], priority [19], policy [OTHER]
Dreamer [Eames], level [1], priority [19], policy [OTHER]
Dreamer [Saito], level [1], priority [19], policy [OTHER]
When /^(?:|I )go to (.+)$/ do |page_name|
When /^(?:|I )press "([^\"]*)"(?: within "([^\"]*)")?$/ do |button, selector|
When /^(?:|I )follow "([^\"]*)"(?: within "([^\"]*)")?$/ do |link, selector|
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, value, selector|
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
# When I fill in the following:
When /^(?:|I )fill in the following(?: within "([^\"]*)")?:$/ do |selector, fields|
When %{I fill in "#{name}" with "#{value}"}
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
When /^(?:|I )check "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')