Skip to content

Instantly share code, notes, and snippets.

View erikvanzijst's full-sized avatar

Erik van Zijst erikvanzijst

View GitHub Profile
@erikvanzijst
erikvanzijst / mp.py
Last active March 13, 2023 08:21
Parallel web crawler
#!/usr/bin/env python3
# Simple multi-processing web crawler, following all a.href's that end in a '/'.
import os
import traceback
from itertools import chain
from multiprocessing import Pool
from time import time
from urllib.parse import urljoin
from bs4 import BeautifulSoup
@erikvanzijst
erikvanzijst / parsexml.txt
Last active February 21, 2023 22:05
xmltodict
In [1]: import xmltodict
In [14]: print(data)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<server>
<response>
<status>ok</status>
<actions>
<action>
<subsystem>hourChooser</subsystem>
@erikvanzijst
erikvanzijst / cloneall.py
Last active July 1, 2020 18:56
Clone all Bitbucket Mercurial repos
#!/usr/bin/env python3
import argparse
import os
import subprocess
# install deps:
# $ pip install requests mercurial
import requests
# Create an OAuth Consumer with Account and Repository Read permission:
@erikvanzijst
erikvanzijst / image2bin.py
Created October 25, 2019 00:07
Scramble video game level compiler
#!/usr/bin/env python3
import argparse
import sys
from PIL import Image
if __name__ == '__main__':
parser = argparse.ArgumentParser(
sys.argv[0], description='Convert image to binary.')
parser.add_argument('file', type=argparse.FileType('rb'))
@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 = {'�': ['-######-', '##----##', '#--##--#', '####--##', '###--###',
@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 / 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 / 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
### 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 / 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