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)
@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?

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 / dmenu-4.5-xft-width-xy.diff
Last active August 29, 2015 14:13
dmenu 4.5 patch containing xft, x and y positioning and window width
diff --git a/config.mk b/config.mk
index 92a5e63..9cff5db 100644
--- a/config.mk
+++ b/config.mk
@@ -12,9 +12,13 @@ X11LIB = /usr/X11R6/lib
XINERAMALIBS = -lXinerama
XINERAMAFLAGS = -DXINERAMA
+# Xft, comment if you don't want it
+XFTINC = -I/usr/include/freetype2
@jaapz
jaapz / breaks.rs
Last active August 29, 2015 14:12
Why does this happen?
struct Record {
name: String,
message: String,
}
// Let's say `record` is an instance of Record, with strings in name and message.
// This will work correctly:
let message =
@jaapz
jaapz / sorting.py
Last active August 29, 2015 14:11
sorting a list using itemgetter
from operator import itemgetter
mylist = [
["Some", "Data", "30.0", 12.10],
["Foo", "Bar", "29.5", 90.00],
["Fizz", "Buzz", "29", 13.12]
]
# Sorting using a field that already has a nice sortable type (for example, a float).
my_sorted_list_4 = sorted(mylist, key=itemgetter(3))
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
@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
@jaapz
jaapz / todo.js
Last active August 29, 2015 14:01 — forked from anonymous/todo.js
$(function() {
"use strict";
// Model. Als toggle gecalled word zal done geinvert worden. Ook word de titel aangepast zodat de view opnieuw rendert.
var Todo = Backbone.Model.extend({
defaults: {
title: "Something to remember",
done: false
},
@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)