Skip to content

Instantly share code, notes, and snippets.

@mk270
mk270 / ocamlbuild-oasis-warn.txt
Last active August 29, 2015 13:56
misformatted warnings from oasis
Note shell prompt appended to long last line
mk270@cornford ~/Src/iati-test> ocamlbuild src/driver.byte
Finished, 0 targets (0 cached) in 00:00:00.
Finished, 17 targets (17 cached) in 00:00:00.
W: Cannot get variable ext_objW: Cannot get variable ext_libW: Cannot get variable ext_dllW: Cannot get variable ocamlfindW: Cannot get variable ocamlfindW: Cannot get variable ocamlfindW: Cannot get variable ocamlfindW: Cannot get variable ocamlfindW: Cannot get variable ocamlfindmk270@cornford ~/Src/iati-test>
@mk270
mk270 / rust-encoding-build.txt
Created August 9, 2014 20:22
iron rust-encoding build problem
mk270@cornford ~/Prog/rust/web1> rm -rf target; cargo clean; rm -f Cargo.lock; cargo build
Updating git repository `https://github.com/iron/cookie.git`
Updating git repository `https://github.com/DaGenix/rust-crypto.git`
Updating git repository `https://github.com/iron/iron.git`
Updating git repository `https://github.com/servo/rust-url.git`
Updating git repository `https://github.com/lifthrasiir/rust-encoding`
Updating git repository `https://github.com/chris-morgan/rust-http.git`
Updating git repository `https://github.com/sfackler/rust-openssl.git`
Updating git repository `https://github.com/chris-morgan/anymap.git`
Updating git repository `https://github.com/reem/rust-http-content-type.git`
@mk270
mk270 / ws_handler.erl
Created September 2, 2014 00:30
Websocket handler attempt
-module(ws_handler).
-behaviour(cowboy_websocket_handler).
-export([init/3]).
-export([websocket_init/3]).
-export([websocket_handle/3]).
-export([websocket_info/3]).
-export([websocket_terminate/3]).
init({tcp, http}, _Req, _Opts) ->
@mk270
mk270 / websocket_app.erl
Created September 2, 2014 00:32
websocket routing
%% Feel free to use, reuse and abuse the code in this file.
%% @private
-module(websocket_app).
-behaviour(application).
%% API.
-export([start/2]).
-export([stop/1]).
@mk270
mk270 / gist:4a148b07cbfffed7bb3f
Created May 7, 2015 08:13
word generator compile error
mk270@cornford ~/Src/word_generator> cargo build
Updating git repository `https://github.com/rust-lang/rand.git`
Downloading unicode-segmentation v0.1.0
Downloading regex v0.1.30
Compiling rustc-serialize v0.3.14
Compiling regex v0.1.30
Compiling libc v0.1.6
Compiling unicode-segmentation v0.1.0
Compiling rand v0.3.8 (https://github.com/rust-lang/rand.git#93544850)
Compiling word_generator v0.1.0 (file:///home/mk270/Src/word_generator)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
int main(int argc, char *argv[], char *env[]) {
char *arena;
char hex[100];
char *target;
tax_payable = (band_info, gross) ->
tax_in_band = (band) ->
band.rate * (Math.min(band.max, gross) - Math.min(band.min, gross))
total = 0
bands = for band in band_info
prev_total = total
total += band.width + 0
{ width: band.width, rate: band.rate, min: prev_total, max: total }
@mk270
mk270 / latin2utf.c
Created April 12, 2012 14:27
Convert ISO-8859-1 to UTF-8 with constant RAM (cf iconv)
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#define MAX 4096
void die(const char *s) {
perror(s);
exit(1);
}
@mk270
mk270 / horizontal_accountability.ml
Created July 19, 2012 16:00
Modelling horizontal accountability / checks and balances in OCaml
type branch =
| Legislative
| Executive
| Judicial
| Other
type origin =
| Elected
| Appointed
@mk270
mk270 / mysql_with_ftwrl.rb
Created July 20, 2012 14:02
CLI wrapper for "FLUSH TABLES WITH READ LOCK"; usage mysql_with_ftwrl.rb do_snapshot --db=name
#!/usr/bin/ruby
require 'dbi'
db_name = 'db_test'
db_user = 'username'
db_pass = 'pass1234'
db_host = '127.0.0.1'
exit_status = nil