Skip to content

Instantly share code, notes, and snippets.

@tomviner
tomviner / readme.md
Last active February 23, 2016 11:22

Patching _pytest.assertion.rewrite.rewrite_asserts to output the rewritten ast tree

Follow up to:

Which version of Meta?

When the above was written Meta couldn't cope with some of the rewritten ast trees in pytest tests. But srossross kindly responded quickly to my comment and merged the already written Meta/PR#19.

But until Meta>0.4.1 is released, we'll still need to use pip install -e [email protected]:srossross/Meta.git#egg=Meta

from __future__ import unicode_literals
class Explode():
def __repr__(self):
return '(1/0)'
explode = Explode()
class Expr(object):
def __init__(self, percent_expr, logic_op, bool_expr, percent_first, percent_char):
@tomviner
tomviner / link_match.py
Last active August 29, 2015 14:06
Linkify PyConUK Schedule Page
@tomviner
tomviner / snake1d.py
Last active May 6, 2016 08:49
One dimensional snake
import os
import random
import string
import sys
import time
from utils import getch
def snake1d():
@tomviner
tomviner / ColBan.js
Last active August 29, 2015 14:00
BAU Standup KanBan Cleaner
// column IDs
var inbox = 240,
pri = 21,
signoff = 23,
done = 28,
show_top_n_issues = 3;
var to_hide = [inbox, signoff, done];
// hide columns and their titles
@tomviner
tomviner / dojo.py
Created January 10, 2014 14:39
Git when last changed dict
#!/usr/bin/env python
import subprocess
from collections import defaultdict
def latest():
filesdict = {}
changecount = defaultdict(int)
stringlist = subprocess.check_output(["git","ls-files"]).split("\n")

Hi all,

A few of us had a discussion at PyconUK about doing a trip to Bletchley Park and the The National Museum of Computing.

  • Date: Saturday 19th Oct

If, like me, you're London based, then join the Pythonista Express from Euston:

@tomviner
tomviner / jQuery-stop.md
Last active December 19, 2015 19:59
Note to everyone using any type of "click performs an animation"

Note to everyone using any type of click performs an animation:

While slowing down an animation, we just found that it's really easy to make code fail when you click to trigger an animation multiple times while it's still performing the previous rounds. This is due to the variables we're using getting all out of sync as you end up running the animation code multiple times concurrently. Sad times.

The solution is to call $('.item-that-is-animating').stop(true, true); within the click handler before you do your animation code. This Stops the currently-running animation on the matched elements. and the true arguments are for clearQueue ie delete any events waiting to be triggered and jumpToEnd which, critically, will run your callback immediately without waiting for the delay to finish.

Example:

$("#visual_type_selector").delegate("a", "click", function() {

var newHash = $(this).attr('href');

@tomviner
tomviner / README.md
Last active December 19, 2015 17:19
SpareRoom.co.uk bookmarklet to open a directions map in a new tab.

Create a bookmarklet with this address:

javascript:(function(){var MY_DEST='LONDON';var t=jQuery('script:contains(SR.listing.detail.init()').text();var m=t.match(/lat: '(-?\d+\.\d+)',\s+lon: '(-?\d+\.\d+)/);var lat=m[1];var lon=m[2];var url='https://www.google.co.uk/maps?saddr='+lat+','+lon+'&daddr='+MY_DEST+'&directionsmode=transit&dirflg=r';window.open(url);})();

Remember to edit your destination address.

@tomviner
tomviner / gcal-many-weeks.js
Last active December 24, 2016 01:25
Google Calendar: Show more than 4 weeks at a time.
function trigger(ename, elem){
if (!elem) {
console.log("Cannot " + ename + " element missing");
}
console.log("Trigger " + ename + " on " + elem);
console.log(elem);
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent(ename, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
elem.dispatchEvent(evt)
}