Skip to content

Instantly share code, notes, and snippets.

@wheresalice
wheresalice / gist:468c89b85051ea369d1e
Created May 20, 2014 15:01
check a crc file matches a datafile
def check_crc(crc_file, datafile)
expected_crc = File.read(crc_file).split(' ')
actual_crc = `cksum #{datafile}`.split(' ')
unless File.exist?(crc_file)
puts 'crc file missing'
return false
end
unless File.exist?(datafile)
puts 'datafile missing'
return false

Piratebox on a cloud VM

Piratebox on a cloud VM gives you a really quick setup to see what you get out of the box. We strip away the networking stack that it offers, and run the web frontend.

First of all we need a basic Debian 7.x VM. I've opted for Digital Ocean because it's cheap and simple to use, other providers are available.

Once the VM is built (60 seconds) we log in and ensure the package lists are up to date:

apt-get update

@wheresalice
wheresalice / gist:f0b2180d082a3e2ce501
Last active August 29, 2015 14:20
Used what we learned at SparkCamp to play with some of Leeds City Council 2014 road traffic accident data
// Download 2014 Road traffic accidents from Leeds City Council
// http://data.gov.uk/dataset/road-traffic-accidents/resource/4882af59-27c5-4148-9624-6cffee36c688
// Remove the header line in an editor because we've not figured out how to do this in Spark yet
// Register the data
val data = sc.textFile("/home/akaerast/downloads/accidents2014.csv")
# Describe the class
case class Accident(reference: String,
@wheresalice
wheresalice / gist:112195
Created May 15, 2009 12:42
Display open Trac tickets modified in the past 10 days
SELECT p.value AS __color__,
id AS ticket, summary, component, version, t.type AS type,
owner, status,
time AS created,
changetime AS _changetime, description AS _description,
reporter AS _reporter
FROM ticket t, enum p
WHERE status <> 'closed'
AND unix_timestamp(date_sub(now(), interval 10 day)) < changetime
AND p.name = t.priority AND p.type = 'priority'
@wheresalice
wheresalice / gist:112197
Created May 15, 2009 12:44
redacted code which goes through a Drupal database subscribing all new users to a Mailman list on a separate server. Relies upon Drupal Drush module and Mailman XMLRPC2 patch.
import os
import xmlrpclib
proxy = xmlrpclib.ServerProxy("https://lists.mydomain.org/mailman/RPC2")
def nicepass(alpha=6,numeric=2):
"""
returns a human-readble password (say rol86din instead of
a difficult to remember K8Yn9muL )
"""
@wheresalice
wheresalice / gist:112198
Created May 15, 2009 12:45
Training Bogofilter with virtual imap users
#!/bin/sh
#retrain_bogofilter.sh
#Version 2.0
#jkv@unixcluster.dk - free for all
#kaerast at qvox - modifications, free for all
#Prerequisites:
# - formail
# - bogofilter
<?php
$couch_dsn = "http://localhost:5984/";
$couch_db = "inout";
require_once "../lib/couch.php";
require_once "../lib/couchClient.php";
require_once "../lib/couchDocument.php";
$client = new couchClient($couch_dsn,$couch_db);
@wheresalice
wheresalice / in-out_gui.php
Created January 3, 2010 17:33
PHP-GTK/CouchDB PoC code to set status of an in/out board
<?php
$couch_dsn = "http://localhost:5984/";
$couch_db = "inout";
// libraries come from http://github.com/dready92/PHP-on-Couch
require_once "../lib/couch.php";
require_once "../lib/couchClient.php";
require_once "../lib/couchDocument.php";
$client = new couchClient($couch_dsn,$couch_db);
@wheresalice
wheresalice / gist:271161
Created January 7, 2010 10:54
Select somebody's name or email address, then use this bookmarklet to search for them on Facebook. It can probably be refactored, but I'm not Javascript expert
javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://www.facebook.com/search/?ref=ffs&q=',l=d.location,e=encodeURIComponent,p=e(s)+'&o=2048&init=ffs',u=f+p;{a%20=function(){if(!w.open(u,'t','toolbar=0,resizable=0,status=1,width=450,height=430'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0);