Skip to content

Instantly share code, notes, and snippets.

\begin{tikzpicture}
\draw%
(6, 0) coordinate (dividerlength)
(0, -1.5) coordinate (dividerbracegap)
(0, -1.3) coordinate (braceLCRgap);
\draw%
(0, -0.6)
@Veedrac
Veedrac / foo.py
Last active August 29, 2015 14:07
totally_a_database = {
"in 1": "out 1",
"in 2": "out 2",
"in 3": "out 3"
}
class MyClass:
def __init__(self):
self.dbitems = DatabaseView(totally_a_database)
### [A] Only code
Although the code is appreciated, it should always have an accompanying explanation. This doesn't have to be long but it is expected.
### [A] Only code (moderation queue)
Although the code is appreciated, it should always have an accompanying explanation. This doesn't have to be long but it is expected. I've arrived here from a moderation queue because this was automatically flagged. Keeping answers to high quality will help prevent that.
### [Q] Truncated error
When showing errors, please *copy the whole error*. All of the information that you have is useful, so if you want better help you should tell us everything you see.
### [Q] Not on topic; not answerable
import random
import sys
from itertools import count
def read_map(map_path):
"""
Read map from the file given by map_path.
returns: iterable of (name, {neighbor: direction, ...})
name: string of current city
"""
Aliquot Chainz
Badly tested, but eh.
usage:
aliquot_chainz <n>
"""
import docopt
import numpy
from collections import defaultdict
from numpy import newaxis
def rotate_packed(packed):
"""
Return a rotated version of a 55-length
array packed into 55 bits. Eg.
import random
import sys
from functools import partial
from timeit import Timer
def values_in_sentinel(keys, dict):
sentinel = object()
items = (dict.get(k, sentinel) for k in keys)
from __future__ import nested_scopes, print_function
import bisect
import numpy
from collections import namedtuple
from itertools import combinations
Num = namedtuple("Num", ["value", "i"])
@Veedrac
Veedrac / matcher.py
Last active August 29, 2015 14:15
Image Matcher - Proof of Concept
import sys
from math import ceil, sqrt
import cv2
import mahotas
import numpy
from scipy.spatial import distance
def preprocess(image, diameter, d=8, sigma=15, k=0):
raw = image = cv2.resize(image, (diameter, diameter))
@Veedrac
Veedrac / shadowing.ml
Last active August 29, 2015 14:15
Not very idiomatic, but gets the point across
let square x = x * x;;
let rec accumulate combiner start n term =
if n = 0 then
start
else
let start = combiner (term n) start
in accumulate combiner start (n-1) term;;
let summation_using_accumulate n term =