Skip to content

Instantly share code, notes, and snippets.

View ansgarm's full-sized avatar

Ansgar Mertens ansgarm

View GitHub Profile
@ansgarm
ansgarm / shelly-thermobeacon.js
Created October 26, 2023 20:10
shelly-thermobeacon
// inspired by: https://github.com/Bluetooth-Devices/thermobeacon-ble/blob/main/src/thermobeacon_ble/parser.py
// and: https://github.com/ALLTERCO/shelly-script-examples/blob/main/ble-ruuvi.js
let CONFIG = {
scan_duration: BLE.Scanner.INFINITE_SCAN,
temperature_thr: 18,
switch_id: 0,
mqtt_topic: "thermobeacon",
event_name: "thermobeacon.measurement",
};
@ansgarm
ansgarm / gist:3a230d94c73b67f59f1fce6ccb8ee6ab
Created October 27, 2021 09:36
jsii type validation log
{
'@pahud/cdktf-aws-eks.CapacityType': {
assembly: '@pahud/cdktf-aws-eks',
fqn: '@pahud/cdktf-aws-eks.CapacityType',
kind: 'enum',
members: [ [Object], [Object] ],
name: 'CapacityType',
namespace: undefined,
docs: {
summary: undefined,
@ansgarm
ansgarm / jsii-aws-oom.txt
Created May 18, 2021 09:03
Out of Memory error for cdktf get on aws provider for golang
jsii compilation failed with non-zero exit code: null
| <--- Last few GCs --->
| [50819:0x108008000] 70298 ms: Scavenge 2005.7 (2036.1) -> 2000.2 (2036.1) MB, 7.3 / 0.0 ms (average mu = 0.258, current mu = 0.227) allocation failure
| [50819:0x108008000] 70324 ms: Scavenge 2011.1 (2036.1) -> 2005.3 (2039.8) MB, 8.8 / 0.0 ms (average mu = 0.258, current mu = 0.227) allocation failure
| [50819:0x108008000] 71113 ms: Scavenge 2015.7 (2040.1) -> 2010.1 (2024.6) MB, 11.9 / 0.0 ms (average mu = 0.258, current mu = 0.227) allocation failure
| <--- JS stacktrace --->
| ==== JS stack trace =========================================
| 0: ExitFrame [pc: 0x100a0ddd9]
| Security context: 0x155f777c08d1 <JSObject>
| 1: get type [0x155f494e46b1] [/Users/ansgar/projects/hashicorp/terraform-cdk/node_modules/jsii-reflect/lib/optional-value.js:~20] [pc=0x24f37384708f](this=0x155f226060e1 <OptionalValue map = 0x155f45846519>)
@ansgarm
ansgarm / reduce.js
Created April 23, 2018 12:27
PSA: Don't use es6 default parameters for Array.reduce() accumulator function
// PSA: Don't use es6 default parameters for Array.reduce() accumulator function
a = [1, 2, 3];
a.reduce((sum = 0, x) => sum + x); // = 6
a.reduce((sum, x) => sum + x, 0); // = 6
// seems to work...
c = a.reduce((sum = 3, x) => sum + x); // = 6
// but! other initial value doesn't have an effect
// even better
@ansgarm
ansgarm / keybase.md
Created October 1, 2014 14:24
keybase.md

Keybase proof

I hereby claim:

  • I am ansgarm on github.
  • I am ansgarmertens (https://keybase.io/ansgarmertens) on keybase.
  • I have a public key whose fingerprint is D119 4F03 F423 57B7 5936 0B31 1EFD A834 0729 6418

To claim this, I am signing this object: