Skip to content

Instantly share code, notes, and snippets.

View khlam's full-sized avatar
🤠
disregard intermediate tokens, just eval my answer

Lam khlam

🤠
disregard intermediate tokens, just eval my answer
View GitHub Profile
@khlam
khlam / gist:b4b86627e19d8a53189318ff956122f1
Created November 17, 2025 02:45
Deterministic SHA-256 hash from the image RGB data.
from pathlib import Path
import hashlib
from PIL import Image
def _image_rgb_hash(path: Path) -> str:
"""Compute a deterministic SHA-256 hash from the image RGB data."""
with Image.open(path) as img:
rgb_img = img.convert("RGB")
pixel_bytes = rgb_img.tobytes()
grep -h -o '^[0-9]\+' *.txt | sort -n | uniq -c | sort -k2 -n
@khlam
khlam / gist:146a72d3fc4d549f6f767cf826c32445
Created November 23, 2024 02:21
Config: Homebridge Camera FFmpeg for bambu lab x1c lan mode camera
{
"name": "Camera FFmpeg",
"cameras": [
{
"name": "bambu",
"videoConfig": {
"source": "-rtsp_transport tcp -i rtsps://bblp:<LAN mode access code>@<X1C IP address>:322/streaming/live/1"
}
}
]
@khlam
khlam / .gitignore
Last active August 7, 2024 21:22
python-gitignore
*.env
wandb/
.ipynb_checkpoints/
*.png
*.ckpt
*.env
**/.DS_Store
@khlam
khlam / subreddit_blocker.js
Created January 29, 2022 10:03
userscript / greasemonkey / violentmonkey script to hide all posts from a subreddit by name (not case sensitive) or by regex
// ==UserScript==
// @name subreddit_blocker
// @description Hides all posts from subreddits by name (not case sensitive) or by regex.
// @author khlam
// @match http://*.reddit.com/*
// @match https://*.reddit.com/*
// @version 0.0
// ==/UserScript==
const regex = [] // your regex block here, comma seperated.
@khlam
khlam / subreddit_custom_css_block.js
Created January 29, 2022 09:52
userscript / greasemonkey / violentmonkey script to removes subreddit custom css for old.reddit.com
// ==UserScript==
// @name subreddit_custom_css_block
// @version 0.0
// @description Removes subreddit custom css for old.reddit.com
// @author khlam
// @match http://*.reddit.com/*
// @match https://*.reddit.com/*
// @require https://gist.githubusercontent.com/khlam/f85ee658005a45a99ba0147124c09c38/raw/704f92f52d7c4c1ed8e71f2c9311b46c2e6ea3cc/jQuery.v3.6.0
/* globals jQuery, $ */
// @run-at document-end
@khlam
khlam / twitch_autoplay_block.js
Last active January 29, 2022 10:09
userscript / greasemonkey / violentmonkey script for twitch.tv frontpage autoplay block, twitch_front_carousel_block twitch autplay block
// ==UserScript==
// @name twitch_front_carousel_block
// @version 0.0
// @description Blocks twitch frontpage autoplaying stream by setting its source to null.
// @author khlam
// @match http://www.twitch.tv/
// @match https://www.twitch.tv/
// @grant none
// @run-at document-end
// ==/UserScript==
abandoned
able
absolute
adorable
adventurous
academic
acceptable
acclaimed
accomplished
accurate
@khlam
khlam / pytorch-csv-lazy-read-csv.py
Last active October 13, 2021 19:56
pytorch-csv-lazy-read-csv
import numpy as np
import pandas as pd
import torch
from torch.utils.data import Dataset, DataLoader
class lazyLoadCSVDataset(Dataset):
def __init__(self, data_CSV_path, rows_each_fetch=500, shuffle=True):
self.dataPath = data_CSV_path