Skip to content

Instantly share code, notes, and snippets.

@karlmikko
karlmikko / index.js
Last active September 6, 2023 10:45
Fronius Amber Powerwall
import digestHeader from "digest-header";
import fetch from "node-fetch";
import http from "http";
import https from "https";
const froniusHost = '';
const froniusPassword = '';
const amberKey = '';
const teslaHost = '';
const teslaEmail = '';
@karlmikko
karlmikko / API_Query_Description.md
Last active October 4, 2022 00:21
LockedOn Query API

LockedOn API

How to get Access

Access is issued to a connected partner on a per office basis. Access requires authorization from the Office and LockedOn Support.

If you are connected with more than 1 office, you will receive an API key per office.

Limits

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Jigsaw puzzle</title>
<script type="text/javascript">
function save(filename, data)
{
var blob = new Blob([data], {type: "text/csv"});
@karlmikko
karlmikko / Recipe-bundling-fonts-with-headless-chrome.md
Created January 23, 2019 02:12 — forked from nat-n/Recipe-bundling-fonts-with-headless-chrome.md
How to build a fontconfig bundle for adding arbitrary fonts to headless chrome independent of the OS. This is specifically useful for deploying headless chrome to AWS lambda where it is necessary to include fonts for rendering CJK (Chinese, Japanese, Korean) characters into the deployed bundle.

Building fontconfig

Start up a lambda-like docker container:

docker run -i -t -v /tmp:/var/task lambci/lambda:build /bin/bash

Install some dependencies inside the container:

yum install gperf freetype-devel libxml2-devel git libtool -y

easy_install pip

@karlmikko
karlmikko / fmap.clj
Last active September 1, 2017 03:32
yet another pmap
;; You can use this as a drop in replacement for map
;; like pmap but with a bounded number of threads that is shared with child fmap invocations
;; making this safe to use in recusive algorithms like tree walking. Dead locks are avaoided
;; by continuing processing on the current thread if the pool is full.
;;
;; You can also specify the window size amouth that fmap looks ahead
;; this make fmap semi-lazy like pmap.
;;
;; You don't need to set options - it will default to the same thread count as pmap (2 + N-CPUs).
;;
@karlmikko
karlmikko / addcustom.js
Last active September 30, 2016 20:44
Add attributes to React
var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig');
HTMLDOMPropertyConfig.Properties['align'] = null;
HTMLDOMPropertyConfig.Properties['valign'] = null;
//do this prior first "require" of react
@karlmikko
karlmikko / GetStoresMixin.js
Last active August 29, 2015 14:05
GetStoresMixin
function findRoutesComponent(component){
if(component._isRoutesComponent && component._isRoutesComponent()){
return component;
}
if(component._owner){
return findRoutesComponent(component._owner);
}
return null;
};
@karlmikko
karlmikko / gist:4351755
Created December 21, 2012 09:34
fixed!
def retryable(options = {})
opts = { :tries => 1, :on => Exception }.merge(options)
retry_exception, retries = opts[:on], opts[:tries]
begin
return yield
rescue retry_exception
if (retries -= 1) > 0
sleep 2