Skip to content

Instantly share code, notes, and snippets.

View afternoon's full-sized avatar

Ben Godfrey afternoon

View GitHub Profile
@afternoon
afternoon / travelwishlist.mkd
Last active October 13, 2015 20:18
Travel Wishlist
  • Trans-Siberian
  • High Himalaya (hiking?)
  • Tibet, Lhasa
  • Chile, Argentina
  • Scandinavia
  • The Icelandic Interior
@afternoon
afternoon / xmltest.erl
Created February 22, 2013 15:41
Examples of generating XML with Erlang's xmerl library.
-module(xmltest).
-compile(export_all).
-include_lib("xmerl/include/xmerl.hrl").
%% @doc Helper function to generate XML from a data structure and print it
serialize(Data) ->
Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)),
io:format("~s~n", [Xml]).
@afternoon
afternoon / JsonOps.scala
Last active December 14, 2015 14:29
Easily serialise any object to JSON in Scala via an implicit conversion.
/*
* Usage:
*
* import com.ben2.jsonops.Implicits._
* val obj = makeSomeObject()
* println(obj.toJson)
*/
package com.ben2.jsonops
@afternoon
afternoon / local_config.json
Last active December 15, 2015 11:39
local_config.json for package iOS apps with Trigger.io
{
"general": {
},
"ios": {
"profiles": {
"DEFAULT": {
"provisioning_profile": "/path/to/project.mobileprovision",
"certificate": "iPhone Developer: Ben Godfrey (XXXXXXXXXX)"
}
}
@afternoon
afternoon / url_safe_uuid.py
Last active April 29, 2017 17:12
Generate URL-safe UUID/GUIDs in Python.
#!/usr/bin/python
# Generate URL-safe UUID/GUIDs in Python, e.g.
#
# ob9G9Ju_Re6SRgxacdUzhw
# k0CWKgThQq-9b2ZcmpVXXA
#
# base64 has an urlsafe encoding
from base64 import urlsafe_b64encode
@afternoon
afternoon / Prog2a.dat
Last active December 16, 2015 05:19
Solution and example data file for BCS problem 2a in OCaml (from a 2004 BCS programming competition).
() (B,A)
(A,B) (C:A;D,D:B)
(A,B) (C:E)
(A,B) (C:A;B;E,D:F)
(A,B) (C:A;B;D;E;F,E:A,D:F)
(A,B,C,D,E) (F)
(Pack1, Pack2) ( Pack3 : Pack4 , Pack4 : Pack1 )
() (ThisIsAVeryLongPackageNameThat:MadeUpPackage)
(UPPER,lower) (NEW:uPpEr;LOWER,oThEr:new)
@afternoon
afternoon / elastic-beanstalk-ssl-config-extension.yaml
Created April 14, 2013 20:30
Elastic Beanstalk configuration file to set up SSL hosting on application instances. See http://tmblr.co/ZU9VxvibvDWI.
# vim: ft=yaml
packages:
yum:
mod_ssl: "" # empty string means latest
container_commands:
10-ssl-key-cert-install:
command: "cp -r .ebextensions/ssl /etc/httpd/"
20-apache-ssl-config:
command: "cp .ebextensions/ssl.conf /etc/httpd/conf.d/ssl.conf"
@afternoon
afternoon / elb-sg-config.yaml
Created April 14, 2013 20:34
Security group and load balancer config file for Elastic Beanstalk. See http://tmblr.co/ZU9VxvibvDWI.
# vim: ft=yaml
# Elastic Load Balancer and Security Group configuration for the app
#
# - Allow anyone to connect to port 443 and office traffic to connect to
# port 22
# - Ensure all traffic is encrypted by configuring load balancer to listen on
# 443 and direct traffic to port 443 on app servers
# - Enable cookie-based session stickiness
# - Use /status for health check
# - Enable backend authentication policy by providing public key for cert
@afternoon
afternoon / helloworld.py
Last active December 16, 2015 05:28
Hello world for the Bottle Python microframework.
from bottle import get, run
@get("/status")
def status():
return {"status": "ok"}
run(host="localhost", port=8080, debug=True, server="gunicorn", workers="4", reloader=True)
@afternoon
afternoon / config.ru
Created April 14, 2013 20:49
Hello world with JSON output for Sinatra (inc config to run server behind Unicorn with 4 workers - 1700 req/s on a 2012 iMac FWIW).
require File.dirname(__FILE__) + '/helloworld.rb'
run HelloWorld.new