Skip to content

Instantly share code, notes, and snippets.

View wolph's full-sized avatar

Rick van Hattem wolph

View GitHub Profile
@wolph
wolph / main.py
Last active January 18, 2018 20:16 — forked from jorenham/main.py
Best exception handling in Python
import sys
import webbrowser
def main():
return 42/0
def excepthook(type_, value, traceback):
webbrowser.open_new_tab('https://stackoverflow.com/search?q=[python] {} {}'.format(type_, value))
@wolph
wolph / .zshrc
Last active December 10, 2017 02:30
Tmux start script which automatically reconnects or starts a new session
function auto_activate(){
name=$(basename "$PWD")
project_dir="$HOME/workspace/$name"
env_dir="$HOME/envs/$name"
if [ -d "$env_dir" ]; then
workon "$name"
fi
}
auto_activate
@wolph
wolph / bugzilla.gs
Created November 5, 2015 12:42
Bugzilla fetcher for google sheets
/**
* @fileoverview Provides the custom function BUGZILLA_TITLE and
* the helper functions that it uses.
*/
/**
* Runs when the add-on is installed.
*/
function onInstall() {
onOpen();
@wolph
wolph / django_admin_edit_fields.js
Last active December 2, 2016 00:02
Firefox console script to extract `fields` and `fieldset` definitions from django admin form/edit pages
console.clear();
function getFields(fields, parent){
var rows = [" fields = ("];
$(fields, parent).each(function(){
var regex = /field-([^ ]+)/g;
var columns = [];
while(match = regex.exec(this.className)){
columns.push(match[1]);
}
@wolph
wolph / __init__.py
Last active October 13, 2016 23:40
RFXtrx
# -*- coding: utf-8 -*-
#
# This file is a plugin for EventGhost.
# Copyright (C) 2012 Walter Kraembring <krambriw>.
#
# ALL RIGHTS RESERVED. The development of this software is based on information
# provided by RFXCOM and is protected under Netherlands Copyright Laws and
# Treaties and shall be subject to the exclusive jurisdiction of the Netherlands
# Courts.
# This pluginís source code and other versions eventually based on it may be
@wolph
wolph / computer_futures_usability.user.js
Last active July 19, 2016 09:25
Computer futures usability enhancer
// ==UserScript==
// @name Computer Futures Worksheet Usability Enhancer
// @namespace http://wol.ph/
// @description try to take over the world!
// @author Wolph
// @match https://worksheets.computerfutures.com/index.php?*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
@wolph
wolph / computer_futures_worksheets.user.js
Last active July 19, 2016 09:23
Due to either incompetence or unwillingness of computer futures it seems impossible to add worksheet hours in a normal way, this script makes it easier by making the hours pasteable. Just paste them as 1 line per day and start time + end time split by space. Note, it only supports 1 start/stop time per day currently.
// ==UserScript==
// @name Computer Futures Worksheet Filler
// @namespace http://wol.ph/
// @version 1.1
// @description
// @match https://worksheets.computerfutures.com/index.php?dir=timesheet*
// @match http://worksheets.computerfutures.com/index.php?dir=timesheet*
// @copyright 2015, Wolph
// @run-at document-end
// ==/UserScript==
@wolph
wolph / to_images.sh
Created March 9, 2014 16:59
Script to automatically convert directories to sparse images on OS X. Since I have noticed a pretty obvious slowdown in OS X when having lots (many millions) of files on the filesystem, this has given me quite a significant speedup.
#!/bin/bash -e
function image_all(){
echo "Processing $1"
test -d "$1" || return 1
cd "$1"
for i in *; do
if [ "$i" == "utils" ]; then
continue
@wolph
wolph / y_combinator_quicksort.py
Created May 30, 2016 21:06
Implementing the Quick sort algorithm using the Y Combinator
Y = lambda f: lambda *args: f(Y(f))(*args)
quicksort = Y(lambda f:
lambda x: (
f([item for item in x if item < x[0]])
+ [y for y in x if x[0] == y]
+ f([item for item in x if item > x[0]])
) if x else [])
@wolph
wolph / proxy.py
Created July 14, 2013 16:14
Gevent based proxy server for non http compliant webserver
from gevent.local import local
from gevent.pywsgi import WSGIServer
from gevent import monkey
import socket
import pprint
import sys
def application(environ, start_response):
url = environ['PATH_INFO']