Skip to content

Instantly share code, notes, and snippets.

View Tremeschin's full-sized avatar
🫤
Struggling financially..

Gabriel Tremeschin Tremeschin

🫤
Struggling financially..
View GitHub Profile
@Tremeschin
Tremeschin / cyclopts-composition.py
Last active February 24, 2026 00:17
Cyclopts example of complex composition chaining commands
"""
$ python main.py h265 config --width 1280 --height 720 h264 --preset veryfast aac --bitrate 20 aac --bitrate 50
Scene(ffmpeg=FFmpeg(vcodec=H264(preset='veryfast', crf=23), acodec=AAC(bitrate=50)), config=Config(width=1280, height=720))
"""
import contextlib
import itertools
import sys
from typing import Annotated, Any, Union
#!/usr/bin/env python3
# fmt: off
# Todo: Find a new name, write proper package
from pathlib import Path
DIVISOR = "# <!-- AUTOMATIC -->"
HOME = Path().home()
import time
import numpy as np
np.set_printoptions(threshold=np.inf, precision=2, suppress=True)
matrix_size = 5
# ---------------------------------------------------------------------------- #
def fit_depthmap(
original: np.ndarray,
@Tremeschin
Tremeschin / snake.py
Last active June 5, 2025 01:24
Snake game in 12 lines of Python, 348 characters
from random import randint as r
X,Y,M,W=[5],[5],(4,2),10
while 1:
G=[["."]*W for _ in range(W)]
G[M[1]][M[0]]='*'
for x,y in zip(X,Y):G[y][x]='#'
for R in G:print(''.join(R))
while not(i:=input()):pass
x,y=(i=="d")-(i=="a"),(i=="s")-(i=="w")
X.insert(0,X[0]+x);Y.insert(0,Y[0]+y)
@Tremeschin
Tremeschin / pacsync
Last active July 18, 2024 19:49
Synchronize a whitelist of packages on an Arch Linux system
#!/bin/bash
#
# (c) 2024, Tremeschin, MIT License
#
# pacsync - Synchronize a whitelist of packages on an Arch Linux system
#
# This scripts remove all non-related and non-dependencies of a package list, acting like a lock
# mechanism to match the system with a list of allowed packages, 'pacman.lock' vibes
#
# Usage: Add this file to your PATH or as a bash function, then run:
@Tremeschin
Tremeschin / hangman.py
Last active March 1, 2025 10:19
8 lines hangman in Python
import random as r
w=r.choice(input("enter csv of words: ").split(","))
d,t,a=["_"for n in w],5,[]
while t>0:
exit(w)if''.join(d)==w else print(''.join(d))
c=input(f"{t}t:")
for p in[p for p,v in enumerate(w)if c==v]:d[p]=w[p]
t-=0 if c in w else 1
@Tremeschin
Tremeschin / tic-tac-toe.py
Last active May 31, 2021 12:39
8 lines tic tac toe
import numpy as n
g,p,w=n.array([[0]*3]*3),1,"-OX"
while True:
for r in g: print(' '.join(w[x]for x in r))
c,p=int(input(w[-p])),-p
g[divmod(c-1,3)]=p
s=n.concatenate((n.sum(g,axis=0),n.sum(g.T,axis=0),[sum(g.diagonal())],[sum(n.fliplr(g).diagonal())]))
if e:=w[1]if 3 in s else w[2]if-3 in s else 0: exit(e+"wins")