Skip to content

Instantly share code, notes, and snippets.

export TEMPDEST=/tmp/trouw URL=https://www.ticketswap.nl/36538/trouw-op-zondag-ade-special-ade; while sleep 5; do curl --silent $URL | grep -w -A2 counter-available >! $TEMPDEST; new_sha=$(sha1sum $TEMPDEST | awk '{print $1}'); if [[ "$new_sha" != "$last_sha" ]]; then; rgrowl 'tickets changed' "$( grep counter-value $TEMPDEST )"; echo $new_sha; fi; last_sha=$new_sha; echo -n . ; done
@atomicstack
atomicstack / make_minecraft_snapshot.sh
Created October 1, 2010 20:43
make a .tar.gz snapshot of a specific minecraft world, and copy to dropbox dir
#!/bin/bash
save_dir="$HOME/Library/Application Support/minecraft/saves"
dropbox_dir="$HOME/Dropbox/minecraft/world1_backups/"
dest_file=$( date '+%Y%m%d_%H%M%S.tar.gz' )
world=$1
test -z "$world" && world=World1
cd "$save_dir"
@atomicstack
atomicstack / sparse_checkout.pl
Created November 26, 2010 11:42
Run this inside an empty SVN checkout (e.g. svn co -N <repository>) and it will sparsely check out the entire sub-tree of directories (excluding files). Unfortunately, in my environment Subversion only checks out at about 100 dirs/minute so it's not very
sub do_dir {
my ($dir) = @_;
chdir $dir;
my @entries = map { chomp; $_ } grep { m{/$}xms } qx/svn ls/;
system qw/svn update -N --set-depth=empty/, @entries;
do_dir("$dir/$_") for @entries;
}
@atomicstack
atomicstack / listmaker.sh
Created October 31, 2011 13:41
Convert a single column list into an SQL IN statement, or alternatively a pipe-separated list which can be used with grep.
#!/bin/bash
export SEP_CHAR=""
export QUOTE_CHAR=""
test "$1" == "--grep" && export SEP_CHAR="|"
( test "$1" == "--sql" || test -z "$1" ) && export SEP_CHAR="," && export QUOTE_CHAR="'"
new_list=$( pbpaste | perl -e 'chomp(@lines = <STDIN>); print q{(} . join( $ENV{SEP_CHAR} => map { $ENV{QUOTE_CHAR} . $_ . $ENV{QUOTE_CHAR} } @lines ) . q{)}' )
echo $new_list | pbcopy
@atomicstack
atomicstack / gist:2972905
Created June 22, 2012 14:06
hobo throughput info
prev=$(du -bs . | awk '{print $1}'); sleep 1;
while true; do
now=$(du -bs . | awk '{print $1}');
diff=$(echo -e "scale=3\n($now - $prev) / 1024 / 1024" | bc);
echo "diff: $diff";
prev=$now;
sleep 1;
done
@atomicstack
atomicstack / chrome-mac-debug.sh
Created September 22, 2012 11:38
chrome-mac-debug
#!/bin/bash
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --enable-logging --v=1 2>> "$HOME/Library/Application Support/Google/Chrome/chrome_stderr.log" &
# https://twitter.com/OvidPerl/status/137172488206553090
perl -e '@t=qw(▁ ▂ ▃ ▄ ▅ ▆ ▇ █);@s=sort{$a<=>$b}@ARGV;$d=($s[-1]-$s[0])/@t;$d*=1.01;for(@ARGV){print $t[($_-$s[0])/$d]}'
# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix
# Bind appropriate commands similar to screen.
# lockscreen ^X x
unbind ^X
# bind ^X lock-server
unbind x
[diff]
# external = git-diff-wrapper.sh
algorithm = patience
# colorMoved=plain
[pager]
diff =
[color]
diff = auto
$ perl -MDateTime -E 'printf( qq{%30s: %s\n}, $_, DateTime->now(time_zone => $_)->strftime(q{%a %F %T})) foreach qw{ US/Pacific US/Eastern Europe/London Europe/Amsterdam Europe/Berlin Asia/Singapore Australia/Melbourne }'
US/Pacific: Fri 2018-09-21 14:35:37
US/Eastern: Fri 2018-09-21 17:35:37
Europe/London: Fri 2018-09-21 22:35:37
Europe/Amsterdam: Fri 2018-09-21 23:35:37
Europe/Berlin: Fri 2018-09-21 23:35:37
Asia/Singapore: Sat 2018-09-22 05:35:37
Australia/Melbourne: Sat 2018-09-22 07:35:37