Skip to content

Instantly share code, notes, and snippets.

from bs4 import BeautifulSoup
import functools
import inspect
class Field(object):
def __init__(self, selector=None):
self._value = None
self.selector = selector
def _get_element(self, selector=None):
@aGHz
aGHz / gist:6024190
Created July 17, 2013 20:32
Dat frequency
A = new webkitAudioContext();
vol = A.createGainNode(); vol.gain.value = 0.3; vol.connect(A.destination);
osc1 = A.createOscillator(); osc1.frequency.value = 40; osc1.noteOn(0); osc1.connect(vol);
osc2 = A.createOscillator(); osc2.frequency.value = 75; osc2.noteOn(0); osc2.connect(vol);
@aGHz
aGHz / gist:5781787
Last active December 18, 2015 12:19
A and Z are collections of closed segments defined by their 1-d endpoints.
Each is sorted according to the start position of the segment.
Place these segments on a line according to the following constraints:
- segments from Z must absolutely retain their position.
- if a segment from A starts before a segment from Z but overlaps with it,
split it in two. The part before the segment in Z retains its position, and
the second part comes after the segment from Z. This can happen multiple
times as needed.
- if a segment from A overlaps with a segment from Z but doesn't start
before, simply move it after the segment from Z.
table.prod-specs {
font-size: 12px;
width: 100%;
margin-bottom: 25px;
}
table.prod-specs thead {
border-bottom: 1px solid #000;
}
@aGHz
aGHz / python_repr.md
Created October 30, 2012 14:48
Strange behaviour with repr() and __repr__ in Python

The Python builtin repr() doesn't seem to take into account the object's __repr__

class Foo(object):
    __repr__ = lambda self: "class"

    def __init__(self, a):
        self.__repr__ = lambda: "object"

foo = Foo('object')

print foo # "class"

@aGHz
aGHz / gist:3758501
Created September 20, 2012 21:36
Compiling against Python.h installed by Homebrew

If compiling anything against a Python.h installed by homebrew install python raises the warning (promoted to an error) ‘PyArg_ParseTuple’ is an unrecognized format function type, review this Homebrew issue and then edit the appropriate pyconfig.h to comment out the line #define HAVE_ATTRIBUTE_FORMAT_PARSETUPLE 1.