Skip to content

Instantly share code, notes, and snippets.

View dbrgn's full-sized avatar

Danilo Bargen dbrgn

View GitHub Profile
@pytest.fixture(scope='session')
def server(request):
"""
Fixture that provides a bottle server running in a background thread.
"""
class StoppableServer(bottle.ServerAdapter):
server = None
def run(self, handler):
@dbrgn
dbrgn / mixins.py
Last active September 13, 2018 20:44
Moved to https://github.com/dbrgn/drf-dynamic-fields
$ python -c 'import random; import string; print "".join([random.SystemRandom().choice(string.digits + string.letters + string.punctuation) for i in range(100)])'

Keybase proof

I hereby claim:

  • I am dbrgn on github.
  • I am dbrgn (https://keybase.io/dbrgn) on keybase.
  • I have a public key whose fingerprint is EA45 6E8B AF01 0942 9583 EED8 3578 F667 F2F3 A5FA

To claim this, I am signing this object:

"""
Small program to show the acceleration of the x and y axis on the LEDs. The
more you accelerate the board, the more LEDs light up.
An easy way to test this is to hold the board vertically. This causes the
gravity to "pull" on the accelerator – the LEDs light up.
"""
import pyb
import math
@dbrgn
dbrgn / 1_before.py
Last active August 29, 2015 14:00
before / after prefetch
In [1]: from apps.swid.models import Tag
In [2]: s = Session.objects.latest()
QUERY = u'SELECT "sessions"."id", "sessions"."time", "sessions"."connection", "sessions"."identity", "sessions"."device", "sessions"."rec" FROM "sessions" ORDER BY "sessions"."time" DESC LIMIT 1' - PARAMS = ()
Execution time: 0.004259s [Database: default]
In [3]: tags = Tag.get_installed_tags_with_time(s)
QUERY = u'SELECT "devices"."id", "devices"."value", "devices"."description", "devices"."product", "devices"."created", "devices"."trusted" FROM "devices" WHERE "devices"."id" = %s ' - PARAMS = (20,)
@dbrgn
dbrgn / gist:05c18609a8e744866b62
Created April 29, 2014 21:50
open-aid nameservers
dns6.pointhq.com
dns7.pointhq.com
dns2.pointhq.com
{
"metadata": {
"name": "aes"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@dbrgn
dbrgn / gist:9210334
Created February 25, 2014 14:53
Parse env vars from supervisor config file
cat /etc/supervisor/conf.d/radar.conf | grep environment | uniq | sed 's/environment=/export /' | sed 's/;/\nexport /g' | sed 's/%%/%/g' | sed 's/\$/\\\$/g' | head -n -1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.