Skip to content

Instantly share code, notes, and snippets.

View riston's full-sized avatar

Risto Novik riston

View GitHub Profile
@riston
riston / bot-download.sh
Created July 4, 2012 15:46
RSBot downloading script
#!/bin/sh
download_page='http://links.powerbot.org/download'
referer='http://powerbot.org'
filename='RSBot.jar'
curl -GL -e $referer -A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19" -o $filename $download_page
# Well you could also add the line to add the line for start the bot after download
# java -jar $filename
@riston
riston / remove.js
Last active December 12, 2022 15:21
Remove empty objects from object, recursive
var removeEmpty = function(object) {
if (!_.isObject(object)) {
return;
}
_.keys(object).forEach(function(key) {
var localObj = object[key];
@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 / gist:3016944
Created June 29, 2012 09:40
Random number generating (Box-Muller)
var Random = {
/**
* Numbers between ~( -2 to 2 )
* http://stackoverflow.com/questions/75677/converting-a-uniform-distribution-to-a-normal-distribution
* http://c-faq.com/lib/gaussian.html
*/
gaussian: function() {
var x1, x2, r;
@riston
riston / command.go
Created February 27, 2016 16:37
Simple command pattern in Go lang
package main
import "fmt"
type Command interface {
Execute() string
}
type PingCommand struct{}
func (p *PingCommand) Execute() string {
@riston
riston / app.js
Created September 6, 2015 15:38
Reactive RXJS drawing example
var canvas = document.getElementById("container");
var ctx = canvas.getContext("2d");
// The line settings
ctx.lineWidth = 4;
ctx.lineJoin = ctx.lineCap = "round";
var intervalSource = Rx.Observable.interval(2 * 1000, Rx.Scheduler.requestAnimationFrame);
var pauser = new Rx.Subject();
@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 / sqs.js
Created March 5, 2015 19:16
SQS recursive polling
var aws = require('aws-sdk');
var util = require('util');
var SQS = new aws.SQS({
accessKeyId: 'xxxx',
secretAccessKey: 'xxx',
region: 'xxx',
sslEnabled: false,
paramValidation: true,
convertResponseTypes: true,
@riston
riston / svg2png.js
Created April 3, 2014 14:25
Convert currently active svg to png, copy this to your web console and execute "svg2png(document.querySelector('svg'))", click the url to open.
// Takes an SVG element as target
function svg2png(target) {
// Flatten CSS styles into the SVG
for (i = 0; i < target.childNodes.length; i++) {
child = target.childNodes[i];
child.style.cssText = window.getComputedStyle(child).cssText;
}
var box = target.viewBox.baseVal;