Skip to content

Instantly share code, notes, and snippets.

View Kaligraphy247's full-sized avatar
💭
Probably Available

James Ononogbu Kaligraphy247

💭
Probably Available
View GitHub Profile
@Kaligraphy247
Kaligraphy247 / safe_get.py
Created April 5, 2025 09:47
Safe Dictionary Value Retrieval with Dot Notation
"""
Safe Dictionary Value Retrieval with Dot Notation
This module provides a function, `safe_get`, that safely retrieves values from
Python dictionaries, including nested dictionaries, using either a list of keys
or a dot-notation string. It avoids common `KeyError` exceptions and provides
a default value if the specified key path is not found.
This code was generated with the help Gemini 2.0 Flash. Test are completly AI generated. While Gemini 2.0 Flash has been trained
to generate correct and efficient code, it's essential to review and test
@Kaligraphy247
Kaligraphy247 / cache.ts
Created November 13, 2024 18:48 — forked from rallisf1/cache.ts
Simple Typescript Memory Cache
export const cache = {
data: new Map(),
timers: new Map(),
set: (k: string, v: any, ttl: number) => {
if (cache.timers.has(k)) {
clearTimeout(cache.timers.get(k))
}
cache.timers.set(
k,
setTimeout(() => cache.delete(k), ttl * 1000)
@Kaligraphy247
Kaligraphy247 / run-tailwindcss.py
Last active August 5, 2024 22:34
Tailwindcss starter script for FastHTML
# httpx is a required dependency for FastHTML, feel free to substitute for something else.
import httpx
import os
import platform
# Constants and Variables
NAME = ""
CACHE_PATH = ".tailwindcss"
INPUT_CSS_FILE = f"{CACHE_PATH}/input.css"
OUTPUT_CSS_FILE = "static/css/style.css"
// Inspired by Tailwind Daisy UI progress bar: https://daisyui.com/components/radial-progress/
// This is a custom-made progress circular/radial progress bar with centered percentage text.
// Tested with Tailwind 3.x. Should work with lower versions of Tailwind CSS as well.
STEP 1: Add the following custom CSS:
.progress-ring__circle {
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
@Kaligraphy247
Kaligraphy247 / tkinterlist.py
Created December 13, 2020 10:50 — forked from athiyadeviyani/tkinterlist.py
Python GUI cheatsheet
# BASIC TKINTER CHEATSHEET
# Build basic GUIs with Python
from tkinter import *
from tkinter import scrolledtext
from tkinter import messagebox
from tkinter.ttk import Progressbar
from tkinter import filedialog
from tkinter import Menu