Skip to content

Instantly share code, notes, and snippets.

View SijmenHuizenga's full-sized avatar
❤️
line by line

Sijmen SijmenHuizenga

❤️
line by line
View GitHub Profile
@SijmenHuizenga
SijmenHuizenga / main.go
Created April 8, 2020 22:57
Zip a directory in Golang with error handling, ignoring symlinks and file checking
func zipDirectory(zipfilename string) error {
outFile, err := os.Create(zipfilename)
if err != nil {
return err
}
w := zip.NewWriter(outFile)
if err := addFilesToZip(w, zipfilename, ""); err != nil {
_ = outFile.Close()
### Keybase proof
I hereby claim:
* I am sijmenhuizenga on github.
* I am sijmenhuizenga (https://keybase.io/sijmenhuizenga) on keybase.
* I have a public key ASAIdPnfNrc0hwu4CMarOQWhbSV8I2lWskXmT3XH8-MsDQo
To claim this, I am signing this object:
@SijmenHuizenga
SijmenHuizenga / Main.elm
Created August 10, 2018 11:48
Ricky elm
-- Fork of https://github.com/brianvanburken/elm-playground/tree/master/ricky-elm
port module Main exposing (main)
import Html exposing (Html)
import Html.Attributes as Attribute
import Html.Events as Event
import Http
import Parser exposing ((|.), (|=), Count(..), Parser, ignore, int, keep, keyword, map, oneOf, oneOrMore, succeed, symbol, zeroOrMore)
import Regex exposing (HowMany(..))
@SijmenHuizenga
SijmenHuizenga / fireworknode.ino
Last active December 30, 2017 14:33
Mysensors Firework Igniter
/**
* This mysensor node will turn a relais on for 5 seconds upon receiving a V_STATUS message. This will trigger some firework!
* To ignite the firework send the following message to the gateway:
* 17;18;1;1;2;1
*/
#define MY_DEBUG
#define MY_RADIO_NRF24
@SijmenHuizenga
SijmenHuizenga / homeiot-gateway.cpp
Created October 20, 2017 18:09
Files for the MySensors network in my home
#define MY_MQTT_USER ""
#define MY_MQTT_PASSWORD ""
#define MY_CONTROLLER_URL_ADDRESS ""
#define MY_PORT 1234
#define MY_DEBUG
#define MY_RADIO_NRF24
#define MY_GATEWAY_MQTT_CLIENT
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "shome-out"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "shome-in"
@SijmenHuizenga
SijmenHuizenga / jsonparser.cpp
Last active October 20, 2017 17:52
Json Parser in C++ (single level
//find the range of the value of a field by its id in JSON or NULL if not found. example:
// field "id" //including the " chars!
// json {"id": 417}
// response {7,9}
// String values are returned excluding their surrounding "
// This only works for single level json and array's are not supported.
int *findJsonFieldRange(const char *json, const char *field) {
int jsoni = 0;
int fieldi = 0;
@SijmenHuizenga
SijmenHuizenga / gateway.ino
Last active October 3, 2017 13:48
MySensors Ping Pong (gateway <--> sensor)
#define MY_DEBUG
#define MY_RADIO_NRF24
#define MY_RF24_CHANNEL 69
#define MY_NODE_ID 0
#define MY_GATEWAY_SERIAL
#include <MySensors.h>
#define PONGNODEID 15
@SijmenHuizenga
SijmenHuizenga / movement-music.ino
Last active September 27, 2017 20:47
Play a tune on device movement!
/**
* Use a LSM303 to detect movement. When the chip moves than a song is played!
*
* To compile requires `piches.h` that is found here: https://www.arduino.cc/en/Tutorial/toneMelody
* And the LSM303 Library is required: https://github.com/pololu/lsm303-arduino
*/
#include <Wire.h>
#include <LSM303.h>
#include "pitches.h"
@SijmenHuizenga
SijmenHuizenga / updateip.sh
Last active July 17, 2020 07:50
Dynamic IP with Cloudflare
# Add to `crontab -e`:
# @hourly /home/pi/updateip.sh > /home/pi/.ip-log.txt
# @reboot sleep 30 && /home/pi/updateip.sh > /home/pi/.ip-log.txt
IP=`curl -s http://api.ipify.org/`
if [ -f $HOME/.ip.txt ]; then
OLD_IP=`cat $HOME/.ip.txt`
else
echo "No file, need IP"
@SijmenHuizenga
SijmenHuizenga / message.md
Created May 6, 2017 19:20
I hereby verify my online identiy.

Sijmen Huizenga

I hereby verify my online identiy. Last updated: 06-may-2017 20:48

Contact Details

Sijmen Huizenga
Born in March 1997
Mail sijmenhuizenga@gmail.com

Site's