Skip to content

Instantly share code, notes, and snippets.

View tarmstrong's full-sized avatar

Tavish Armstrong tarmstrong

View GitHub Profile
@tarmstrong
tarmstrong / myconcordia-refresh.user.js
Created February 3, 2014 18:29
Chrome user script for refreshing myconcordia every five minutes so you don't get logged out of your portal or Moodle while you're working.
// ==UserScript==
// @match https://my.concordia.ca/*
// ==/UserScript==
// Prevent MyConcordia from logging you out every X minutes UGHGHGHGHGH
// by refreshing the page every five minutes.
setTimeout(function () {
location.href = location.href;
}, 1000 * 60 * 5);
@tarmstrong
tarmstrong / test_modified.py
Last active August 29, 2015 13:56
very rough tests for check_modified
# some test data
cell1 = {
"cell_type": "code",
"collapsed": False,
"input": [
"x",
"x",
"x",
"x",
@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):