Skip to content

Instantly share code, notes, and snippets.

Rick van Hattem WoLpH

Block or report user

Report or block WoLpH

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
View __init__.py
# -*- 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 / django_admin_edit_fields.js
Last active Dec 2, 2016
Firefox console script to extract `fields` and `fieldset` definitions from django admin form/edit pages
View django_admin_edit_fields.js
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 / computer_futures_usability.user.js
Last active Jul 19, 2016
Computer futures usability enhancer
View computer_futures_usability.user.js
// ==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 / y_combinator_quicksort.py
Created May 30, 2016
Implementing the Quick sort algorithm using the Y Combinator
View y_combinator_quicksort.py
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 / bugzilla.gs
Created Nov 5, 2015
Bugzilla fetcher for google sheets
View bugzilla.gs
/**
* @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 / warning_decorator.py
Created Oct 5, 2015
Decorator to ignore a specific number of Python warnings
View warning_decorator.py
import warnings
import functools
def ignore_warning(warning, count=None):
def _ignore_warning(function):
@functools.wraps(function)
def __ignore_warning(*args, **kwargs):
with warnings.catch_warnings(record=True) as ws:
# Catch all warnings of this type
@WoLpH
WoLpH / replace.zsh
Created Sep 23, 2015
Regular expression (Perl pie) to search and replace Django STATIC_URL with the static (from staticfiles) templatetag
View replace.zsh
perl -pi -e 's/"\{\{\s*STATIC_URL\s*\}\}\/?([^"]+)"/"{% static \x27$1\x27 %}"/g' templates/***/*.html
@WoLpH
WoLpH / eventghost_domoticz.py
Created Sep 13, 2015
Example script to access domoticz from eventghost, I'll make this in a plugin somewhere in the future :)
View eventghost_domoticz.py
LIGHT_ID = 123
LIGHT_LEVEL = 40
DOMOTICZ_URL = 'http://domoticz/json.htm?'
def fetch(**kwargs):
import json
import urllib
params = urllib.urlencode(kwargs.items())
url = DOMOTICZ_URL + params
@WoLpH
WoLpH / quicksort_y_combinator_lambda_calculus.py
Created Aug 19, 2015
Quicksort using the Y Combinator (lambda calculus) in pure Python
View quicksort_y_combinator_lambda_calculus.py
# Quicksort using the Y Combinator (lambda calculus) in pure Python
>>> 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 / computer_futures_worksheets.user.js
Last active Jul 19, 2016
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.
View computer_futures_worksheets.user.js
// ==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==
You can’t perform that action at this time.