Skip to content

Instantly share code, notes, and snippets.

View linj121's full-sized avatar
:shipit:
Focusing

Josh linj121

:shipit:
Focusing
View GitHub Profile
git clone --bare https://github.com/linj121/dotfiles.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
@linj121
linj121 / comb.py
Last active December 26, 2024 00:34
Generate combinations from a pool of elements
#!/ucrt64/bin/python
from typing import List
from sys import argv
# eg. pool = ['0', '1']
# n = 3
# total count = 2 ** 3 = 8
# 0 0 0
# 0 0 1
# 0 1 0
@linj121
linj121 / 3dto2d.py
Last active September 23, 2024 21:23
Project 3d vertices onto the 2d plane of a 1x1x1 view camera
import matplotlib.pyplot as plt
class Vec2:
x: float
y: float
def __init__(self, x, y):
self.x = x
self.y = y
#!/bin/bash
# Set default values for configuration files
CONFIG_DIR=${CONFIG_DIR:-/etc/zlmediakit}
CONFIG_FILE=${CONFIG_FILE:-$CONFIG_DIR/config.ini}
SSL_CERT_FILE=${SSL_CERT_FILE:-$CONFIG_DIR/default.pem}
if [ ! -d "$CONFIG_DIR" ]; then
echo "Configuration directory $CONFIG_DIR does not exist. Please create it and add your config.ini and default.pem files."
exit 1
// Author: Josh Comeau
// https://courses.joshwcomeau.com/css-for-js
// Replace “.the-sticky-child” for a CSS selector
// that matches the sticky-position element:
const selector = '.the-sticky-child';
function findCulprits(elem) {
if (!elem) {
throw new Error(
// Author: Josh Comeau
// https://courses.joshwcomeau.com/css-for-js/
// Helps developers finding the parent element that break the fixed position
// Replace “.the-fixed-child” for a CSS selector
// that matches the fixed-position element:
const selector = '.the-fixed-child';
@linj121
linj121 / model.py
Last active February 25, 2024 23:38
Floyd Cycle Detection
class FloydCycleModel:
def __init__(self, cycleLength: int, fasterSpeed: int, slowerSpeed: int) -> None:
self.CycleLength = cycleLength
self.FasterSpeed = fasterSpeed
self.SlowerSpeed = slowerSpeed
def calcIterations(self, n: int) -> int:
return n * self.CycleLength / (self.FasterSpeed - self.SlowerSpeed)
def argmin(self) -> int: