Skip to content

Instantly share code, notes, and snippets.

@preaction
preaction / README.md
Created March 16, 2012 18:40
dot-files README.md

= Dot Files =

Configuration and scripts for productivity.

== Usage ==

Clone git repo. Copy or create links to files as necessary.

=== Local overrides ===

@preaction
preaction / Intro-XS-CXX.html
Created March 22, 2012 07:41
Intro to XS/C++
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Intro to XS/C++</title>
<!-- metadata -->
<meta name="generator" content="S5" />
<meta name="version" content="S5 1.2a2" />
<meta name="author" content="Doug Bell" />
<meta name="company" content="Double Cluepon Software Corp." />
@preaction
preaction / jsontidy.pl
Created May 7, 2012 18:13
Pretty-print a JSON file from STDIN or multiple filenames as arguments
#!/usr/bin/env perl
# Pretty-print JSON file
use JSON;
my @files = @ARGV;
my @fh;
if ( !@files ) {
@fh = ( *STDIN );
}
@preaction
preaction / gist:2630216
Created May 7, 2012 20:34
Kill all sleep processes for the current user
ps au | perl -anle'print $F[1] if $F[10] eq "sleep"' | xargs kill
@preaction
preaction / plackup.sh
Created May 16, 2012 07:53
A SysV-style init/rc script for Plackup
#!/bin/sh
# A basic plackup script
NAME=RT
PLACKUP=rt-server
USER=rt
PID_FILE=/tmp/rt-server.pid
case $1 in
start)
@preaction
preaction / git_perl5lib.sh
Created May 29, 2012 20:01
Update perl5lib with all lib/blib dirs in a directory
# Set the right PERL5LIB
for LIBDIR in $HOME/git/*; do
if [[ -e $LIBDIR/blib/lib ]]; then
PERL5LIB=$LIBDIR/blib/lib:$LIBDIR/blib/arch:$PERL5LIB
fi
# lib dir outranks blib dir, though this might cause problems with XS modules
if [[ -e $LIBDIR/lib ]]; then
PERL5LIB=$LIBDIR/lib:$PERL5LIB
fi
done
@preaction
preaction / gist:2871329
Created June 4, 2012 22:52
De-PBP ALL THE Moose-Y THINGS
sub de_pbp($) {
my ( $class ) = @_;
my $meta = $class->meta;
for my $attr_name ( $meta->get_attribute_list ) {
my $attr = $meta->get_attribute( $attr_name );
next if $class->can( $attr_name ); # Don't overwrite something already here
if ( $attr->reader eq "get_$attr_name" && $attr->writer eq "set_$attr_name" ) {
# Also install the non-PBP version
# Have to use globref because we're immutable...
no strict 'refs';
@preaction
preaction / gist:2915077
Created June 12, 2012 04:47
method_ref for Perl
sub method_ref {
my ( $self, $method_name, @args ) = @_;
return sub { $self->$method_name( @args, @_ ); }
}
@preaction
preaction / CleanupDir.pm
Created June 18, 2012 16:42
MooseX::Runnable module to archive/delete files in a directory based on size, age, and/or total size rules.
package CleanupDir;
use Moose;
with 'MooseX::Getopt';
with 'MooseX::Runnable';
use File::Find;
use File::stat;
use autodie qw( :system );
use Log::Log4perl qw( :easy );
@preaction
preaction / digest.sh
Created June 18, 2012 17:56
output mail digest system
# digest.sh
# Create an e-mail digest of all output, STDOUT and STDERR, and send it
# when given the proper command.
# Usage:
# digest.sh add <job_name> <command>
# # Send an e-mail and reset the digest
# digest.sh send <job_name>
# Environment:
# DIGEST_DIR: The directory to store digests in
# MAILTO: The e-mail to send digests to