Skip to content

Instantly share code, notes, and snippets.

@mk270
mk270 / amqp-delete-queue.py
Created February 26, 2013 21:07
trivial tool for delete AMQP queues, as Debian squeeze doesn't seem to have my favourite one
#!/usr/bin/env python
import pika
import sys
from optparse import OptionParser
def run():
p = OptionParser()
p.add_option("--hostname", dest="hostname",
default="localhost", help="Hostname of AMQP endpoint")
@mk270
mk270 / contrib_count
Created March 7, 2013 00:48
A cmdline tool for finding how many github contributions a user has made in the last year
#!/usr/bin/python
import requests
import lxml.html
import sys
def get_contrib_count(user):
url = 'https://github.com/%s' % user
html = requests.get(url).read()
root = lxml.html.fromstring(html)
@mk270
mk270 / example.ml
Created March 7, 2013 21:37
example of trivial thing it's hard to do in python
let get_value p =
if p > 3
then 1
else
try
100 / p
with _ ->
-1
let main () =
@mk270
mk270 / gist:5124548
Last active December 14, 2015 17:48
sqlite schema for timelinejs backend for parlyhack
-- sqlite schema for parly hack
CREATE TABLE event (
event_id integer primary key,
start_date date,
end_date date,
headline text,
event_body text,
media text,
media_credit text,
@mk270
mk270 / testlimit.c
Created March 17, 2013 18:41
Test rlimit operation
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <unistd.h>
int limit = LIMIT;
void infinite_loop(void) {
struct timeval tv;
@mk270
mk270 / tags.el
Created March 17, 2013 18:45
html tag tool
(defun add-tags (tag)
"add tags"
(interactive)
(save-excursion
(goto-char (region-end))
(insert (concat "</" tag ">"))
(goto-char (region-beginning))
(insert (concat "<" tag ">"))))
@mk270
mk270 / gist:5213183
Created March 21, 2013 13:57
I don't understand SQLA transactions
# Leaves a transaction
p_group = models.PackageGroup.query.filter_by(name=id).first_or_404()
# Doesn't leave a transaction, if uncommented instead of above
#p_group = db.session.query(models.PackageGroup).filter_by(name=id).first()
del(p_group)
db.session.commit()
@mk270
mk270 / gist:5408855
Last active December 16, 2015 08:49
What I had to do to get an OCaml executable working

Install OCaml from source

  • download ocaml-4.00.1.tar.gz
  • tar zxvf path/to/ocaml-4.00.1.tar.gz
  • cd ocaml-4.00.1
  • ./configure -prefix $HOME
  • make world
  • make bootstrap
  • make opt
@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`