Skip to content

Instantly share code, notes, and snippets.

View anttikuuskoski's full-sized avatar

Eino-Antti Kuuskoski anttikuuskoski

View GitHub Profile
@anttikuuskoski
anttikuuskoski / script.js
Last active April 8, 2024 20:15
Shelly 1.2.2 firmware console issue example
/* Shelly firmware 1.2.2 issue; tested on Pro3EM */
let counter = 0;
function breaksIt(i) {
console.log('break ' + i);
}
function worksBut(a) {
console.log('func ' + a + ' ' + (counter++) );
@anttikuuskoski
anttikuuskoski / object_create_works_simple.js
Last active October 2, 2023 15:18
Object.create works when used to replace a subobject on fw 0.14.4
function reportConfigError(res, ec, em) {
if(ec)
console.log("Config update error", ec, em);
}
let bluConfig = Shelly.getComponentConfig("plugs_ui");
let on = Object.create(bluConfig.leds.colors["switch:0"].on);
on.rgb = [50, 0, 50];
bluConfig.leds.colors["switch:0"].on = on;
@anttikuuskoski
anttikuuskoski / object_create_works.js
Last active October 2, 2023 15:17
Object.create as used in the plus plug illuminator, is used to copy and modify a subobject - works on 0.14.4
function reportConfigError(res, ec, em) {
console.log("Config update error", ec, em);
}
let onColorConfig = {
rgb: [100, 0, 0],
// rgb: [0, 0, 100],
brightness: 80
};
@anttikuuskoski
anttikuuskoski / clone_vs_object_create.js
Last active September 24, 2023 11:26
Code to demonstrate behaviour of Object.create (not working) vs cloning through json (working) in shelly gen2 firmware 1.0.0-beta6 - 1.0.3 running in Shelly Plug Plus S
function reportConfigError(res, ec, em) {
console.log("Config update error", ec, em);
}
function cloneObject(something) {
let str = JSON.stringify(something);
return JSON.parse(str);
}
let bluConfig = {
@anttikuuskoski
anttikuuskoski / call_depth_of_two_breaks_something.js
Last active September 24, 2023 11:25
Code to demonstrate a bug in shelly gen2 firmware 1.0.0-beta6 - 1.0.3 running in Shelly Plug Plus S wherein 2 levels of function calls prevents correct behaviour
function reportConfigError(res, ec, em) {
console.log("Config update error", ec, em);
}
let bluConfig = {
leds: {
mode: "switch",
colors: {
"switch:0": {
on: {
@anttikuuskoski
anttikuuskoski / object_create_acts_strange.js
Last active August 11, 2023 13:50
Code to demonstrate a bug in Object.create in Shelly gen 2 firmware version 1.0.0-beta6.
// Code to demonstrate a bug in Object.create in Shelly gen 2 firmware version 1.0.0-beta6 in a Shelly Plus Plug S
let original = {
key: 'value'
};
// Make a clone
let clone = Object.create(original);
// Should print the original object stringified and it does
@anttikuuskoski
anttikuuskoski / CompositionWithMultipleParameters.md
Last active May 4, 2021 10:52 — forked from cscalfani/CompositionWithMultipleParameters.md
Functional Composition with Multiple Parameters in Haskell

Functional Composition with Multiple Parameters in Haskell

In the past, I've written composition functions in both Elm and Haskell that take multiple parameters for the leftmost function, i.e. the function that gets applied first.

(All examples here are in Haskell)

Here was my Haskell implemenation (stolen from the web):

compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d
@anttikuuskoski
anttikuuskoski / .block
Created December 29, 2016 12:06 — forked from mbostock/.block
Brush & Zoom
license: gpl-3.0