Skip to content

Instantly share code, notes, and snippets.

@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 / link_match.py
Last active August 29, 2015 14:06
Linkify PyConUK Schedule Page
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):
import pytest
import httpretty
@pytest.yield_fixture
def mock_out_devpi():
httpretty.reset()
httpretty.enable()
# prevent all other urls, except those registered
httpretty.HTTPretty.allow_net_connect = False
hosts = ('pypi.local', 'pypi-zonza.company.local')
@tomviner
tomviner / fixture_loading.py
Created April 17, 2015 10:22
Load a django fixture, but error if the file can't be found
import os
from django.core import management
from django.conf import settings
def load_ensured_fixture(fixture_path):
"""
Load a fixture with a path like 'my_app/fixtures/test_initial_data.json'
@tomviner
tomviner / README.md
Last active August 29, 2015 14:22
How HTTPS Everywhere Chrome extension is breaking Lanyrd signin

Steps to reproduce bug

  1. Install Chrome extension HTTPS Everywhere
    • I have Version: 2015.5.28
  2. Visit http://lanyrd.com/
  3. Click Signin
  4. A JS error popup should appear saying
    • image

Confirm

"""
https://twitter.com/raymondh/status/617049150606028801
#python tip: The modulo operation x % y gives a result with the same sign as y and with abs(result) < abs(y):
>>> 11 % 7
4
>>> 11 % -7
-3
"""
import math
from hypothesis import given, assume
@tomviner
tomviner / output.txt
Last active August 29, 2015 14:24
Hypothesis test_reverse example
[206096504910900498493010377380239941762L, 27, 241, 468, 206096504910900498493010366855655511824L, -340, 206096504910900498493010370573292788646L, 6, -188, 206096504910900498493010365575630902925L]
[21895897394889366278002048857818986990125268678994617770323631L, -5, 73453863292979521160722570724395436702110210638363401802874390L, 860083230267801667615814962096447759118030419081884684367195374L, 1208756186641563556189216823181235577582763775470322786885255197L, 563574118372954898036644503963904424109207146483853094148809633L, 20, -1464475540476225476021127290449598226042060199991921137850322312L, -1554085104269531629275069816677895447025824915356256971517138516L, 658781301413442456187105669962066361153531021415203972856482081L, 1421770204015349061297731987862436233014697243702547161097469746L, 1111082349050193290192329277649104120747717126931126127983058755L, -109571337096131499455011271023310218778431969690802066031870575L, -1536409144373002107386864029818511666641780965936236899633623888L, 0, 14137316515470
@tomviner
tomviner / spottylotty.py
Created September 9, 2011 15:43
Spotify Ticket Lottery
from __future__ import division
import sys
import math
import random
# http://www.spotify.com/us/jobs/tech/ticket-lottery/
def bc(n, k, f=math.factorial):
"""Binomial coefficient in terms of Factorials
(n) = ____n!____
@tomviner
tomviner / q1.py
Created September 16, 2011 08:47
Anagram of Palindrome
# -*- coding: utf-8 -*-
"""
1) A string is a palindrome if it reads the same from left-to-right as it does right-to-left.
e.g “nolemonnomelon”, “racecar” & “neveroddoreven” are all palindromes.
A string is an anagram of another string if it consists of exactly the same characters but in another order.
e.g The string “carrace” is an anagram of “racecar”.
Write a function `def is_anagram_of_palindrome(str):`
such that it returns True if the string str is an anagram of a palindrome, and otherwise returns False.
You may assume that str contains only lowercase characters a-z and is not empty.
e.g Given str = “carrace” the function should return True as it is an anagram of the palindrome “racecar”.