Skip to content

Instantly share code, notes, and snippets.

View dpjanes's full-sized avatar

David Janes dpjanes

View GitHub Profile
@dpjanes
dpjanes / doctor.py
Created August 15, 2022 22:34
Flutter Doctor-like Python code
import asyncio
from yachalk import chalk
async def check_1():
await asyncio.sleep(2)
return True, "all good man"
check_1.LABEL = "doing check 1"
@dpjanes
dpjanes / DateDocuments.py
Created August 23, 2022 09:57
Rename documents with a datestamp
import sys
import os
import click
import re
import time
import logging
logger = logging.getLogger(__name__)
def process_dir(f, depth=0, **av):
@dpjanes
dpjanes / DOM3D.js
Created March 27, 2024 17:11 — forked from OrionReed/dom3d.js
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@dpjanes
dpjanes / Baseball6.py
Created August 20, 2024 15:54
Compute the odds of winning the game when ahead in the 6th inning
# Code by GPT-4o
# data from:
# https://www.retrosheet.org/gamelogs/index.html
def parse_line_score(line_score):
# Initialize scores
visitor_score = 0
home_score = 0
# Split the line score by inning