Skip to content

Instantly share code, notes, and snippets.

Joost Rijneveld joostrijneveld

Block or report user

Report or block joostrijneveld

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
joostrijneveld /
Last active Sep 26, 2016
Scrape whatever was last played on 3FM (in the current hour)
#! /bin/env python
from bs4 import BeautifulSoup
import requests
URL = ""
r = requests.get(URL)
r.encoding = 'utf-8'
soup = BeautifulSoup(r.text, 'lxml')
joostrijneveld / keyedit.c.patch
Created Jun 23, 2016
Editing GPG's keyedit.c to allow unsigned UIDs
View keyedit.c.patch
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -1877,7 +1877,7 @@ static struct
{ "nrsign", cmdNOP, 0,
N_("sign selected user IDs with a non-revocable signature")},
{ "debug", cmdDEBUG, 0, NULL},
- { "adduid", cmdADDUID, KEYEDIT_NOT_SK | KEYEDIT_NEED_SK, N_("add a user ID")},
+ { "adduid", cmdADDUID, KEYEDIT_NOT_SK, N_("add a user ID")},
N_("add a photo ID")},
joostrijneveld /
Last active Dec 18, 2015
Splits a set of PDFs into two folders for TAs to check
for ta in ${TAS[@]}; do
mkdir -p $ta;
mkdir -p $REST
for f in pdfs/*.pdf
joostrijneveld /
Created May 9, 2015
Facebook autoresponder plugin for Poezio
from plugin import BasePlugin
class Plugin(BasePlugin):
def init(self):
self.api.add_event_handler('conversation_msg', self.on_msg)
self.api.add_event_handler('private_msg', self.on_msg)
def on_msg(self, msg, tab):
tab.command_say('[Automatic response] I stopped reading Facebook chat. Do try in some other way!')
joostrijneveld /
Created Apr 25, 2015
The partial solution as listed in the GCJ contest analysis for 2015-R1A-B-small seems to contain an infinite loop
from fractions import gcd
from itertools import count
def naive_get_barber_number(N):
customer = 1;
for T in count(1):
for barber in range(B):
if T % M[barber] == 0:
# at this point N = 0 and customer > 0..
joostrijneveld /
Created Mar 3, 2015
Shell script that watches the desktop for screenshots (OSX default format) and then copies them to a remote using scp, leaving the URL available on the clipboard.
#! /bin/bash
# change the paths on line 9 and 10 to match your specific configuration
/usr/local/bin/fswatch -0 ~/Desktop | while read -d "" event; \
do \
if [[ ${event} == ~/Desktop/Screen* ]] && [[ -e ${event} ]]; then
newname=`cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | head -c 16`
scp "${event}"$newname.png > /dev/null
echo -n "$newname.png" | pbcopy
joostrijneveld /
Created Oct 30, 2014
Homer Simpson using Turtle graphics, transcribed from
from turtle import *
def Homer():
joostrijneveld /
Created Oct 21, 2014
This file contains the solution to Problem 67 of Project Euler
#! /usr/bin/env python
with open('p067_triangle.txt') as f:
triangle = [[int(y) for y in x.strip().split(' ')] for x in f.readlines()]
upsidedown = list(reversed(triangle))
rowpairs = zip(upsidedown, upsidedown[1:])
for bot, top in rowpairs:
for i, x in enumerate(top):
top[i] = x + max(bot[i], bot[i+1])
joostrijneveld /
Last active Aug 29, 2015
Computes if/when it makes sense for the defending player in Risk to choose to throw only one die (if allowed).
#! /usr/bin/env python
def printmatrix(matrix):
""" source: """
s = [[str(e) for e in row] for row in [['['+str(n)+']' for n in range(1, 7)]]+matrix]
lens = [len(max(col, key=len)) for col in zip(*s)]
fmt = '\t'.join('{{:{}}}'.format(x) for x in lens)
table = ['['+str(n)+"]\t"+fmt.format(*row) for (row, n) in zip(s, range(0, len(s)+1))]
joostrijneveld /
Created May 20, 2014
Producing printable QR codes for persistent storage of GPG private keys
# Heavily depends on:
# libqrencode (
# paperkey (
# zbar (
# Producing the QR codes:
# Split over 4 codes to ensure the data per image is not too large.
gpg --export-secret-key KEYIDGOESHERE | paperkey --output-type raw | base64 > temp
split temp -n 4 IMG
for f in IMG*; do cat $f | qrencode -o $f.png; done
You can’t perform that action at this time.