Skip to content

Instantly share code, notes, and snippets.

View main.html
<body>
{{> hello}}
</body>
<template name="hello">
{{#with people}}
{{count}}
{{/with}}
</template>
View TestUnstash.java
import java.io.File;
import java.util.UUID;
import org.eclipse.jgit.api.Git;
public class TestUnstash {
public static void main(String[] args) throws Exception {
File directory = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
directory.mkdir();
File.createTempFile("blank", null, directory);
@mrw34
mrw34 / package.json
Created Dec 14, 2015
West London Xmas Hack Night
View package.json
{
"dependencies": {
"underscore": "^1.8.3",
"vorpal": "^1.4.0",
"ws": "^0.8.1"
}
}
@mrw34
mrw34 / traintimes_gcal.user.js
Created Jul 12, 2013
Userscript to replace iCal downloads on traintimes.org.uk with links to Google Calendar's event creation page
View traintimes_gcal.user.js
// ==UserScript==
// @match http://traintimes.org.uk/*
// ==/UserScript==
(function() {
var icals = document.getElementsByClassName("ical");
for (var i = 0; i < icals.length; i++) {
icals[i].href = 'http://markwoodbridge.appspot.com/ical?url=' + encodeURIComponent(icals[i].href);
}
@mrw34
mrw34 / west.clj
Last active Dec 19, 2015 — forked from t-ob/west.clj
View west.clj
(ns genetic.core)
(def letters
(conj (map (comp char
(partial + 97))
(range 26))
\space))
(defn random-string [source]
(let [length (count source)]
@mrw34
mrw34 / geoip.sh
Last active Dec 20, 2015
Convert IP addresses (e.g. from httpd logs) to GeoJSON
View geoip.sh
#!/bin/bash -eu
echo {\"type\": \"GeometryCollection\", \"geometries\": [
sep=
while read ip ; do
coordinates=$(curl -s freegeoip.net/csv/$ip | csvtool col 9,8 -)
echo $sep{\"type\": \"Point\", \"coordinates\": [$coordinates]}
sep=,
done
echo ]}
@mrw34
mrw34 / mailx.sh
Last active Feb 29, 2016
A primitive mailx emulator using bash, curl and Mailgun
View mailx.sh
#!/bin/bash
set -eu -o pipefail
cmd="curl -s --user 'api:$MAILGUN_API_KEY' https://api.mailgun.net/v2/$MAILGUN_DOMAIN/messages"
while getopts "r:c:b:s:a:E" opt; do
case $opt in
r)
cmd+=" -F from='$OPTARG'"
;;
@mrw34
mrw34 / package.json
Created Apr 6, 2016
Mixpanel export
View package.json
{
"dependencies": {
"moment": "^2.12.0",
"request": "^2.70.0",
"underscore": "^1.8.3"
}
}
@mrw34
mrw34 / index.js
Last active Apr 11, 2016
Stable JavaScript Object hash function for Node.js
View index.js
function hash(object, algorithm, encoding) {
var h = require('crypto').createHash(algorithm || 'md5');
(function update(v, k) {
if (k !== undefined) {
h.update(JSON.stringify(k));
}
if (v && v.constructor === Array) {
v.forEach(function(value) {
update(h, value);
});