Skip to content

Instantly share code, notes, and snippets.

View jomido's full-sized avatar
🎯
Focusing

Jonathan Dobson jomido

🎯
Focusing
View GitHub Profile
@jomido
jomido / monty.md
Created December 14, 2023 14:48
monty hall intuition

monty hall intuition: 1000 doors

the setup

A host invites a friend over to play a game.

There are 3 doors. Behind 1 door is a car. Behind the other 2 doors are goats. The friend may choose one door. If the friend chooses the door with the car, they can keep it. If the friend chooses a door with a goat, they have to return the goat to the farm from whence it was borrowed. Goats go home. 10km

@jomido
jomido / README.md
Created February 2, 2023 21:23
Focused Tour

Focused Tour

A component to automate focused tours.

The framework does not matter (it's incidental), but this demo is in Vue 3.

  • handle window resize
  • add UI for text/help
@jomido
jomido / solution.py
Last active July 12, 2022 16:42
CodeSignal: Descending/Ascending Towers
cases = [
([], 0),
([10], 0),
([1, 2, 3, 4], 0),
([1, 1, 1, 1], 6),
([1, 3, 2, 1], 3),
([1, 7, 1, 4], 13),
]
@jomido
jomido / fnf.py
Last active November 19, 2021 13:12
# fire-n-forget
#
# https://bugs.python.org/issue44665
# https://bugs.python.org/issue42538
import asyncio
import functools
running_tasks = set()
@jomido
jomido / timeit.js
Created May 5, 2020 15:25
v8 ser/deser vs "parsify"
const v8 = require('v8')
const iterations = 1000
const getData = () => {
// return a large data blob
return [
{
@jomido
jomido / index.js
Created January 31, 2018 20:46
Node Blocking Readline
// THIS WILL NOT WORK UNTIL NODE implements `Atomics` :) Soon?
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function msleep(n) {
@jomido
jomido / gcloud-script-box.sh
Created October 13, 2017 14:52
Idempotent Gcloud Compute Create
#!/bin/bash
# BEGIN SANITY BOX------------------------------------------
set -e # immediately exit if any command fails |
set -u # immediately fail on undefined variables |
set -o pipefail # show error of last failed command |
IFS=$'\n\t' # control what word splitting means |
# END SANITY BOX--------------------------------------------
# delete
@jomido
jomido / README.md
Last active October 13, 2017 16:41
Dedupe and limit HTTP request with NGINX

NGINX conf:

# limit_req_zone   $request_uri zone=per_uri_2s:10m rate=30r/m;
limit_req_zone $limit_post zone=per_uri:10m rate=30r/m;
limit_req_status 429;

location ~ ^/v\d+/tasks/.*/claim$ {
 limit_req zone=per_uri_2s;
 [...]
@jomido
jomido / doit.sh
Created September 19, 2017 13:56
Docker on Debian 9
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
@jomido
jomido / README.md
Created July 19, 2017 14:44
Messing About with Elasticsearch (in Python)