Skip to content

Instantly share code, notes, and snippets.

View KarstenB's full-sized avatar

Karsten Becker KarstenB

  • Siemens AG
  • Berlin
  • 08:06 (UTC +02:00)
View GitHub Profile
@KarstenB
KarstenB / PollingSettings.json
Created April 22, 2020 16:53
My PollingSettings.json
{
"homieServer": "tcp://192.168.188.250:1883",
"homieUser": "",
"homiePassword": "",
"homieDeviceName": "daikin-heatingunit",
"daikinIP": "192.168.188.200",
"daikinPort": 80,
"properties": [
{
"path": "0/DateTime",
@KarstenB
KarstenB / BeanPropertyModel.java
Created April 13, 2020 07:51
A simple JTable Model that uses Bean Introspection for everything
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@KarstenB
KarstenB / Proxy media cron job.sh
Last active August 29, 2015 14:09
This script converts a directory full of videos, images or audio into smaller versions that can be synced into the cloud without occupying terabytes of space.
#!/bin/bash
#Change this to the full directory path that contains the source media
SOURCE_MEDIA_DIR="/Video_Library_nas"
#Change this directory to the full directory path that will contain the proxy media
#As those files are rather small, this could be a cloud directory
PROXY_MEDIA_DIR="/Video_Library_proxy"
#Images will be resized to be of at most this width
IMG_WIDTH=1024
#Videos will be resized to be at most this wide
VIDEO_WIDTH=450
@KarstenB
KarstenB / Shift Right Logical (SRL) for BigInteger
Created July 13, 2014 18:41
This allows a BigInteger to be logically shifted right (filling with 0)
public static BigInteger srl(BigInteger l, int width, int shiftBy) {
if (l.signum() >= 0)
return l.shiftRight(shiftBy);
BigInteger opener = BigInteger.ONE.shiftLeft(width + 1);
BigInteger opened = l.subtract(opener);
BigInteger mask = opener.subtract(BigInteger.ONE).shiftRight(shiftBy + 1);
BigInteger res = opened.shiftRight(shiftBy).and(mask);
return res;
}