Skip to content

Instantly share code, notes, and snippets.

View drkibitz's full-sized avatar
🎩
deducing

Dr. Kibitz drkibitz

🎩
deducing
View GitHub Profile
##
## Source in Xcode Run Script Phase
##
set -e
CARTHAGE=$(command -v carthage)
##
## Validate
@drkibitz
drkibitz / gist:6143035
Last active April 23, 2020 16:37
pixi.js IntactionManager Example Usage 2
// create an new instance of a pixi stage
var stage = new PIXI.Stage(0x66FF99);
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(400, 300);
// create a manager instance, passing stage and renderer.view
var manager = new PIXI.InteractionManager(stage, renderer.view);
stage
.on('click', function (event) {
console.log(event.type, event.target); // 'click', PIXI.DisplayObject {}
@drkibitz
drkibitz / montyhall.js
Last active June 6, 2023 01:42
Monty Hall Problem
/**
* The Monty Hall Problem
* https://en.wikipedia.org/wiki/Monty_Hall_problem
*/
// convert 0.333 to 33%
const toPercentInteger = (fraction) => {
return Math.floor(fraction * 100);
};
@drkibitz
drkibitz / childprocess-lifecycle-manager.ts
Last active June 6, 2023 03:16
Type safe ChildProcess Manager (With command flow, i.e. micro redux)
import type { ChildProcess, ChildProcessByStdio } from 'node:child_process';
import type { Readable, Writable } from 'node:stream';
import stripAnsi from 'npm:strip-ansi';
export enum Phase {
Stopped = 'stopped',
Stopping = 'stopping',
Starting = 'starting',
Started = 'started',
}
@drkibitz
drkibitz / priority-signals.js
Last active June 6, 2023 03:30
Signal implementation with listener priorities
/**
* This object represents a single listener of a Singal.
* A listener is simply an object with a reference to a function and thisArg,
* with a priority for insertion sorting and a once flag.
* @class
*/
class Listener {
/**
* @param {Function} fn - The listener function
* @param {Function} [thisArg] - The listener thisArg
@drkibitz
drkibitz / delete-all-remote-git-tags-in-pages.sh
Last active June 6, 2023 03:32
Delete all remote Git tags in pages
#!/usr/bin/env bash
## Count local
totalCount=$(git tag -l | wc -l)
pageCount=150
index=0
while [ $index -le $totalCount ]; do
## Reverse order with `sort -r`
list=$(git tag -l | sort | head -n $pageCount)
@drkibitz
drkibitz / parallel.bash
Last active September 11, 2023 03:29
parallel.bash
#!/usr/bin/env bash
## parallel.bash
## -------------
## A bash script that executes provided tasks in parallel, with added handling
## for errors, logs, and signals (within reason).
## ```sh
## ./parallel.bash -m 2 \
## 'echo 'sleeping1'; sleep 5' \
## 'echo 'sleeping3'; sleep 2' \
## 'echo 'sleeping3'; sleep 3' \