Skip to content

Instantly share code, notes, and snippets.

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 / traintimes_gcal.user.js
Created July 12, 2013 19:00
Userscript to replace iCal downloads on traintimes.org.uk with links to Google Calendar's event creation page
// ==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 December 19, 2015 20:49 — forked from t-ob/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 December 20, 2015 08:49
Convert IP addresses (e.g. from httpd logs) to GeoJSON
#!/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 / main.html
Created April 2, 2014 15:24
meteor-with
<body>
{{> hello}}
</body>
<template name="hello">
{{#with people}}
{{count}}
{{/with}}
</template>
@mrw34
mrw34 / blog.xml
Created May 26, 2014 19:51
Minimal Jekyll Atom feed template
---
---
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{site.title}}</title>
<id>http://{{site.domain}}/</id>
<updated>{{site.time | date_to_xmlschema}}</updated>
<link href="http://{{site.domain}}/blog.xml" rel="self"/>
{% for post in site.posts %}
@mrw34
mrw34 / index.js
Last active April 11, 2016 20:13
Stable JavaScript Object hash function for Node.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);
});
@mrw34
mrw34 / gist:b12531d1a8df25f6c170
Last active July 19, 2022 12:30
Trello JSON to CSV conversion using jq
jq -r '["List", "Card"], ((reduce .lists[] as $list ({}; .[$list.id] = $list.name)) as $lists | .cards[] | select(.closed != true) | [$lists[.idList],.name]) | @csv' <nw3RUeLl.json
@mrw34
mrw34 / package.json
Created December 14, 2015 20:06
West London Xmas Hack Night
{
"dependencies": {
"underscore": "^1.8.3",
"vorpal": "^1.4.0",
"ws": "^0.8.1"
}
}
@mrw34
mrw34 / mailx.sh
Last active February 29, 2016 10:00
A primitive mailx emulator using bash, curl and Mailgun
#!/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'"
;;