Skip to content

Instantly share code, notes, and snippets.

View benjaminhawkeslewis's full-sized avatar

Benjamin Hawkes-Lewis benjaminhawkeslewis

View GitHub Profile
@benjaminhawkeslewis
benjaminhawkeslewis / gist:2623263
Created May 6, 2012 16:56
Sharing clipboards

Sharing clipboards between OS X and remote *nix

Install latest stable XQuartz.

Forward your X11 connection when SSHing to the box:

ssh -X remoteuser@remotehost

Alternatively you can configure this, globally or for an individual host, in your .ssh/config with the ForwardX11 directive.

@benjaminhawkeslewis
benjaminhawkeslewis / gist:1366855
Created November 15, 2011 11:32
Create or reattach tmux session oneliner
function tmux_create_or_reattach() { tmux has-session -t $1 && tmux attach -t $1 || tmux -u -L $1; }; tmux_create_or_reattach ben
@benjaminhawkeslewis
benjaminhawkeslewis / gist:1333608
Created November 2, 2011 13:22
Gawking my time log
gawk -F "\t" '{ split($1, times, "/") ; split(times[1], start_time, /[T:-]/); split(times[2], end_time, /[T:-]/); h = (mktime(end_time[1] " " end_time[2] " " end_time[3] " " end_time[4] " " end_time[5] " 00") - mktime(start_time[1] " " start_time[2] " " start_time[3] " " start_time[4] " " start_time[5] " 00"))/(60*60); t[$3] = t[$3] + h } END { for (tag in t) { printf "%-50s\t%.2f\n", tag, t[tag] } }' time\ log.txt
@benjaminhawkeslewis
benjaminhawkeslewis / gist:1333465
Created November 2, 2011 12:01
Unattended CPAN installations
PERL_MM_USE_DEFAULT=1 cpan -i Some::Package::Or::Other
# If fails, try installing/upgrading CPAN and Test::Harness
@benjaminhawkeslewis
benjaminhawkeslewis / gist:1267584
Created October 6, 2011 14:48
My first Pig script - filter input by UUID, then sort by score
-- Filter rows in $inputFile by UUIDs present in $filterByFile, then sort by score
input = LOAD '$inputFile' USING PigStorage('\t') AS (uuid:chararray,score:double);
filter_by = LOAD '$filterByFile' USING PigStorage('\t') AS (uuid:chararray);
filtered = JOIN input BY uuid, filter_by by uuid;
wanted_fields = FOREACH filtered GENERATE $0 as uuid:chararray, $1 as score:double;
ordered = ORDER wanted_fields BY score DESC;
STORE ordered INTO '$outputDir' USING PigStorage('\t');
@benjaminhawkeslewis
benjaminhawkeslewis / gist:1244758
Created September 27, 2011 10:16
Put curly braces after closing parens
for f in `ack-grep -l '\) {' .` ; do sed -i -e 's/\( *\)\(.*\)) {/\1\2)\n\1{/' $f ; done
@benjaminhawkeslewis
benjaminhawkeslewis / gist:1214006
Created September 13, 2011 14:55
Customizing Mac OS X Snow Leopard
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
# Brew some packages
brew install gawk
brew install gnupg
brew install bash-completion
brew install git
brew install yuicompressor
brew install tmux
@benjaminhawkeslewis
benjaminhawkeslewis / gist:1200092
Created September 7, 2011 08:51
Customizing Ubuntu Lucid
# Some useful things
apt-get install fortune ack-grep
# Update time hourly - useful for VMs that may be paused
ln -s /usr/sbin/ntpdate-debian /etc/cron.hourly/
# Latest weechat (0.3.6-dev)
add-apt-repository ppa:nesthib/weechat && apt-get update && apt-get dist-upgrade && apt-get install weechat
# Git config
@benjaminhawkeslewis
benjaminhawkeslewis / gist:1192630
Created September 4, 2011 10:24
Possible way to structure Java test code for a (PHP) HATEOS webservice
src/main/java/com/acme/uiAutomation/webServices/Driver.java => abstraction for selenium2/webdriver
src/main/java/com/acme/uiAutomation/webServices/DriverFactory.java => factory for selenium2/webdriver
src/main/java/com/acme/uiAutomation/webServices/component/HomePage.java => Page Object for homepage
src/main/java/com/acme/uiAutomation/webServices/component/LoginDialog.java => Page Component for login dialog
src/test/unit/java/com/acme/uiAutomation/webServices/DriverFactoryTestSuite.java => unit tests for driver factory
src/test/performance/java/com/acme/webServices/TestSuite.java => performance tests for homepage
src/test/functional/java/com/acme/webServices/HomePageTestSuite.java => functional tests for homepage
@benjaminhawkeslewis
benjaminhawkeslewis / gist:1139912
Created August 11, 2011 15:14
Watch HTTP traffic with tshark
# In this case, track HTTP on eth0, port 4444
tshark -i eth0 -d tcp.port==4444,http -R 'http' -Tpdml -V -S -l "port 4444" | grep '"http.'