Skip to content

Instantly share code, notes, and snippets.

View morungos's full-sized avatar

Stuart Watt morungos

View GitHub Profile
@morungos
morungos / dump.pl
Created July 12, 2013 16:54
Simple script to fairly safely dump a MySQL database to a bunch of tab files, with accompanying SQL definitions. It's not designed as a reliable backup, but as a way of archiving very large databases for processing by other tools.
#!/usr/bin/perl -w
use strict;
use Carp;
use DBI;
use File::Spec;
use File::Path qw(make_path);
use Getopt::Long;
my ($verbose, $username, $password, $hostname, $tabs);
@morungos
morungos / mptt.pl
Created September 18, 2013 16:57
Example code for MongoDB setting left and right values for modified preorder tree traversal. Problem and data are from here: http://www.sitepoint.com/hierarchical-data-database-2/
#!/usr/bin/perl -w
=data
db.data.drop();
db.data.insert({_id: "Food"});
db.data.insert({_id: "Fruit", parent: "Food"});
db.data.insert({_id: "Red", parent: "Fruit"});
db.data.insert({_id: "Cherry", parent: "Red"});
db.data.insert({_id: "Yellow", parent: "Fruit"});
db.data.insert({_id: "Banana", parent: "Yellow"});
@morungos
morungos / server.js
Created October 3, 2013 17:38
Naive server for node.js, handling static files for testing JS sites that won't work from files
var express = require('express');
var app = module.exports.app = express();
function logErrors(err, req, res, next) {
console.error(err.stack);
next(err);
}
function clientErrorHandler(err, req, res, next) {
@morungos
morungos / dcc_to_vcf.pl
Last active December 27, 2015 02:39
Quick script to convert DCC output data to VCF. It's a bit grubby to say the least (only uses core dependencies) and only handles SNPs.
#!/usr/bin/env perl -w
use strict;
use warnings;
# Basic script to convert DCC output for SNPs to a VCF file capable of being
# used for later analysis. More complex variants won't yet work, due to the need
# for reference genome information which we don't get from the DCC output yet.
#
# Written to use minimal Perl dependencies.
@morungos
morungos / gist:8866319
Last active August 29, 2015 13:56
Stuart's OSX plist for MongoDB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mongodb/bin/mongod</string>
@morungos
morungos / gist:9420347
Created March 7, 2014 21:20
Recursively search a directory of compressed XML files for something, using parallel stuff for performance
find . -name '*.xml.gz' -print0 | sort -z | xargs -r0 -I "{}" -P 4 sh -c "gzip -d -c {} | grep --label={} -H 1229467"
--- WordNet-3.0/src/stubs.c 2007-01-04 12:47:55.000000000 -0500
+++ WordNet-3.0.1/src/stubs.c 2014-05-15 15:05:32.000000000 -0400
@@ -40,8 +40,7 @@ int wn_findvalidsearches (ClientData cli
char *morph;
int pos;
if (argc != 3) {
- interp -> result =
- "usage: findvalidsearches searchword partofspeechnum";
+ Tcl_SetResult(interp, "usage: findvalidsearches searchword partofspeechnum", TCL_DYNAMIC);
return TCL_ERROR;

Keybase proof

I hereby claim:

  • I am morungos on github.
  • I am morungos (https://keybase.io/morungos) on keybase.
  • I have a public key ASCd1oTZKTv3xw9lQKbNRRAD7l40-Z_S-1hawBYo4Tk_wgo

To claim this, I am signing this object:

@morungos
morungos / audit.yml
Created June 15, 2017 15:03
Ansible plays to build a table of pushed deployments
---
- name: "Local action: Mark the deployment"
local_action: shell echo '|' `git log -n1 | grep -E "^commit"` '|' {{inventory_hostname}} '|' `date` '|' `whoami` '|' >> deploy.md
run_once: yes
@morungos
morungos / .block
Created August 9, 2017 14:24 — forked from mbostock/.block
Bullet Charts
license: gpl-3.0