Skip to content

Instantly share code, notes, and snippets.

View hynek's full-sized avatar
🎯
squeezed between dealing post-travel & pre-travel; pls be patient

Hynek Schlawack hynek

🎯
squeezed between dealing post-travel & pre-travel; pls be patient
View GitHub Profile
@hynek
hynek / gist:1266898
Created October 6, 2011 09:01
A decorator for Django tests that logs you in before running a test.
def login_first(test):
"""Decorator offering convenience login for tests that require it."""
def _login(self):
self.client.login(
username='testusername',
password='testpassword')
return test(self)
return _login
@hynek
hynek / gist:2965846
Created June 21, 2012 13:51
Match indentation of second argument with first argument if the first one on the same line like the opening parenthesis - originally by Steve Losh
--- /Users/hynek/Downloads/python.vim 2012-06-21 15:44:18.000000000 +0200
+++ python.vim 2012-06-21 15:38:52.000000000 +0200
@@ -119,11 +119,7 @@
return indent(parlnum) + &shiftwidth
endif
else
- if closing_paren
- return parcol - 1
- else
- return parcol
@hynek
hynek / builddeb-graphite.sh
Last active June 23, 2019 18:24
A quick and dirty way to package Graphite using fpm and a custom target. Please read the instructions inside, it was never meant to be shared and is mostly tailored for my own needs. One of them being debian/Ubuntu. However fpm supports many, many other package managers so the script can be easily adopted. The resulting package does NOT contain …
#!/bin/bash
# A quick and dirty way to package Graphite using fpm and a custom target.
# (c) by Hynek Schlawack, MIT licence, USE AT OWN RISK.
# EXECUTE DIRECTLY ON A BUILDBOT -- IT USES REAL PATHS SINCE GRAPHITE IS PRICKY
# Necessary Ubuntu dependency for building: build-essential, libcairo-dev and
# fpm which isn't packaged unfortunately: https://github.com/jordansissel/fpm
from OpenSSL import SSL
from twisted.internet import ssl
class TLSContextWithChainFileFactory(ssl.DefaultOpenSSLContextFactory):
"""
A SSLContext factory for TLS only and C{certificateFileName} is set as the
chain file. Add all chain files that lead from the CA to your certificate.
"""
def cacheContext(self):
@hynek
hynek / l.py
Created April 25, 2013 21:45 — forked from dstufft/l.py
def foo():
"""
... Doc string goes here
"""
pass
>>> def f(x,*,y,z):
... print(x, y, z)
...
>>> f(1,2,3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() takes 1 positional argument but 3 were given
class Foo:
_answer = 42
@property
def answer(self):
print('getting!')
return self._answer
@answer.setter
def answer(self, new_answer):
print('setting!')
$ ffind '*anypattern*'
Traceback (most recent call last):
File "/usr/local/bin/ffind", line 843, in <module>
main()
File "/usr/local/bin/ffind", line 819, in main
if options.literal or not is_re(query):
File "/usr/local/bin/ffind", line 702, in is_re
return not all(c.lower() in string.letters + '_-' for c in s)
File "/usr/local/bin/ffind", line 702, in <genexpr>
return not all(c.lower() in string.letters + '_-' for c in s)
@hynek
hynek / gist:6972160
Last active December 25, 2015 11:49
A Marked 2 custom processor that renders reST files with rst2html and leaves the rest be.
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import subprocess
ext = os.environ['MARKED_EXT'].lower()
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I have a new GPG key: 7F69F181 with fingerprint C2A0 4F8 6 AC E2 8 ADC F817 DBB 7 AE 25 3 622 7F69 F18 1. If you've signed the old one (C6197B3C, used to sign this message), I would appreciate a signature on the new one too.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - http://gpgtools.org
iF4EAREIAAYFAlKUh/oACgkQAuAjRMYZezy5WwD/dAtYqosqWprtSGEKTRL59wJ8
nRmxcEiMTljHVhbs6y4BAMB9x7iHOQUy/uKpHiGNgIuWCpoB/a9Z7lBUXuPRulNY