Skip to content

Instantly share code, notes, and snippets.

View jbarrett's full-sized avatar
🤘
Be excellent to each other

John Barrett jbarrett

🤘
Be excellent to each other
View GitHub Profile
@jbarrett
jbarrett / todo.html
Last active August 29, 2015 14:05
The cheapest firefox todo list ever - add to bookmarks, set to load in sidebar
<meta http-equiv="refresh" content="10" />
<html>
<frameset cols="*">
<frame id="todo" src="todo.txt">
</frameset>
</html>
@jbarrett
jbarrett / RootURIFor.pm
Created April 14, 2015 17:48
Dancer2::Plugin::RootURIFor prototype
package Dancer2::Plugin::RootURIFor;
use strict;
use warnings;
my $VERSION = 0;
use URI::Escape;
use Dancer2::Plugin;
@jbarrett
jbarrett / .bash_profile
Created March 6, 2012 10:30
Git prompt snippet
# from http://www.entropy.ch/blog/Developer/2009/03/30/Git-and-SVN-Status-in-the-Bash-Prompt.html :
# Prompt setup, with SCM status
parse_git_branch() {
local DIRTY STATUS
STATUS=$(git status 2>/dev/null)
[ $? -eq 128 -o $? -eq 127 ] && return
[[ "$STATUS" == *'working directory clean'* ]] || DIRTY=' *'
echo "($(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* //')$DIRTY)"
}
@jbarrett
jbarrett / rssfs.pl
Created August 24, 2012 14:05
FUSE Module to read/mount a RSS feed
#!/usr/bin/env perl
# rssfs.pl
use strict;
use warnings;
use Date::Parse;
use Fuse;
use HTML::FormatText::WithLinks;
@jbarrett
jbarrett / controller.pl
Created August 29, 2012 19:53
VERY rough prototype for midi control from analogue joystick.
#!/usr/bin/env perl
use MIDI::ALSA;
use SDL;
use SDL::Joystick;
use Time::HiRes qw( usleep );
SDL::init_sub_system(SDL_INIT_JOYSTICK);
my $joystick = SDL::Joystick->new(0);
my $x;
@jbarrett
jbarrett / testloop.sh
Created September 6, 2012 09:24
A very simple loop to give constant feedback on tests v code. Stick it in a small tmux/screen pane for TDD goodness.
#!/bin/bash
# Wait for project changes, run tests, report.
RED=1
GREEN=2
testcmd="make test"
exclude='^\.git|.*swp'
function report {
@jbarrett
jbarrett / db_migrate.pl
Created September 18, 2012 13:39
Quick DBIx::Class::Schema::Versioned deployment skeleton
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use Foo::Schema;
@jbarrett
jbarrett / QDB.pm
Last active December 14, 2015 20:09
Very quick first pass at WWW::QDB, quote retrieval from qdb.us and bash.org with cache for random quotes.
package WWW::QDB;
use v5.10.1;
use strict;
use warnings;
use HTTP::Tiny;
use HTML::TreeBuilder::XPath;
use Scalar::Util qw/looks_like_number/;
@jbarrett
jbarrett / gist:5501284
Last active December 16, 2015 21:39
First pass at .bash_profile function for quick creation of new git projects. Requires sudoer rights.
newrepo() {
repo=$1
if [ -z $repo ] ; then
echo "No repository name specified"
return 1
fi
[[ ! $repo =~ \.git$ ]] && repo="${repo}.git"
sudo -u git git init --bare "/home/git/${repo}"
}
@jbarrett
jbarrett / rename_movies.pl
Last active December 20, 2015 14:29
Quick and dirty script to rename DVD Rips, supplies the existing filename (minus ext) to IMDB for a suggested title/year. Confirms each action (occasionally IMDB::Film comes back with the wrong title or nothing at all, so full automation would be bad). `yes | rename_movies.pl` if you *really* want to do this.
#!/usr/bin/env perl
use IMDB::Film;
use File::Copy;
use autodie;
# Rename DVD Rips, with suggestion from IMDB.
my $dir = shift || '/media/usb1/vids/Movies';
opendir (my $dh, $dir);