Skip to content

Instantly share code, notes, and snippets.

View sean-duffy's full-sized avatar

Sean Duffy sean-duffy

View GitHub Profile
import re
references = []
with open('references.bib', 'r') as references_file:
references = re.findall('@\w*{(.*),', references_file.read())
dupes = [x for x in references if references.count(x) > 1]
not_cited = []
{
"title": "Sample Quiz",
"questions": [
{
"question": "Why did the chicken cross the road?",
"correct_answer": "C",
"answers": [
{
"option": "A",
"answer": "Because it wanted to."
import re
import requests
from lxml import html
rspca_base = 'https://www.rspca.org.uk'
def get_pet(name, ref):
base = rspca_base + '/findapet/details/-/Animal/{0}/ref/{1}/rehome/'
base = base.format(name, ref)
r = requests.get(base)
def parent(i):
return (i + 1) / 2 - 1
def left(i):
return (i + 1) * 2 - 1
def right(i):
return ((i + 1) * 2)
def insert(heap, n):
class Node:
def __init__(self, n):
self.n = n
self.left = None
self.right = None
class BinarySearchTree:
def __init__(self, node=None):
self.head = node
@sean-duffy
sean-duffy / matrices.py
Created February 5, 2014 16:41
Functions to calculate the determinant of a matrix.
def sign_factor(coords, matrix):
"""
Return the sign factor of the item in a matrix with
the coordinates specified by 'coords'.
"""
if (coords[0] % 2 == 0) != (coords[1] % 2 == 0):
return -1
else:
return +1