Skip to content

Instantly share code, notes, and snippets.

View tommystanton's full-sized avatar

Tommy Stanton tommystanton

View GitHub Profile
@tommystanton
tommystanton / date-format-conversion.p6
Last active July 10, 2019 02:37
Perl 6 script to convert dates to ISO8601
#!/usr/bin/env perl6
use v6.d;
=begin DESCRIPTION
Given a newline-delimited file of mm/dd/yyyy, write a newline-delimited
file of yyyy-mm-dd.
=end DESCRIPTION
@tommystanton
tommystanton / perl6-run-tests.sh
Last active May 7, 2018 00:03
Automatically run tests when a source file is modified (Perl 6)
#!/bin/bash
while inotifywait \
--quiet --quiet \
--recursive \
--event close_write \
lib/ @lib/.precomp/ bin/ t/; do \
clear; \
prove --exec perl6 --lib --verbose; \
done
@tommystanton
tommystanton / vim_setup.sh
Last active May 18, 2020 23:50
Set up Vim with reasonable defaults
#!/bin/sh
vimrc="$HOME/.vimrc"
vim_plugin_dir="$HOME/.vim/plugin"
sensible_plugin='https://raw.githubusercontent.com/tpope/vim-sensible/master/plugin/sensible.vim'
mkdir -p "$vim_plugin_dir"
wget -P "$vim_plugin_dir" "$sensible_plugin"
cat << "EOT" - >> "$vimrc"
@tommystanton
tommystanton / sum.org
Created July 21, 2015 16:55
Basic table formulas in Org Mode
DescriptionAmount
Foo5.30
Bar3.10
#Total:8.40
@tommystanton
tommystanton / dirs_stack.md
Created July 14, 2015 01:34
Use a dirs stack element as an argument on the command-line

Using the dirs (bash-builtins(7)) stack to create a playlist for Audacious of two Ubiktune albums I recently purchased off of Bandcamp:

$ dirs -v
 0  ~/Music
 1  ~/Music/Zackery_Wilson/SNESQUE
 2  ~/Music/Joshua_Morse/Waveform_4

$ audacious $(dirs -l +2) $(dirs -l +1) &

@tommystanton
tommystanton / bitwise_flag_example.pl
Created December 6, 2013 06:48
Perl example of using bitwise operations as "flags"
# Based on this tutorial:
# http://www.devshed.com/c/a/Perl/Perl-Bit-by-Bit/3/
#
# This will print:
#
# .--------------------------------.
# | Name | Programmer? | Adult? |
# +---------+-------------+--------+
# | Bob | Yes | Yes |
# | Alice | No | Yes |
@tommystanton
tommystanton / eggtartClient.js
Created December 3, 2013 03:26
Use Eggtart (Node.js module) to add a bookmark to Delicious.
/*
This is very crude.
Example usage:
$ node eggtartClient.js \
'https://github.com/fcambus/ansiweather' \
'fcambus/ansiweather' \
AnsiWeather CLI weather unicode shell_script github repository-git
null { result: { '$': { code: 'done' } } }
@tommystanton
tommystanton / install_and_run.txt
Last active December 23, 2015 05:58
Learning TDD in Node.js using Mocha and should (and journey, to simulate a web application).
$ npm install mocha should journey
$ node_modules/.bin/mocha --ui tdd --reporter tap server.checkHello.test.js
1..1
ok 1 Response from /hello URI should return JSON containing "hello"
# tests 1
# pass 1
# fail 0
@tommystanton
tommystanton / ed
Created September 17, 2012 18:49
GNU ed + GNU readline
#!/bin/sh
# Try to add GNU readline support to GNU ed
hash rlwrap 2>&-
if (( $? == 0 )); then
exec /usr/bin/rlwrap /bin/ed "$@"
else
exec /bin/ed "$@"
fi
#!/bin/bash
#
# By Andrew Grangaard ( http://www.lowlevelmanager.com )
# inspired by
# svnvimdiff:
# Copyright 2007 by Geoff Buchan
# http://www.vim.org/scripts/script.php?script_id=1797
# which was
# Based on the script cvsvimdiff, written by
# Stefano Zacchiroli <zack@cs.unibo.it>