Skip to content

Instantly share code, notes, and snippets.

View wuub's full-sized avatar

Wojciech Bederski wuub

View GitHub Profile
@wuub
wuub / money.py
Created March 28, 2017 08:05 — forked from tauzen/money.py
Python DDD - Value Object idea. Immutable attributes, methods, structural equality.
from collections import namedtuple
class Money(namedtuple('Money', ['amount', 'currency'])):
def add(self, amount):
return Money(self.amount + amount, self.currency)
m = Money(20, 'USD')
print(m)
# Money(amount=20, currency='USD')
@wuub
wuub / 10-trackpoint.rules
Created April 17, 2016 18:54
Thinkpad trackpoint
ACTION=="add",SUBSYSTEM=="input",ATTR{name}=="TPPS/2 IBM TrackPoint",ATTR{device/sensitivity}="255",ATTR{device/speed}="255",ATTR{device/inertia}="6"
@wuub
wuub / dockmux
Last active January 13, 2016 16:19
$ dockmux $(docker ps -q)
#!/bin/bash
if [[ -e ~/.dockmux/$1 ]]; then
CONTAINERS=$(cat ~/.dockmux/$1)
SESSION_NAME=$1
else
CONTAINERS="$@"
SESSION_NAME=dockmux
fi
@wuub
wuub / totp.py
Created November 10, 2015 14:40
hacky script to generate terminal qrcodes for totp auth's from csv file
import pyqrcode
import csv
template = "otpauth://totp/{name}?secret={secret}"
with open("keys.csv") as f:
for k in csv.DictReader(f):
qr = pyqrcode.create(template.format(secret=k['secret'], name=k['email']))
print(k['email'])
print(qr.terminal(quiet_zone=1))
raw_input("next>>> ")
@wuub
wuub / main.go
Created October 8, 2015 08:42
Find out which services generate workload in your consul raft log
package main
import (
"fmt"
"github.com/hashicorp/raft"
"github.com/hashicorp/raft-boltdb"
"regexp"
)
func main() {

Keybase proof

I hereby claim:

  • I am wuub on github.
  • I am wuub (https://keybase.io/wuub) on keybase.
  • I have a public key whose fingerprint is 35CB 8060 6617 4BC9 BD6F 81B7 1B00 6E8F 911A 6A2B

To claim this, I am signing this object:

@wuub
wuub / ds1624.py
Created August 3, 2014 15:10
Micropython DS1624 temperature read in continous mode with maximum (0.0625°C) resolution
import pyb
ACCESS_CONFIG = 0xAC
READ_TEMPERATURE = 0xAA
START_CONVERT = 0xEE
STOP_CONVERT = 0x22
LSB_RESOLUTION = 2 ** (-4)
LSB_BITS = 4
@wuub
wuub / guni.py
Created June 9, 2014 18:49
gunicorn configurable app
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import multiprocessing
from itertools import chain
from gunicorn import util
from gunicorn.config import Config
from gunicorn.app.base import Application
@wuub
wuub / gtfo.py
Last active August 29, 2015 13:56
Drop into ~/.config/sublime-text-3/Packages/User + modify in_build_dir(view) acoordingly
import sublime, sublime_plugin
BUILD_COLOR_SCHEME = "Packages/Color Scheme - Default/Twilight.tmTheme"
def in_build_dir(view):
if not view or not view.file_name():
return False
return "/build/" in view.file_name()
@wuub
wuub / irapp.py
Last active December 26, 2015 13:39
Flask like application for IR / LIRC programming
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import with_statement, division, absolute_import, print_function
import lirc
import tempfile
from collections import namedtuple
import time
import atexit