Skip to content

Instantly share code, notes, and snippets.

View enrobsop's full-sized avatar

Paul Osborne enrobsop

  • Cambridge, UK.
View GitHub Profile
################################################################################
#
# Provides aliases to simplify commands when working with HADOOP.
#
# Examples:
# hs mapper.py reducer.py ../data/testdata.txt outputdir
#
# ...or, with combiner...
# hsc mapper.py reducer.py ../data/testdata.txt outputdir
#
@enrobsop
enrobsop / drupal2wp.sql
Last active August 29, 2015 14:01
Example Drupal to WordPress migration script
--
-- Script to migrate from Drupal to WordPress
--
-- Author: Paul Osborne
-- Created: 29 May 2014
--
#nosplit -- run entire script atomically
-- ****************************************************************************
@enrobsop
enrobsop / packN_java
Last active August 19, 2021 05:31
Java equivalent of Perl/ PHP pack("N", int) function. (Based on Groovy version at https://gist.github.com/enrobsop/8403667)
// Java equivalent of:
// PHP: pack("N", 123) and unpack("N", str)
// Perl: pack("N", 123) and unpack("N", str)
static String packN(int value) {
byte[] bytes = ByteBuffer.allocate(4).putInt(value).array();
bytes = toPositiveByteArray(bytes);
return String.valueOf((char[]) bytes);
}
@enrobsop
enrobsop / packN_groovy
Last active January 3, 2016 03:39
Groovy equivalent of Perl/ PHP pack("N", int) function.
// Groovy equivalent of:
// PHP: pack("N", 123) and unpack("N", str)
// Perl: pack("N", 123) and unpack("N", str)
static String packN(int value) {
def bytes = ByteBuffer.allocate(4).putInt(value).array()
bytes = toPositiveByteArray(bytes)
(bytes as char[]).toString()
}
@enrobsop
enrobsop / ArrowLine.js
Created October 3, 2013 12:48
A JavaScript 'class' to add an a directional arrow to the centre of a Google Maps API polyline. The API now has built-in functionality to do this (see https://developers.google.com/maps/documentation/javascript/examples/overlay-symbol-arrow). This Gist uses some school-level mathematics to rotate and translate a set of coordinates using matrices.
function ArrowLine(polyline) {
this.div_ = null;
this.polyline_ = polyline;
this.bounds_ = TFUtils.getLineBounds(this.polyline_);
}
ArrowLine.prototype = new google.maps.OverlayView();
ArrowLine.prototype.onAdd = function() {
var div = document.createElement('div');
div.style.position = "absolute";