Skip to content

Instantly share code, notes, and snippets.

Avatar

Arthur Embleton aembleton

View GitHub Profile
@aembleton
aembleton / activator.fish
Created Jul 16, 2014
Add Activator for Play Framework to fish command line
View activator.fish
function activator
~/Downloads/activator-1.2.3-minimal/./activator $argv
end
@aembleton
aembleton / UnicodeTranslator.scala
Last active Aug 29, 2015
Translates between ASCII and unicode.
View UnicodeTranslator.scala
import scala.annotation.tailrec
object UnicodeTranslator {
private lazy val unicodeRegex = """(\\u[0-9a-fA-F]{4})""".r
def escapeUnicode(stringToEscape:String) = stringToEscape.foldLeft("") { (escaped, char) =>
if (char <= 127) {
escaped + char
} else {
@aembleton
aembleton / Ordnance-Survey.tms
Created Feb 19, 2015
Ordnance Survey map to be used in QLandkarte GT.
View Ordnance-Survey.tms
<TMS>
<Title>Ordnance Survey</Title>
<Layer idx="0">
<Script><![CDATA[
(
function convert(z1, x1, y1)
{
serverpart = 0
serverpart = (serverpart + 1) % 4;
function encodeQuadTree(zoom, tilex, tiley)
@aembleton
aembleton / getPrettyDateRange.php
Created Apr 15, 2015
PHP function to create a date range such as '1st - 4th May 2015' or '28th August - 2nd September 2015'
View getPrettyDateRange.php
function getPrettyDateRange($fromDate, $toDate) {
$fromTime = strtotime($fromDate);
$toTime = strtotime($toDate);
$fromDay = date("jS", $fromTime);
$fromMonth = date("F", $fromTime);
$fromYear = date("Y", $fromTime);
$toDay = date("jS", $toTime);
$toMonth = date("F", $toTime);
@aembleton
aembleton / gist:5063b7f2ad6889e06f27
Created Jul 15, 2015
Use apache commons StringUtils to pretty print an arrayt
View gist:5063b7f2ad6889e06f27
"(" + StringUtils.join(params, ",") + ")"
@aembleton
aembleton / Only UK but this Perl can be expanded upon
Created Mar 15, 2011
Call Perl number normalisation from Java
View Only UK but this Perl can be expanded upon
#!/usr/bin/perl
use strict;
use warnings;
my $n = $ARGV[0];
my $country = $ARGV[1];
if ($country eq "GB") {
if ($n =~ /^0(\d{10})$/x) {
@aembleton
aembleton / Regex.java
Created Mar 17, 2011
Matches regular expressions in the haystack. Any matched strings are returned in a list.
View Regex.java
package util;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Regex {
/**
@aembleton
aembleton / StringUtil.java
Created May 19, 2011
Useful String utility methods.
View StringUtil.java
package utils;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
@aembleton
aembleton / MapToData.java
Created Jul 21, 2011
Converts a Map into URLEncoded data that can be used in a POST
View MapToData.java
package net.blerg;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@aembleton
aembleton / JsonUtil.java
Created Jul 22, 2011
Utility class containing static methods that are useful for reading in and marshalling JSON
View JsonUtil.java
package net.blerg.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
You can’t perform that action at this time.