Skip to content

Instantly share code, notes, and snippets.

@mattfenwick
mattfenwick / addcomments.pl
Created May 22, 2018 15:56
Add comments to exported functions, methods, types in a golang source tree
my $path = $ARGV[0];
# print $path;
open(my $file, "<", $path) or die "Unable to open file, $!";
my $contents = do { local $/; <$file> };
close $file;
# print $contents;
{
"name": "X",
"fields": [
["a", "Int"],
["b", "String?"]
]
}
@mattfenwick
mattfenwick / recipes.md
Created April 1, 2016 19:00
git recipes

Merges

Use diff3 conflict markers

$ git config --global merge.conflictstyle diff3

Show the diffs that introduced a conflict

$ git log -p --oneline --left-right --merge

@mattfenwick
mattfenwick / jamie.jpg
Last active August 28, 2015 19:02
bye bye Jamie
asb
@mattfenwick
mattfenwick / dumper.py
Last active September 11, 2015 20:49
extract tickets from git history using commit messages
import subprocess
import re
import sys
if len(sys.argv) != 3:
print "incorrect args"
print sys.argv
sys.exit(1)
@mattfenwick
mattfenwick / gzip.sh
Last active August 29, 2015 14:06
examples using unix utilies
# pack a file
gzip -c workflows.tar > workflows.gzip
# unpack a file
gzip -c -d workflows.gzip > unzipped.tar
@mattfenwick
mattfenwick / notes.md
Last active August 29, 2015 14:06
notes on mongodb

Starting mongo

  • may need to create the /data/db folder
  • run mongod or service mongod start to get it started
    • may need to sudo those so that it gets permissions
  • run mongo to get into an interactive shell

From (Python|Javascript|etc.)

install pymongo somehow

use strict;
use warnings;
local $/; # set slurp mode so that entire file is read at once (instead of a single line)
my $content = <STDIN>;
my %refs = ();
foreach my $key ($content =~ m/\\ref\{([\w_]+)\}/g) {
'use strict';
var genhtml = require('genhtml-js'),
h = genhtml.html,
s = genhtml.serialize,
types = require('function-js').types;
// extend Array
function ArrayExt() {}
ArrayExt.prototype = [1, 2, 3];
@mattfenwick
mattfenwick / annotate.json
Created December 12, 2013 20:30
annotate
[
{
"problem": "ambiguity: multiple matching sequential SS",
"resolution": [
[
79,
{
"51": {
"residueid": 20
},