Skip to content

Instantly share code, notes, and snippets.

View afternoon's full-sized avatar

Ben Godfrey afternoon

View GitHub Profile
@afternoon
afternoon / gist:1821125
Created February 13, 2012 22:39
Output from scalaxb -v -p go go.xsd
[debug] module - ListBuffer(go.xsd)
[debug] xsd - toSchema: SchemaDecl(
topElems(ElemDecl(Some(http://www.thoughtworks-studios.com/ns/go),result,String,None,None,1,1,None,true,true,None,None),
ElemDecl(Some(http://www.thoughtworks-studios.com/ns/go),state,String,None,None,1,1,None,true,true,None,None),
ElemDecl(Some(http://www.thoughtworks-studios.com/ns/go),id,String,None,None,1,1,None,true,true,None,None),
ElemDecl(Some(http://www.thoughtworks-studios.com/ns/go),pipeline,ReferenceTypeSymbol({http://www.thoughtworks-studios.com/ns/go}@pipeline/pipeline),None,None,1,1,None,true,true,None,None),
ElemDecl(Some(http://www.thoughtworks-studios.com/ns/go),link,ReferenceTypeSymbol({http://www.thoughtworks-studios.com/ns/go}@link/link),None,None,1,1,None,true,true,None,None),
ElemDecl(Some(http://www.thoughtworks-studios.com/ns/go),jobs,ReferenceTypeSymbol({http://www.thoughtworks-studios.com/ns/go}@jobs/jobs),None,None,1,1,None,true,true,None,None),
ElemDecl(Some(http://www.thoughtworks-studios.com/ns/go),approvedB
@afternoon
afternoon / hypothesis.n3
Created March 6, 2012 13:12
A hypothesis and supporting evidence encoded in N3
@prefix dc: <http://purl.org/dc/elements/1.1/>.
# this resource is a hypothesis, with common metadata (title, author, date) and
# some links to related concepts
<> a :Hypothesis;
dc:author <http://hypothify.com/martwine>;
dc:author <http://hypothify.com/user5d66>;
dc:author <http://hypothify.com/user9ac7>;
dc:date "2012-03-06T10:25:00";
dc:title "The ocean atmosphere of exchange of ammonia is controlled by the emission of Dimethysulfide"@en;
@afternoon
afternoon / authify.sh
Created May 10, 2012 00:04
Add your public key to authorized_keys on a remote host
#!/bin/bash
# Add yourself to the list of authorized ssh users on a host
host=$1
tmpfile=`mktemp /tmp/authorized_keys.XXXXXX` || exit 1
notice() {
echo -e "\033[33m# $1\033[0m"
}
notice "Adding you to authorized_keys for $host"
@afternoon
afternoon / flup.py
Created May 10, 2012 00:05
Very simple Flickr uploader
#!/usr/bin/env python
from argparse import ArgumentParser
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
from datetime import datetime
from flickrapi import FlickrAPI
from os import environ
from os.path import abspath, basename, expanduser
from sys import argv
@afternoon
afternoon / find_duplicate_files.py
Created July 17, 2012 22:44
Find duplicate files in a directory (optionally only check those matching a filename pattern)
#!/usr/bin/env python
from fnmatch import fnmatch
from os import walk
from os.path import join
from hashlib import md5
from sys import argv
def recursive_glob(rootdir='.', pattern='*'):
for rootdir, dirnames, filenames in walk(rootdir):
@afternoon
afternoon / play20-with-scalate.patch
Created October 1, 2012 16:14
Use Scalate in a new Play 2.0 project
From 5942a6b9041cce90c326664f206592782157353f Mon Sep 17 00:00:00 2001
From: Ben Godfrey <bpgodfrey@gmail.com>
Date: Mon, 1 Oct 2012 17:18:31 +0100
Subject: [PATCH] Use Scalate to render templates
---
app/controllers/Application.scala | 4 +--
app/lib/ScalateIntegration.scala | 53 +++++++++++++++++++++++++++++++++++++++
app/views/index.jade | 3 +++
app/views/index.scala.html | 7 ------
@afternoon
afternoon / jenkins-user-script.sh
Created October 4, 2012 23:09
User data script to spin up a Ubuntu-based Jenkins server on the EC2 clouds
#!/bin/bash
#
# User data script which sets up Jenkins on Ubuntu using Puppet
#
# For example:
#
# $ ec2-run-instances ami-5a19976a -t m1.small --region us-west-2 \
# --key ec2-keypair --user-data-file Desktop/jenkins-user-script.sh
# $ ssh -i ~/.ssh/ec2-keypair-us-west-2 \
# ubuntu@ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com
@afternoon
afternoon / pig_1352835411845.log
Created November 13, 2012 19:40
Piggybank/AvroStorage RuntimeException
Pig Stack Trace
---------------
ERROR 1200: Pig script failed to parse:
<file test.pig, line 8, column 11> pig script failed to validate: java.lang.RuntimeException: could not instantiate 'org.apache.pig.piggybank.storage.avro.AvroStorage' with arguments 'null'
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1000: Error during parsing. Pig script failed to parse:
<file test.pig, line 8, column 11> pig script failed to validate: java.lang.RuntimeException: could not instantiate 'org.apache.pig.piggybank.storage.avro.AvroStorage' with arguments 'null'
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1597)
at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1540)
at org.apache.pig.PigServer.registerQuery(PigServer.java:540)
@afternoon
afternoon / wishlist.mkd
Last active October 13, 2015 06:08
Wishlist 2
@afternoon
afternoon / echomachine.coffee
Created December 3, 2012 22:47
nodemachine resource in coffeescript
sys = require("sys")
http = require("http")
nodemachine = require("nodemachine")
class EchoMachine extends nodemachine.App
canHandleResource: (context) -> true
getResource: (context, callback) ->
context.res.sendBody(context.req.url)
callback(context, true)