Skip to content

Instantly share code, notes, and snippets.

View bwaldvogel's full-sized avatar

Benedikt Waldvogel bwaldvogel

View GitHub Profile
@bwaldvogel
bwaldvogel / BeanSerializerFactoryWithGlobalIncludeDefaults.java
Created August 27, 2018 15:25
Workaround for Jackson’s global inclusion behaviour change in 2.8.3
import java.lang.reflect.Field;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.cfg.PackageVersion;
import com.fasterxml.jackson.databind.cfg.SerializerFactoryConfig;
import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
import com.fasterxml.jackson.databind.ser.PropertyBuilder;
import com.fasterxml.jackson.databind.ser.SerializerFactory;
@oskar456
oskar456 / bh1750.py
Created June 20, 2015 15:26
BH1750 python library
#!/usr/bin/python2
# vim: expandtab ts=4 sw=4
# Inspired by http://www.raspberrypi-spy.co.uk/2015/03/bh1750fvi-i2c-digital-light-intensity-sensor/
import smbus
import time
class BH1750():
""" Implement BH1750 communication. """
@umidjons
umidjons / row-number-per-group.sql
Created November 27, 2013 13:24
MySQL: Row number per group
SELECT
t.`code`,
t.title,
t.price_total,
(
CASE `code`
WHEN @curCode THEN
@curRow := @curRow + 1
ELSE
@curRow := 1
@temporaer
temporaer / random_palette.py
Created January 31, 2013 12:39
Create a random palette in LAB space and convert to RGB. For easy use as a infinite colormap in matplotlib.
# Create a random palette in LAB space and convert to RGB.
# For easy use as a infinite colormap in matplotlib.
# After an idea from @amueller and
# http://stackoverflow.com/questions/10254207/color-and-line-writing-using-matplotlib
import numpy as np
from colormath.color_objects import LabColor
def get_random_color(seed=3):
@uarun
uarun / filetype.vim
Created August 3, 2011 19:32
Gradle syntax highlighting in vim
# ~/.vim/filetype.vim
au BufNewFile,BufRead *.gradle setf groovy