Skip to content

Instantly share code, notes, and snippets.

@andrewrjones
andrewrjones / signal_test.pl
Created March 31, 2014 15:58
keep doing something until we catch an INT signal (Ctrl + C)
#!perl
# keep doing something until we catch an INT signal (Ctrl + C)
use strict;
use warnings;
my $running = 1;
$SIG{INT} = sub { $running = 0 };
@andrewrjones
andrewrjones / asset-check.pl
Last active August 29, 2015 14:04
Quick and dirty Perl script to email me a report of sites possibly hosting my assets. See http://andrew-jones.com/blog/prevent-other-sites-from-serving-your-assets-with-nginx/
#!perl
#
# See http://andrew-jones.com/blog/prevent-other-sites-from-serving-your-assets-with-nginx/
use strict;
use warnings;
use URI::Split qw(uri_split);
use Data::Dumper;
use Email::MIME;
@andrewrjones
andrewrjones / quarter-interval.js
Created December 1, 2009 15:57
Quarter as an interval in Simile Timeline.
/*
* This allows you to use a Quarter as an interval in the Simile Timeline.
* See http://andrew-jones.com/2009/12/01/using-a-quarter-interval-with-the-simile-timeline/ for info.
* It has been tested with version 2.3.0 (March 6, 2009). Unlikely to work with other versions.
* For more information on the timeline, see http://www.simile-widgets.org/wiki/Timeline
*/
SimileAjax.DateTime.QUARTER = 11;
(function() {
@andrewrjones
andrewrjones / extracting-data-from-a-sharepoint-list-with-paging.pl
Created October 7, 2010 12:36
Extract data from SharePoint list - with paging
#!perl
use strict;
use warnings;
use LWP::UserAgent;
use LWP::Debug;
use SOAP::Lite on_action => sub { "$_[0]$_[1]"; };#, +trace => 'debug';
import SOAP::Data 'name', 'value';
@andrewrjones
andrewrjones / date-from-week-number.pl
Created October 8, 2010 15:59
date-from-week-number.pl
#!perl
use POSIX;
use DateTime;
use Test::More tests => 3;
sub date_from_week_number {
my ( $week_num, $year ) = @_;
$year ||= POSIX::strftime( '%Y', localtime );
@andrewrjones
andrewrjones / Gistson.php
Created July 5, 2011 21:37 — forked from phatduckk/Gistson.php
Embed a Gist in Wordpress
<?php
/*
Plugin Name: Gistson - Embedded Gist WP Plugin
Plugin URI: http://arin.me/blog/tag/gistson
Description: Use a shortcode [gist id="12345"] to embed A Gist from http://gist.github.com into your blog
Version: 0.2
Author: Arin Sarkissian
Author URI: http://arin.me
Copyright 2009 Arin Sarkissian, 2011 Andrew Jones
# Import PowerShell Community Extensions
# Available from http://pscx.codeplex.com/
$pscx = Get-Module -List Pscx
if($m){Import-Module Pscx}
Set-Alias open Invoke-Item
Set-Alias vi gvim # because I forget...
function prompt
{
@andrewrjones
andrewrjones / kinosearch1_dump.pl
Created January 19, 2012 16:18
Dump the KinoSearch1 index.
#!/usr/bin/perl
use strict;
use warnings;
use KinoSearch1::Index::IndexReader;
my $r = KinoSearch1::Index::IndexReader->new( invindex => '/path/to/index' );
# get one or more readers
my @readers = ref $r->{sub_readers} eq 'ARRAY' ? @{ $r->{sub_readers} } : $r;
@andrewrjones
andrewrjones / gist:1876882
Created February 21, 2012 14:40
Slurping text from a file
sub slurp_from_file {
my ( $self, $file ) = @_;
return do {
local $/ = undef;
open my $fh, "<", $file
or die "could not open $file: $!";
my $doc = <$fh>;
# ensure there are no carriage returns
@andrewrjones
andrewrjones / arsenal-ticket-email.pl
Created September 15, 2012 16:45
Lets me know when Arsenal tickets are available
#!perl
use v5.10.1;
use strict;
use warnings;
use Getopt::Long;
use Storable qw(store retrieve);