Skip to content

Instantly share code, notes, and snippets.

Risto Novik riston

Block or report user

Report or block riston

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@riston
riston / mqtt-dht11.js
Created Aug 5, 2018
Mongoose OS DHT11 MQTT temperature and humidity reporter
View mqtt-dht11.js
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 Apr 9, 2018
io-ts library testing
View index.ts
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 Apr 23, 2017
Maze rendering with Two.js
View maze.js
const ACTORS = {
N: 1,
S: 2,
E: 4,
W: 8,
SP: 16,
EP: 32,
}
View keybase.md

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 Jan 8, 2017
Person detection and dropbox upload script
View vision-detect.py
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 Nov 23, 2016
Promisify function, could not work executed in wrong context(this)
View test.js
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 Nov 10, 2016
Promise generator combination
View combine.js
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 Oct 6, 2016
Fizz Buzz hack in js
View fizzbuzz.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 Sep 26, 2016
Heroku NODE_CONFIG change
View config.sh
#!/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)"
@riston
riston / enc.js
Created Jun 11, 2016
Encrypt-decrypt AES256 Node.js with crypto module example
View enc.js
var crypto = require("crypto");
function encrypt(key, data) {
var ciph = crypto.createCipher("aes256", key);
ciph.end(data);
var encBuffer = ciph.read();
// Convert to base64
return encBuffer.toString("base64");
You can’t perform that action at this time.