Skip to content

Instantly share code, notes, and snippets.

Avatar
😬
Whoops!

Simon Westphahl westphahl

😬
Whoops!
View GitHub Profile
@westphahl
westphahl / 98-wireguard.network
Created Feb 22, 2020
Wireguard systemd config
View 98-wireguard.network
# /etc/systemd/network/98-wireguard.network
[Match]
Name = wg0
[Network]
Address = 10.200.200.1/32
[Route]
Gateway = 10.200.200.1
Destination = 10.200.200.0/24
@westphahl
westphahl / bug_demo.py
Last active Sep 9, 2019
Pika - Connection reset bug
View bug_demo.py
# Issue: https://github.com/pika/pika/issues/753
import logging
import pika
class Consumer:
def run(self, queue):
self.connection = connection = pika.BlockingConnection()
View assert_raises_ctx.py
class assert_raises(object):
def __init__(self, exc_type):
self.exc_type = exc_type
def __enter__(self):
pass
def __exit__(self, exc_type, exc_value, traceback):
assert self.exc_type == exc_type, "Expected exception not raised"
@westphahl
westphahl / signalblocker.py
Created Jul 22, 2015
context manager to block signals
View signalblocker.py
import time
import signal
class SignalBlocker:
def __init__(self, signal):
self._signal = signal
self._signal_blocked = False
View gist:12e1e8538368a67d5eda
epfd = epoll_create(1);
if (epfd == -1)
errExit("epoll_create");
ev.events = EPOLLIN;
ev.data.fd = sockfd;
epoll_ctl(epfd, EPOLL_CTL_ADD, sockfd, &ev);
ev.events = EPOLLIN;
ev.data.fd = STDIN_FILENO;
View .zshrc
# Evaluate prompt
setopt prompt_subst
# History config
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
# VIM key bindings
bindkey -v
# Key bindings for 'home' and 'end'
bindkey "^[[1~" beginning-of-line
@westphahl
westphahl / gist:4663221
Last active Dec 11, 2015
Testing SMTP with telnet
View gist:4663221
$ echo 'me@example.com' | base64
bWVAZXhhbXBsZS5jb20=
$ echo 'secret' | base64
c2VjcmV0
View gist:1297896
<!DOCTYPE html>
<html lang="de">
<head>
<title>{% block title %}{% endblock %}</title>
<meta charset="utf-8">
<link rel="stylesheet" href="{{ MEDIA_URL }}style/screen.css">
</head>
<body>
@westphahl
westphahl / gist:989000
Created May 24, 2011
Abfrage von Ankünften für Bahnhöfe (Q&D mit gevent/BeautifulSoup)
View gist:989000
#!/usr/bin/env python
import gevent
from gevent import monkey, GreenletExit
monkey.patch_all()
import sys
import urllib2
from datetime import datetime, date, time
from BeautifulSoup import BeautifulSoup
@westphahl
westphahl / gist:988332
Created May 24, 2011
Ankünfte und Verspätungen für Bahnhof
View gist:988332
#!/usr/bin/env python
import sys
import urllib2
from urllib2 import URLError
from BeautifulSoup import BeautifulSoup
URL = "http://reiseauskunft.bahn.de/bin/bhftafel.exe/dn?rt=1&input=%s&boardType=arr&time=actual&productsFilter=11110&start=yes"
if __name__ == '__main__':