Skip to content

Instantly share code, notes, and snippets.

View tarmstrong's full-sized avatar

Tavish Armstrong tarmstrong

View GitHub Profile
@tarmstrong
tarmstrong / gist:4219498
Created December 5, 2012 21:07
Phergie test additional method
<?php
class Phergie_Plugin_PhpTest extends Phergie_Plugin_TestCase
{
/**
* Tests for appropriate plugin requirements.
*
* @return void
*/
public function testPluginRequirements()
{
@tarmstrong
tarmstrong / bugfix-diff.txt
Created September 29, 2013 22:36
Why NBDiff should exist
diff --git a/IPythonReviewTime.ipynb b/IPythonReviewTime.ipynb
index 803d4ac..09b5662 100644
--- a/IPythonReviewTime.ipynb
+++ b/IPythonReviewTime.ipynb
@@ -162,7 +162,7 @@
"output_type": "pyout",
"prompt_number": 6,
"text": [
- "<matplotlib.collections.LineCollection at 0x80e5f50>"
+ "<matplotlib.collections.LineCollection at 0x8f86f50>"
@tarmstrong
tarmstrong / nbdiff.py
Created October 7, 2013 04:42
Gist of the nbdiff backend (very rough idea)
from flask import Flask
class NBDiffFlask(Flask):
def set_files(self, file1, file2):
self.file1 = file1
self.file2 = file2
app = NBDiffFlask(__name__)
@app.route("/diff.js")
# two strings
A = 'abcabba'
B = 'cbabac'
# Get a list of columns and their truth values.
[[a == b for (a, b) in list(it.product(A, B))][i*6:i*6+6] for i in range(len("abcabba"))]
"""
expected_result = [[False, False, True, False, True, False],
[False, True, False, True, False, False],
#!/usr/bin/env bash
while [ 1 ];
do
cp ~/test.txt ~/test.txt.old
EVENT=$(inotifywait --format '%e' ~/test.txt);
[ $? != 0 ] && exit
[ "$EVENT" = "MODIFY" ] && echo 'file modified!'
diff ~/test.txt ~/test.txt.old
done
@tarmstrong
tarmstrong / make_merge_conflict.py
Created November 22, 2013 00:48
Cause a merge conflict!
# Tavish Armstrong (c) 2013
#
# make_merge_conflict.py
#
# Make a new directory, initialize a git repository within, and cause a merge conflict.
# Yes. On purpose.
import os
import subprocess
import random
@tarmstrong
tarmstrong / ughghghghghghghg.py
Created November 29, 2013 02:43
ghgghughghghghghghghghghghg
import lib2to3.pygram
import lib2to3.pgen2.driver as driver
class Tree(object):
def __init__(self, n):
self.n = n
self.used_names = set()
def __getitem__(self, idx):
@tarmstrong
tarmstrong / mgu.py
Created December 5, 2013 14:54
Implementation of MGU
# Most General Unifier implementation
# - Tavish Armstrong
class Pred(object):
def __init__(self, name, args):
self.name = name
self.args = args
def apply(self, sub):
@tarmstrong
tarmstrong / vimunstaged.sh
Created January 2, 2014 17:53
In a git repository, open all currently modified and unstaged changes in vim. Each file is opened in a separate tab.
#!/usr/bin/env bash
MODDED_FILES=$( git ls-files --modified );
vim -p $MODDED_FILES
@tarmstrong
tarmstrong / vimlastcommit.sh
Created January 2, 2014 22:06
Open the files you modified in the HEAD commit in vim.
#!/usr/bin/env bash
LAST_COMMIT_FILES=$( git log -1 --numstat --pretty="%h" | tail -n +3 | awk '{print $3}' );
vim -p $LAST_COMMIT_FILES