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 / 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 / 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 / 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 / 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 / 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(..))
### 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.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()