Skip to content

Instantly share code, notes, and snippets.

View wolph's full-sized avatar

Rick van Hattem wolph

View GitHub Profile
@wolph
wolph / assign_to_me.user.js
Created April 15, 2015 13:29
Assign bug to me in Bugzilla
// ==UserScript==
// @name Assign to me (Bugzilla)
// @namespace http://wol.ph/
// @version 1.0
// @description
// @match http://bugzilla.3xo.eu/show_bug.cgi?id=*
// @copyright 2015, Wolph
// ==/UserScript==
var assigned_to_field = document.getElementsByName('assigned_to')[0];
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Threading.Tasks;
using System.Net.Sockets;
using System.Threading;
using System.Runtime.InteropServices;
@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 / quicksort_y_combinator_lambda_calculus.py
Created August 19, 2015 11:44
Quicksort using the Y Combinator (lambda calculus) in pure Python
# 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 / eventghost_domoticz.py
Created September 13, 2015 17:47
Example script to access domoticz from eventghost, I'll make this in a plugin somewhere in the future :)
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 / replace.zsh
Created September 23, 2015 10:18
Regular expression (Perl pie) to search and replace Django STATIC_URL with the static (from staticfiles) templatetag
perl -pi -e 's/"\{\{\s*STATIC_URL\s*\}\}\/?([^"]+)"/"{% static \x27$1\x27 %}"/g' templates/***/*.html
@wolph
wolph / warning_decorator.py
Created October 5, 2015 09:08
Decorator to ignore a specific number of Python warnings
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 / 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 / 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 / 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';