Skip to content

Instantly share code, notes, and snippets.

@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 / HttpContextFactory.cs
Created February 7, 2012 13:32
Factory method to allow us to mock HttpContext when testing
using System.Web;
namespace AndrewJones
{
/// <summary>
/// Factory method to allow us to mock HttpContext when testing
/// </summary>
public static class HttpContextFactory
{
private static HttpContextBase mockHttpContext;
@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);
@andrewrjones
andrewrjones / yours2nginx.php
Created April 26, 2013 22:37
Script to migrate short URLs from YOURLs to nginx.
#!/usr/bin/php
<?php
/*
This script takes all the short URL's in the YOURLs database and generates
an nginx config file containing the correct redirects.
Use if you want to migrate away from YOURLs and use nginx to ensure the links
continue to work.