Skip to content

Instantly share code, notes, and snippets.

@lcustodio
lcustodio / ensureActive-in-a-catch-all.md
Last active September 28, 2026 16:54
What currentCoroutineContext().ensureActive() changes in a catch-all under a consumer timeout (kotlinx-coroutines 1.11.0 sandbox)

ensureActive() in a catch-all

What does currentCoroutineContext().ensureActive() change when a catch-all is wrapped in a consumer timeout? This sandbox runs three versions of the same catch block against the cases a Kafka consumer actually meets.

// 1. original: swallows everything
try { call() } catch (ex: Throwable) { log(ex) }

// 2. type check
try { call() } catch (ex: CancellationException) { throw ex } catch (ex: Throwable) { log(ex) }
@lcustodio
lcustodio / ssh_key.tf
Created August 12, 2020 09:44 — forked from irvingpop/ssh_key.tf
Terraform external data source example - dynamic SSH key generation
# ssh key generator data source expects the below 3 inputs, and produces 3 outputs for use:
# "${data.external.ssh_key_generator.result.public_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key_file}" (path)
data "external" "ssh_key_generator" {
program = ["bash", "${path.root}/../ssh_key_generator.sh"]
query = {
customer_name = "${var.customer_name}"
customer_group = "${var.customer_group}"
@lcustodio
lcustodio / hashmap.R
Created December 1, 2019 21:49
R Hashmap
# https://rnotebook.io/anon/ae2ac79d0d10d6f6/notebooks/hashmap.ipynb
library(hash)
h <- hash()
a <- matrix(1:4, nrow = 12, ncol = 3)
print(a)
# has.key("4",h)
@lcustodio
lcustodio / Mac OSX Setup - Brew
Created January 21, 2019 00:09 — forked from jbelke/Mac OSX Setup - Brew
Mac OSX Setup - Brew and Cask
# Get Sudo.
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
# Install Xcode first - https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12
# Install Xcode command line tools.
xcode-select --install
@lcustodio
lcustodio / clear-docker.sh
Created December 21, 2017 16:56
Clear docker volumes
docker system prune -a --volumes
@lcustodio
lcustodio / GIF-Screencast-OSX.md
Created December 12, 2017 10:22 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@lcustodio
lcustodio / inspect-node-in-chrome.sh
Created November 27, 2017 10:36
Debug Node into Chrome
#NiM - Node.js V8 --inspector Manager (NiM)
#https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj?hl=en
node --inspect-brk 01-hello.js
@lcustodio
lcustodio / api-discussion.md
Last active October 25, 2017 12:50
Api discussion

Option 1

POST

{
  "command": "SET_PROCESS_THRESHOLD",
  "parameters": {
  	"processName": "New Vacation Request",
    "newTargetDurationInMillis": "NULL | 0"
 }
@lcustodio
lcustodio / container.js
Created September 16, 2017 12:24
Component wrapper to centralize blog-like content
import React from "react"
export default ({ children }) =>
<div style={{ margin: "3rem auto", maxWidth: 600 }}>
{children}
</div>
@lcustodio
lcustodio / destructuring.js
Created July 10, 2017 12:06 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];