Skip to content

Instantly share code, notes, and snippets.

@kf6kjg
kf6kjg / test.yaml
Last active May 7, 2021 00:41
Demonstrates failure behaviors in GitHub Actions Workflows
# Test results
# If a "workflow run" that is in the pending state is cancelled, then no jobs in that "workflow run" will execute - doesn't matter what their if condition is.
# If a "workflow run" that is in the running state is cancelled, then:
# 1. All jobs that are in the Running state will be stopped and anything that's actively being executed will be killed wherever they are in their execution. This can leave external services in an inconsistent state unless you actively handle it.
# 2. Any jobs that are conditional on the `cancelled()` status function will have their condition checked and if true will then execute.
# The remaining "workflow run" states are unaffected by cancellation as the run is already terminated: Cancelled, Failure, and Success.
# Jobs can terminate with the following states:
# * cancelled - meaning that at some point in the job somthing cancelled the workflow run, whether human or machine. E.g. if the workflow run was aborted via the concurrency cancel-in-progress flag being true
@kf6kjg
kf6kjg / objToTypeReadout.ts
Created July 30, 2020 19:56
Recursively converts the given value to a similar structure but with the values replaced by their types.
/**
* Recursively converts the given value to a similar structure but with the values replaced by their types.
*
* Useful for debugging datastructures you can't dig into via a debugger and that you don't already know the types of.
*/
function objToTypeReadout(key: string, value: any): { [key: string]: any } {
if (Array.isArray(value)) {
return {
[key]: typeof value,
value: value.map((v, i) => objToTypeReadout(i.toFixed(0), v)),
@kf6kjg
kf6kjg / format_txt_files.js
Created December 6, 2018 16:22
Nice formatting of TXT files
// ==UserScript==
// @name Nice formatting of TXT files
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Format online text files in a clean and easy to read way without losing fixed width needs.
// @author Ricky Curtice
// @match *://*/*.txt
// @grant none
// ==/UserScript==
@kf6kjg
kf6kjg / ISwitch
Last active October 22, 2017 16:32
JavaScript inline switch. Useful in React render methods, and still feels like a switch statement with the checked value up top. Also allows for falsy values which I also didn't see in my casual search for similar solutions.
function iswitch(key, map, def) {
return map !== null && typeof map === 'object' && map.hasOwnProperty(key) ? map[key] : def; // This way falsy values can be returned.
}
let result = iswitch('a', {
'a': "first value",
'b': "second value",
}, "default value");