Skip to content

Instantly share code, notes, and snippets.

@nicokruger
nicokruger / piped-script-arguments.sh
Created March 18, 2012 20:01
bash pass arguments to script read through pipe
λ ~ → echo 'echo $1 $2 $3' | bash -s - 10 11 12
10 11 12
@nicokruger
nicokruger / gister.sh
Created March 18, 2012 20:34
Gister (view gists on github)
#!/bin/bash
if [ $# -lt 3 ]; then
echo "Usage: <mode> <github username> <gist filename>" >&2
echo " mode is:" >&2
echo " -o output the file to stdout" >&2
echo " -s store the file in a temporary location, and print the temp filename" >&2
echo " -x execute the script" >&2
echo " (to pass arguments to the downloaeded script, add a \"-\" and add" >&2
echo " add the args for the downloaded script after that)" >&2
@nicokruger
nicokruger / count-files.sh
Created March 18, 2012 21:02
count-files.sh
#!/bin/bash
echo $(find . -type f | grep -v .git | wc -l)
@nicokruger
nicokruger / simple-gnuplot.sh
Created March 18, 2012 21:27
Simple 1d gnuplot line graph
TMP_FILE=$(mktemp)
for var in "$@"
do
echo $var >> $TMP_FILE
done
GNUPLOT_FILE=$(mktemp)
gnuplot <<DeadBeef
set style line 1 linetype 2
@nicokruger
nicokruger / argstester.sh
Created March 18, 2012 21:38
argstester.sh
for var in "$@"
do
echo $var
done
@nicokruger
nicokruger / asciiplot.rb
Created March 18, 2012 22:09 — forked from tremby/gist:1571696
plot -- ascii plot of numerical input data
#!/usr/bin/env ruby
def usage(stdout = false)
stream = stdout ? $stdout : $stderr
bin = File.basename($0)
indent = " " * (bin.length() + "Usage: ".length())
stream.puts("Usage: #{bin} [--help|-h]")
stream.puts(indent + " [--vertical]")
@nicokruger
nicokruger / 8ball.rb
Created March 18, 2012 22:13 — forked from tremby/gist:1571672
8ball -- simple magic 8-ball script with original answers
#!/usr/bin/env ruby
def usage(stdout = false)
stream = stdout ? $stdout : $stderr
bin = File.basename($0)
indent = " " * (bin.length() + "Usage: ".length())
stream.puts("Usage: #{bin} [--help|-h]")
stream.puts(indent + " [--yes|--no|--maybe]")
@nicokruger
nicokruger / twitter-everyone-list.py
Created March 20, 2012 05:54 — forked from blech/twitter-everyone-list.py
Create an 'everyone' list with everyone you're currently following.
#!/usr/bin/python2
import warnings
warnings.simplefilter('ignore', DeprecationWarning)
import httplib2, urllib, time
from urllib import urlencode
try:
import json
except ImportError:
@nicokruger
nicokruger / SimpleRL.py
Created March 20, 2012 06:05
Simple RL python - taken from https://raw.github.com/nrkn/SimpleR for demo
#!/usr/bin/env python
import curses
from curses import KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT
MAP = [
'#### ####',
'# #### #',
'# #',
'## ##',
@nicokruger
nicokruger / annoying-blogger
Created March 20, 2012 06:15
Blogger does not have code blocks
This gist will host random code listings for blogger posts.