Skip to content

Instantly share code, notes, and snippets.

View jaapz's full-sized avatar

Jaap Broekhuizen jaapz

View GitHub Profile
/KFM5KAIFA-METER
1-3:0.2.8(42)
0-0:1.0.0(160525195716S)
0-0:96.1.1(4530303235303030303539393336303136)
1-0:1.8.1(000001.117*kWh)
1-0:1.8.2(000004.020*kWh)
1-0:2.8.1(000000.000*kWh)
1-0:2.8.2(000000.000*kWh)
0-0:96.14.0(0002)
1-0:1.7.0(00.341*kW)

Keybase proof

I hereby claim:

  • I am jaapz on github.
  • I am jaapz (https://keybase.io/jaapz) on keybase.
  • I have a public key ASDhauBBIob-8oo_8Ngge8gvF2lTyXaGQhQUyspuRpcQ4go

To claim this, I am signing this object:

@jaapz
jaapz / test.py
Last active January 2, 2016 14:39
Monkeypatch builtins for use in py.tests
import __builtin__
def test_raw_input(monkeypatch):
""" Get user input without actually having a user type letters using monkeypatch """
def mock_raw_input(*args, **kwargs):
""" Act like someone just typed 'yolo'. """
return 'yolo';
monkeypatch.setattr(__builtin__, 'raw_input', mock_raw_input)
@jaapz
jaapz / gist:8252864
Created January 4, 2014 07:56
correct docstrings
"""
User interface class, responsible for console input and output
"""
class Ui:
def __init__(self):
pass
class Ui:
"""
User interface class, responsible for console input and output
@jaapz
jaapz / events.py
Last active December 31, 2015 00:59
from axel import Event
error = Event(asynch=True)
@jaapz
jaapz / gist:7822021
Last active December 30, 2015 11:19
class Compri(object):
# De plek waarop de naam van het veld in deze lijst staat komt overeen met de plek waarop het in het 'parts' text staat. Dus
# slotactie staat op positie 0 in parts, perstijd1 op positie 1 in parts, etc.
_name_to_number_map = ['slotactie', 'perstijd1', 'tijdstemp1', ...]
def __init__(self, parts):
self.fill_with_parts_data(parts)
def fill_with_parts_data(self, parts):
""" Fills fields on this class with the data in parts.
@jaapz
jaapz / gist:7563366
Last active December 28, 2015 21:19
calculateSeriesAverage: function() {
var total, firstHour, lastHour, dit, models;
dit = this;
total = 0;
firstTimestamp = this.first().get('timestamp');
lastTimestamp = this.last().get('timestamp');
this.each(function(model, i) {
var width, height, opp, next;
@jaapz
jaapz / destructuring.js
Last active November 12, 2015 09:50
object destructuring in es6
// simple destructuring without default
let obj = {bananaphone: 'hello?'};
let {bananaphone} = obj;
console.log(bananaphone); // hello?
// destructuring with default
let {missingkey = 'hey?'} = obj;
console.log(missingkey); // hey?
@jaapz
jaapz / cb-exit.py
Last active November 1, 2015 23:00
cb-exit for crunchbang with jessie repo's
#!/usr/bin/env python
# Replace the old /usr/bin/cb-exit with this one.
import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass
void update_libunity_quicklist () {
var launcher = Unity.LauncherEntry.get_for_desktop_id (app_launcher);
var quicklist = new Dbusmenu.Menuitem ();
foreach (var plug in plugs) {
var item = new Dbusmenu.Menuitem ();
item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, plug["title"]);