Skip to content

Instantly share code, notes, and snippets.

@hoodja
hoodja / Pipeable.js
Created April 8, 2013 16:38
Notice a closed pipe and just stop.
process.stdout.on('error', function( err ) {
if (err.code == "EPIPE") {
process.exit(0);
}
});
@hoodja
hoodja / output.txt
Last active December 15, 2015 13:29
>>> original_list = ['awesome', 'stupid', 'jim', 'rich', 'magnus']
>>> [ x + 'sauce' for x in original_list]
['awesomesauce', 'stupidsauce', 'jimsauce', 'richsauce', 'magnussauce']
function render {
cat << END_RENDER
#begin the "real" content
blah $FOO
foo $BAR
smack $HEAD
for $USER
#end the "real" content
@hoodja
hoodja / win_to_unix_path.bat
Last active December 14, 2015 07:08
On a windows-base slave, translate the workspace path to unix style ('\' ==> '/') for use in MinGW commands
:: assumes MinGW exists on system so echo and sed are available
:: TODO: perhaps attempt to rework with magic variable expansion built-in to the Windows shell
:: this format is for file-based execution
:: if you are attempting to run this on the command line, %%i should be %i instead (thanks Microsoft :/)
FOR /F "tokens=*" %%i in ('echo %WORKSPACE%^| sed -e ''s/\\/\//g''') do SET MinGW_JENKINS_WORKSPACE=%%i
@hoodja
hoodja / unity_to_junit.pl
Last active December 14, 2015 06:38
"bash" me all you want, but this is sweet. It turns the verbose output of Unity xUnit framework for C (yes, straight eff'n C) into JUnit results that Jenkins CI can eat.
use strict;
use warnings;
my $fname = shift or die 'filename!';
open my $fh, $fname or die "Could not open $fname: $!";
print "<testsuite>\n";
foreach(grep /^ *(IGNORE_)?TEST/, <$fh>) {
my ($status, $group, $test, $detail);
#include "unity_fixture.h"
int PrimeFactors(int number, int* primes, int primes_size)
{
int count = 0;
int candidate = 0;
for (candidate = 2; number > 1; candidate++)
for (; number % candidate == 0; number /= candidate)
primes[count++] = candidate;
watch( 'test/.*\.clj' ) {|md| test_stuff }
watch( 'src/.*\.clj' ) {|md| test_stuff }
def colorize(text, color_code)
"#{color_code}#{text}\e[1;37m"
end
def red(text); colorize(text, "\e[0;31m"); end
def green(text); colorize(text, "\e[0;32m"); end
@hoodja
hoodja / your_script.sh
Created November 19, 2011 18:51 — forked from zspencer/your_script.sh
Pair with Zee
#If you're on a mac/linux, you can just copy and paste this. If you're on Windows, you need to figure out how to do this using Putty.
ssh remotepair@pairwith.zacharyspencer.com -p9876
#Password: pairingftw
tmux -S /var/tmux/pairing attach
@hoodja
hoodja / gist:1139488
Created August 11, 2011 12:06
Mercurial command to expunge anything that is not checked into repository (think 'make clean')
hg --config extensions.purge= clean --all
@hoodja
hoodja / gist:1139459
Created August 11, 2011 11:48
Quickly find project directories which have the fewest test files (really just fewest files)
for i in $(find . -name '*TestMain.cpp' -exec dirname {} \; | sort | uniq); do
echo "$(find $i -type f -depth 1 -maxdepth 1 | wc -l) $i";
done | sort -n | head