Skip to content

Instantly share code, notes, and snippets.

View riston's full-sized avatar

Risto Novik riston

View GitHub Profile
@riston
riston / setup.bash
Last active July 29, 2020 21:25
Capture Dallas ds18b20 sensor temperature data and post it to Home Assistant (base source https://www.mkompf.com/weather/pionewiremini.html)
echo '2-57/5 * * * * HA_TOKEN=OOOO HA_HOST=tik.tok.org python3 $HOME/temperature.py >> $HOME/temperature.log 2>&1' | crontab -
@riston
riston / mqtt-dht11.js
Created August 5, 2018 13:23
Mongoose OS DHT11 MQTT temperature and humidity reporter
load('api_config.js');
load('api_events.js');
load('api_gpio.js');
load('api_mqtt.js');
load('api_net.js');
load('api_sys.js');
load('api_esp8266.js');
load('api_dht.js');
load('api_timer.js');
@riston
riston / index.ts
Last active April 9, 2018 06:15
io-ts library testing
import t, {
array, type, string, number, mixed, boolean, union,
null as Null, undefined as Undefined, Type, literal,
success, failure,
} from 'io-ts';
import { ThrowReporter } from 'io-ts/lib/ThrowReporter'
import { PathReporter } from 'io-ts/lib/PathReporter'
import { reporter } from 'io-ts-reporters';
@riston
riston / maze.js
Created April 23, 2017 15:53
Maze rendering with Two.js
const ACTORS = {
N: 1,
S: 2,
E: 4,
W: 8,
SP: 16,
EP: 32,
}
@riston
riston / keybase.md
Created February 9, 2017 14:36
Keybase proof

Keybase proof

I hereby claim:

  • I am riston on github.
  • I am riston (https://keybase.io/riston) on keybase.
  • I have a public key ASAXJmK3h-xIPLvliDr3pTrO67IQQ1M_A7QJizLfqcV85go

To claim this, I am signing this object:

@riston
riston / vision-detect.py
Created January 8, 2017 18:55
Person detection and dropbox upload script
from io import BytesIO
import requests
import dropbox
import time
import sys
import os
IMG_PATH = "/var/images"
MS_VISION_BASE_URL = "https://api.projectoxford.ai/vision/v1.0/analyze"
@riston
riston / test.js
Created November 23, 2016 14:56
Promisify function, could not work executed in wrong context(this)
const _promiseFn = fn => {
return function promisified(...args) {
const self = this; // promisification if performance critical
return new Promise((resolve, reject) => {
const cbFn = (error, result) => {
if (error) {
return reject(new Error(error));
}
if (result && false === result.success) {
@riston
riston / combine.js
Created November 10, 2016 12:37
Promise generator combination
const bluebird = require("bluebird");
const cop = bluebird.coroutine;
const exec = (time) => bluebird.delay(time).then(() => {
console.log("Time done", time);
return time;
});
@riston
riston / fizzbuzz.js
Last active October 6, 2016 07:23
Fizz Buzz hack in js
d=(x,n)=>x%n==0
f="Fizz"
b="Buzz"
for(i=0;++i<101;) console.log(d(i,3)&&d(i,5)?f+b:d(i,3)?f:d(i,5)?b:i)
d=x=>n=>x%n==0
f="Fizz"
b="Buzz"
for(i=0;++i<101;) console.log((a=d(i))&&a(3)&&a(5)?f+b:a(3)?f:a(5)?b:i)
@riston
riston / config.sh
Created September 26, 2016 07:28
Heroku NODE_CONFIG change
#!/bin/bash
#
# .config.sh application-name change the NODE_CONFIG value
set -euo pipefail
cd "$(dirname "$0")/.."
APPLICATION="${1:-}"
TMPFILE="$(mktemp /tmp/config.XXXX.json)"