Skip to content

Instantly share code, notes, and snippets.

martinky / interleave.kt
Last active Oct 28, 2022
Kotlin extension function to produce an interleaved flattened list from a collection of iterables
View interleave.kt
* Produces a flattened [List] that is an interleaved merge of the input iterables.
* For example:
* ```
* listOf(
* listOf(1, 2, 3, 4),
* listOf('a', 'b')
* ).interleave()
martinky / dummy.h
Last active Mar 23, 2021
Dummy helper struct that helps to debug when C++ objects get created, copied and destroyed.
View dummy.h
#pragma once
Dummy struct that prints a line whenever it is constructed, copied, moved or destructed.
struct dummy {
int val;
dummy() : val(0) { printf("dummy() def ctor\n"); }
dummy(int v) : val(v) { printf("dummy(%d) ctor\n", val); }
dummy(const dummy &d) : val(d.val) { printf("dummy(%d) copy ctor\n", val); }
martinky /
Last active Mar 26, 2020
Minimal example simulating a JS closure capture bug of the QML engine that is only observed while the QML debugger is attached. With the QML debugger attached following error occurs: main.qml:30: ReferenceError: text is not defined. Without QML debugger attached, the code works properly.
QT += quick
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
martinky / Makefile
Last active Mar 18, 2022
Makefile used to run complete Ansible playbooks in parallel on individual hosts using make -jN with added timeout constraint.
View Makefile
HOSTS=host_a host_b
deploy: all_hosts
all_hosts: $(HOSTS)
View ctor_init_list_fallacy.cpp
#include <stdio.h>
class Component
int value;
Component(int v) :