Skip to content

Instantly share code, notes, and snippets.

@jart
jart / rename-pictures.sh
Created December 12, 2023 15:24
Shell script for renaming all images in a folder
#!/bin/sh
# rename-pictures.sh
# Author: Justine Tunney <jtunney@gmail.com>
# License: Apache 2.0
#
# This shell script can be used to ensure all the images in a folder
# have good descriptive filenames that are written in English. It's
# based on the Mistral 7b and LLaVA v1.5 models.
#
# For example, the following command:
@Hirrolot
Hirrolot / CoC.ml
Last active July 15, 2024 16:09
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@Gopiandcode
Gopiandcode / cram-mode.el
Created January 22, 2023 13:37
An emacs mode for cram tests
;;; cram-mode.el --- Emacs mode for CRAM tests -*- lexical-binding: t; -*-
;; Copyright (C) 2023 Kiran Gopinathan
;; Author: Kiran Gopinathan
;; Keywords:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
@progheal
progheal / CubeFolding.md
Last active December 22, 2022 20:03
Advent of Code 2022 Day 22: Monkey Maps, cube folding algorithm

Let's start from our designated starting point, the "top left" of the first cube face, going right. This means we are going clockwise along the edge of the net.

We want to trace the edge and trying to match the "edge cells", which is represented by a cell, and its direction when we traversed them clockwisely. Using the sample as example, the first edge is (1,9,>). If the current edge does not match other edge, we simply push that into a stack.

We go along the edge, stopping every N times to determine which turn do we take on the net. This is done by going one step out and check myself and my left.

@Hirrolot
Hirrolot / CoC.ml
Last active May 26, 2024 00:04
Barebones lambda cube in OCaml
(* The syntax of our calculus. Notice that types are represented in the same way
as terms, which is the essence of CoC. *)
type term =
| Var of string
| Appl of term * term
| Binder of binder * string * term * term
| Star
| Box
and binder = Lam | Pi
@miabrahams
miabrahams / FfmpegPostprocess.py
Last active March 2, 2024 18:07
Ffmpeg post-processing OBS Plugin
import obspython as obs
import subprocess
import os
import re
import datetime
# Info for potential OBS Python hackers!
# Tip 1 - Read the "OBS Studio Backend Design" documentation page. Read the documentation table of contents.
# Tip 2 - be sure to add obspython.py to your script path to enable completion.
# Tip 3 - Some of the Python API is generated at runtime, so it won't show up in obspython.py.
#!/usr/bin/python
#
# Derived from:
#
# MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
#
# Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
# rights reserved.
#
# License to copy and use this software is granted provided that it
@claymcleod
claymcleod / pycurses.py
Last active June 27, 2024 00:17
Python curses example
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()