Skip to content

Instantly share code, notes, and snippets.

View tspspi's full-sized avatar

tspspi

View GitHub Profile
@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 / 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 / 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 / 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 / updateTunnel.sh
Created November 1, 2019 10:22
Hurricane electric IPv6 tunnel endpoint dynamic IP update script
#!/bin/sh
# INTERFACE ... Is the public interface to the internet with assigned public IP
# GIFIF ....... The generic routing encapsulating interface
# POPIP ....... IP address of your assigned point of presence (tunnel endpoint)
# STATEFILE ... File that keeps the current "old" IP address
# LOGFILE ..... Logfile into which updates will be written
# TID ......... Tunnel ID (see tunnel configuration page)
# USERID ...... User ID (as registered)
# UPDATEKEY ... See advanced tab of tunnel configuration page
@tspspi
tspspi / nodered
Created February 29, 2020 13:19
FreeBSD NodeRED rc.d init script
#!/bin/sh
#
# PROVIDE: nodered
# REQUIRE: LOGIN
# KEYWORD: shutdown
# Configuration variables:
#
# Variable Default Description
# ====================================================================================================