Skip to content

Instantly share code, notes, and snippets.

View unverbraucht's full-sized avatar

Kevin Read unverbraucht

View GitHub Profile
@unverbraucht
unverbraucht / homematic-test.py
Created January 9, 2018 09:22
Quick sample to reproduce json escaping with pyhomematic. Please replace PASSWORD with a valid password of the CCU.
import time
import sys
import logging
from pyhomematic import HMConnection
logging.basicConfig(level=logging.DEBUG)
def systemcallback(src, *args):
print(src)
for arg in args:
public class AmazonKindlePaddingGuesser() {
/**
* Certain devices (I'm looking at you, Amazon) don't displace the root of the view
* hierarchy by the width of the status bar.
* See https://developer.amazon.com/public/solutions/devices/fire-tablets/specifications/03-ux-specifications and
* https://developer.amazon.com/appsandservices/solutions/devices/kindle-fire/specifications/01-device-and-feature-specifications for
* more info
* @param layout A layout that should get the right padding applied
* @return the width of the right padding in px
*/
@unverbraucht
unverbraucht / gist:118117ab66ac142f4eda
Last active January 24, 2023 18:16
Script for OpenWRT that adds delay, bandwidth limiting and packet loss to a Wi-Fi router connection. See http://kevin-read.com/post/86601925386/simulating-a-slow-network-connection-when-testing-on for details
#!/bin/sh
# The bandwidth to simulate, here about 56kilobit per second. This is layer 2 bandwidth, so TCP/UDP and IP overhead will apply
BW="56kbps"
# _Half_ the latency that we aim for. Since this applies to both the WAN port and Wi-Fi, the delay is applied twice, so this actually puts it at around 120+ms
LATENCY="60ms"
# Chance of packet loss. Also applied to both interfaces, so it is 1%.
LOSS="0.5%"
# The device name of your wifi device.
WIFI="wlan0"
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software