Skip to content

Instantly share code, notes, and snippets.

View erikvanzijst's full-sized avatar

Erik van Zijst erikvanzijst

View GitHub Profile
@erikvanzijst
erikvanzijst / gist:2874887
Created June 5, 2012 13:13
lock: fixed race condition in file lock acquisition
# HG changeset patch
# User Erik van Zijst <erik.van.zijst@gmail.com>
# Date 1315554086 -36000
# Branch stable
# Node ID ec4dafac91fc69903dea3ac3f77fdaf11de84a00
# Parent 01cdfba22f0c1bfdc21feeb95b4d5d36219bafdd
lock: fixed race condition in file lock acquisition
This fixes a race condition in lock.trylock() where, if you try to acquire a
lock that is held by someone else just at the moment at which that other party
@erikvanzijst
erikvanzijst / tsdb-import-sample
Created July 27, 2012 08:03
opentsdb import file
test.erik3 1343033863 1 method=GET service=web status=302 view=proxy-login
test.erik3 1343033863 22 method=GET service=gitweb status=200
test.erik3 1343033864 3 method=GET service=api status=304 view=.api.v10.resource.NonCachingResource
test.erik3 1343033864 1 method=GET service=web status=404 view=wiki-path
test.erik3 1343033864 1 method=GET service=web status=200 view=user
test.erik3 1343033864 6 method=GET service=web status=301 view=.bb.views.site_info
test.erik3 1343033864 2 method=GET service=web status=301 view=filebrowse-raw
test.erik3 1343033864 6 method=GET service=web status=302 view=.bb.views.site_info
test.erik3 1343033864 2 method=GET service=web status=200 view=source-node
test.erik3 1343033864 2 method=GET service=web status=200 view=filebrowse-raw
1343033864 23
1343033865 305
1343033866 304
1343033867 294
1343033868 295
1343033869 290
1343033870 308
1343033871 308
1343033872 301
1343033873 263
import requests, re, sys
from urllib import urlencode
refs = [(ref[0] == '^' and 'exclude' or 'include', re.sub(r'^\^', '', ref))
for ref in sys.argv[2:]]
url = ('/2.0/repositories/%s/commits?%s' % (sys.argv[1], urlencode(refs)))
while url:
doc = requests.get('https://api.bitbucket.org' + url).json()
for cset in doc['values']:
@erikvanzijst
erikvanzijst / gist:8851082
Created February 6, 2014 19:35
Automate Bitbucket issue tracker exports
$ # initiate export, will return 202:
$ curl -u evzijst:passwd -X POST -v https://api.bitbucket.org/1.0/repositories/evzijst/interruptingcow/issues/export
[...]
< HTTP/1.1 202 ACCEPTED
[...]
$ # poll for status updates:
$ curl -u evzijst:passwd -X GET https://api.bitbucket.org/1.0/repositories/evzijst/interruptingcow/issues/export
{"status": "ACCEPTED", "count": "1", "total": "4", "phase": "Issues", "pct": "25"}
$ # until it's ready:
$ curl -u evzijst:passwd -X GET https://api.bitbucket.org/1.0/repositories/evzijst/interruptingcow/issues/export
### Keybase proof
I hereby claim:
* I am erikvanzijst on github.
* I am erikvanzijst (https://keybase.io/erikvanzijst) on keybase.
* I have a public key whose fingerprint is E96D DAAB 1680 4D86 EFA2 A08A 4539 ACC7 B26D 1005
To claim this, I am signing this object:
@erikvanzijst
erikvanzijst / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@erikvanzijst
erikvanzijst / knightrider.py
Last active April 5, 2023 18:01
Knight Rider LEDs on a Raspberry Pi
# The code accompanying https://www.youtube.com/watch?v=PsVcLdAyAcU
import atexit
import time
from gpiozero import LEDBoard
leds = LEDBoard(2, 3, 4, 17, 27, 22, 10, 9)
i = 0
atexit.register(leds.close)
@erikvanzijst
erikvanzijst / shift.py
Created May 6, 2019 16:52
16 bit serial to parallel GPIO interface
#!/usr/bin/env python3
#
# Code accompanying https://www.youtube.com/watch?v=SnPh4zwQkVI
import atexit
from time import sleep
from gpiozero import DigitalOutputDevice
def _pulse(pin):
pin.value = 1
@erikvanzijst
erikvanzijst / marquee_banner.py
Last active September 1, 2019 16:51
Linux console fonts to Python
#!/usr/bin/env python3
#
# Compiles a text string into the binary format used by the circuit from
# https://www.youtube.com/watch?v=7vDrLuH4eWA
import sys
from itertools import islice
# Generated with psf2python.py
charset = {'�': ['-######-', '##----##', '#--##--#', '####--##', '###--###',