Skip to content

Instantly share code, notes, and snippets.

View tspspi's full-sized avatar

tspspi

View GitHub Profile
@tspspi
tspspi / UriMatcher.java
Last active October 25, 2018 10:08
UriMatcher like available on Android without Android dependencies
/*
Derived from Android Source Code
Source: platform_frameworks_base/core/java/android/content/UriMatcher.java
(see for example: https://android.googlesource.com/platform/frameworks/base/+/android-7.0.0_r33/core/java/android/content/UriMatcher.java )
Original License: Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0)
Original Copyright: Copyright (C) 2006 The Android Open Source Project
Modifications made:
To be useable outside the Android Framework android.net.Uri has been changed to
java.net.URL, reordered constant definitions towards the top of the class, no
@tspspi
tspspi / serdeshelper.h
Last active February 1, 2023 05:01
Floats in C: Simple binary serialization and deserialization of IEEE754 floats independent of architecture
#ifndef __is_included__F0CBD5F3_AC0B_4F2F_9137_1D3A922083A7
#define __is_included__F0CBD5F3_AC0B_4F2F_9137_1D3A922083A7 1
/*
Requires stdint.h and math.h
*/
/*
IEEE 754 Floats (Single):
All Bits 1+r+p 32 Bit
@tspspi
tspspi / download_image.sh
Created October 2, 2018 22:54
Periodically fetching webcam images (JPEG) with wget and cron
#!/bin/sh
# === BEGIN CONFIGURATION ===
# Capture source
url="https://www.wien.gv.at/webcam-inselcam/inselcam.jpeg"
# Capture destination and timestamp format
currentdate=`date +"%Y%m%d-%H%M%S"`
@tspspi
tspspi / owcrc.c
Created October 24, 2018 13:38
1-Wire CRC: A CLI tool to calculate or verify CRC for device ROM IDs
/*
Simply command line tool to calculate CRC
of device ROM IDs for dallas 1-wire devices
(or compatible)
*/
#include <stdio.h>
#include <stdint.h>
static uint8_t crcUpdate8(uint8_t crc, uint8_t data) {
uint8_t j;
@tspspi
tspspi / unfs3d
Created November 11, 2018 16:55
unfs3 rc.d startup script for FreeBSD
#!/bin/sh
# Startup script for unfs3 (http://unfs3.sourceforge.net) - inofficial script
#
# Use in rc.conf:
# unfs3d_enable="YES"
#
# One can override the location of the exports file via
# unfs3d_exports="/etc/exports"
#
@tspspi
tspspi / usbmodeswitch.sh
Created November 21, 2018 10:55
FreeBSD rc.d init script for sysutils/usb_modeswitch with Huawei Modem
#!/bin/sh
# PROVIDE: usbmodeswitch
# REQUIRE: FILESYSTEMS
# BEFORE: ppp
# usb modeswitch script for huawei modem
# with sysutils/usb_modeswitch
. /etc/rc.subr
@tspspi
tspspi / krb5renew.sh
Created March 8, 2019 10:41
Kerberos ticket renewal for all cache files on a machine
#!/bin/sh
# This script automatically renews renewable tickets
# of all users on a given machine (to prevent timeout
# for long running tasks of logged in users).
# It also removes expires tickets from cache files
: ${RENEWAL_THREASHOLD:=3600}
: ${VERBOSE:=0}
: ${LOGFILE:=/var/log/krb5renew.log}
@tspspi
tspspi / howto.md
Last active March 10, 2019 14:22
How to use avr-gcc and avrdude with Arduino Pro-Mini on FreeBSD

How to use AVR-GCC and avrdude with Arduino pro-mini on FreeBSD

Required packages / ports

devel/avr-gcc
devel/avr-binutils
devel/avrdude
@tspspi
tspspi / Makefile
Created October 8, 2019 08:12
Simple JPEG image I/O example with libjpeg (nearly no proper error handling)
main: main.c filter_greyscale.c imagefile.c simple_imageio.h
clang -DDEBUG -o main -Wall -ansi -std=c99 -pedantic -Werror main.c filter_greyscale.c imagefile.c -ljpeg
@tspspi
tspspi / SimplePiezoBoardTest.cpp
Created October 14, 2019 13:21
3D printer piezo board leveling Arduino test sketch
/*
Simple test program for 3D printer piezo
bed leveling adapter board described at
https://www.tspi.at/2019/09/11/piezobedlevel.html
(using Arduino IDE and libraries).
This does not provide any I2C connectivity, etc.
and just periodically reads analog samples, dumps
them to the serial port and does some moving average
filtering (as well as using a inductive probe as