Poor man's Finite State Machine (FSM)
function fsm_reducer(current_state, event) {
let new_state = current_state;
// 1. Transitions
if (event.type === "start") {
new_state = { ...new_state, state: "playing" };
}Poor man's Finite State Machine (FSM)
function fsm_reducer(current_state, event) {
let new_state = current_state;
// 1. Transitions
if (event.type === "start") {
new_state = { ...new_state, state: "playing" };
}| /** | |
| * Gear Factory Bot | |
| * ================ | |
| * | |
| * A JavaScript bot that automates the idle game "Gear Factory". | |
| * | |
| * What it does: | |
| * - Buy Gear: repeatedly clicks the "Buy Gear" button on the Build tab. | |
| * - Sort: repeatedly clicks the "Sort" button. | |
| * - Merge: merge gears very quickly. |
| // Simple bot that executes an action after another that I made for the game Progress Knight Quest | |
| // https://indomit.github.io/progress_knight_2/ | |
| // GitHub: https://github.com/indomit/progress_knight_2/ | |
| (() => { | |
| try { | |
| window.stop_bot(); | |
| } catch (_) {} | |
| /* UTIL */ |
| // Constants | |
| const APPOINTMENTS_CALENDAR_URL = "/terminvereinbarung/termin/all/120686/" | |
| const WAIT_DURATION_MS = 3 * 60 * 1000 | |
| const INITIAL_STATE = "INIT_STATE" | |
| const SETTING_UP_STATE = "SETTING_UP_STATE" | |
| const CHECKING_APPOINTMENTS_STATE = "CHECKING_APPOINTMENTS_STATE" | |
| const WAITING_STATE = "WAITING_STATE" | |
| const ALARM_STATE = "ALARM_STATE" |
| #!/bin/python | |
| # This is a simple script to help save and restore the database during development. | |
| # Usage: | |
| # - dev-db save users | |
| # - dev-db restore users | |
| import sys | |
| import os |
| # | |
| # Some usefull kubectl commands | |
| # | |
| function kube-find-namespace() { | |
| kubectl get namespaces | tail -n +2 | fzf -q "$1" | awk '/(.*)/ {print $1}' | |
| } | |
| function kube-app-pod() { | |
| local namespace | |
| namespace=$1 | |
| kubectl get pods --field-selector status.phase=Running -n "$namespace" | awk '/(.*)-app-(.*) / {print $1}' | head -n 1 |
| # https://github.com/alacritty/alacritty | |
| # https://github.com/dancor/wmctrl | |
| # https://github.com/baskerville/sxhkd | |
| # https://github.com/noctuid/tdrop | |
| super + z | |
| tdrop -n top --width 100% --height 30% --post-map-hook 'wmctrl -r "Alacritty - Drop Down - Top" -b add,above,sticky' alacritty --title 'Alacritty - Drop Down - Top' | |
| super + shift + z | |
| tdrop -n bottom -y 64% --width 100% --height 30% --post-map-hook 'wmctrl -r "Alacritty - Drop Down - Bottom" -b add,above,sticky' alacritty --title 'Alacritty - Drop Down - Bottom' |
| /*** | |
| * __ ______ ________________ ________ ___ _____ __ ___________ ____ ____ _____ | |
| * / |/ / | / ____/ _/ ____/ / ____/ / / | / ___// / / / ____/ | / __ \/ __ \/ ___/ | |
| * / /|_/ / /| |/ / __ / // / / /_ / / / /| | \__ \/ /_/ / / / /| | / /_/ / / / /\__ \ | |
| * / / / / ___ / /_/ // // /___ / __/ / /___/ ___ |___/ / __ / /___/ ___ |/ _, _/ /_/ /___/ / | |
| * /_/ /_/_/ |_\____/___/\____/ /_/ /_____/_/ |_/____/_/ /_/\____/_/ |_/_/ |_/_____//____/ | |
| * | |
| */ | |
| (function() { |
| Benchmarking 6 regexes for 18 test cases | |
| Benchmarking test case: "17697971165612536521198392175651265616253619638124 minutes" | |
| original x 4,228,677 ops/sec ±1.47% (86 runs sampled) | |
| prototype0 x 4,329,400 ops/sec ±2.68% (81 runs sampled) | |
| prototype1 x 4,015,480 ops/sec ±2.31% (83 runs sampled) | |
| prototype2 x 4,621,512 ops/sec ±1.20% (88 runs sampled) | |
| prototype3 x 4,516,519 ops/sec ±0.75% (90 runs sampled) | |
| ***totype4 x 4,729,367 ops/sec ±1.01% (88 runs sampled) |
| /* | |
| * Orginial: | |
| * Quick and dirty tricks for debugging Javascript by Chang Wang | |
| * https://hackernoon.com/quick-and-dirty-tricks-for-debugging-javascript-d0e911c3afa | |
| * | |
| * Translated to Typescript by @TheVTM | |
| */ | |
| function print<T>(tag: string, param: T): T { | |
| console.log(tag, param); |