Skip to content

Instantly share code, notes, and snippets.

class Foo():
@classmethod
def _fetch(cls, data):
response = requests.get("http://example.com/my/fun/data", data=data)
return cls(response.json())
class ChildFoo(Foo):
@classmethod
def get_latest(cls):
return cls._fetch({'fleeb':'farb', 'can':'dog'})

Keybase proof

I hereby claim:

  • I am habnabit on github.
  • I am habnabit (https://keybase.io/habnabit) on keybase.
  • I have a public key whose fingerprint is 61A4 97F3 DAFE 523F 6D38 6EB4 10F2 FD0D 67DE 9C2A

To claim this, I am signing this object:

{
"depgraph": {
"pydoctor.driver": {
"twisted": 1,
"twisted.internet": 1,
"twisted.python": 1,
"twisted.web": 1,
"twisted.web.resource": 1,
"twisted.web.server": 1,
"twisted.web.vhost": 1
import treq
from twisted.internet import defer, task
def testD():
def makeRequest():
d = treq.get('http://example.com/')
d.addErrback(handleError)
return d
*.egg*
/.tox
+ rm -rf .tox
+ tox
GLOB sdist-make: /Users/habnabit/Projects/20150415-pip-2689/setup.py
py27 create: /Users/habnabit/Projects/20150415-pip-2689/.tox/py27
py27 inst: /Users/habnabit/Projects/20150415-pip-2689/.tox/dist/pip-2689-test-1.2.3.zip
py27 runtests: PYTHONHASHSEED='1241514770'
_________________________________________________________________ summary __________________________________________________________________
py27: commands succeeded
congratulations :)
+ tmp='/var/folders/q5/vn6fl1yn3zgff3jtjjl1_tjm0000gn/T//pip-*'
@habnabit
habnabit / shell.py
Created November 10, 2010 19:28 — forked from gregglind/shell.py
import shlex as shlex_
from subprocess import Popen, PIPE
def shell(args, input=None, stdout=PIPE, stderr=PIPE, shlex=False, **kwargs):
"""Gets the output of a command run in a subprocess.
Arguments:
args: A sequence of strings, or a single string if shlex=True.
input: A string to be written to the process's stdin.
Any extra keyword arguments are forwarded to Popen.
@habnabit
habnabit / pygame_twisted.py
Created September 12, 2012 16:50 — forked from RyanHope/pygame_twisted.py
PyGame / Twisted integration with fixed fps screen updating and fast as possible event processing.
#!/usr/bin/env python
from twisted.internet import reactor
from twisted.internet.task import LoopingCall, Cooperator
import pygame
import pygame.font
pygame.display.init()
pygame.font.init()
@habnabit
habnabit / BiblioSortingHelper.java
Created November 14, 2015 17:43
bibliocraft/mekanism compatibility
//
// Decompiled by Procyon v0.5.29
//
package jds.bibliocraft;
import net.minecraft.nbt.NBTBase;
import java.util.List;
import java.util.Collections;
import net.minecraft.util.StatCollector;
@habnabit
habnabit / tcp-proxy.py
Last active December 11, 2015 22:38 — forked from fiorix/tcp-proxy.py
import sys
from twisted.internet import defer, protocol, task, endpoints
from twisted.python import log
class ProxyClientProtocol(protocol.Protocol):
def connectionMade(self):
log.msg("Client: connected to peer")