Skip to content

Instantly share code, notes, and snippets.

@knyazer
knyazer / add_to_fish_config.fish
Last active January 21, 2025 21:51
Bringing AI to Git commit.
function gcm
# Check if llm is installed, if not, install it
if not type -q llm
echo "'llm' is not installed. Attempting to install it using pip..."
if pip install llm
echo "'llm' installed successfully."
else
echo "Failed to install 'llm'. Please install it manually and try again."
return 1
end
@karpathy
karpathy / add_to_zshrc.sh
Created August 25, 2024 20:43
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
{
"input": {
"blocklist": [],
"compressor#0": {
"attack": 5.0,
"boost-amount": 6.0,
"boost-threshold": -72.0,
"bypass": false,
"dry": -100.0,
"hpf-frequency": 10.0,
@kj800x
kj800x / Hacking the LG Monitor's EDID.md
Last active June 22, 2025 11:19
Hacking the LG Monitor's EDID

preface: Posting these online since it sounds like these notes are somewhat interesting based on a few folks I've shared with. These are semi-rough notes that I basically wrote for myself in case I ever needed to revisit this fix, so keep that in mind.

I recently bought an LG ULTRAGEAR monitor secondhand off of a coworker. I really love it and it's been great so far, but I ran into some minor issues with it in Linux. It works great on both Mac and Windows, but on Linux it displays just a black panel until I use the second monitor to go in and reduce the refresh rate down to 60 Hz.

This has worked decent so far but there's some issues:

  • It doesn't work while linux is booting up. The motherboards boot sequence is visible just fine, but as soon as control is handed over to Linux and I'd normally see a splash screen while I'm waiting for my login window, I see nothing.
  • It doesn't work on the login screen. This would be fine if login consistently worked on my second screen, but I need to manually switch
@extratone
extratone / targetffmpeg.sh
Created February 16, 2023 02:05
Resize a video file to a specific target size with ffmpeg. ([Source](https://stackoverflow.com/a/61146975/14383008))
#!/bin/bash
#
# Re-encode a video to a target size in MB.
# Example:
# ./this_script.sh video.mp4 15
T_SIZE="$2" # target size in MB
T_FILE="${1%.*}-$2MB.mp4" # filename out
# Original duration in seconds
Ubuntu 22.04, AMD Kabini APU - switch to amdgpu kernel driver.
1. Check current driver:
$ lspci -k | grep -A 3 -E "(VGA|3D)"
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Kabini [Radeon HD 8400 / R3 Series]
Subsystem: Samsung Electronics Co Ltd Kabini [Radeon HD 8400 / R3 Series]
Kernel driver in use: radeon
Kernel modules: radeon, amdgpu
---
if "Kernel driver in use: radeon" - you need to switch.
2. $ sudo featherpad /etc/default/grub
@jdtimmerman
jdtimmerman / powertop-autotune
Last active August 2, 2024 16:17
Run powertop --auto-tune but exclude some devices
#!/usr/bin/env sh
# Script for running powertop --auto-tune but disable optimizations for some devices
#
# Based on solution from https://askubuntu.com/a/1026527/53903
powertop --auto-tune
devices=(
"0001:abcd" # My important device
@noahp
noahp / cross-static-rsync.sh
Created September 27, 2021 23:51
Cross-compile rsync in static mode
# get rsync
❯ git clone [email protected]:WayneD/rsync.git
❯ git checkout v3.2.3 # recent tag
# get musl cross toolchain from https://musl.cc/
❯ wget https://musl.cc/arm-linux-musleabihf-cross.tgz
❯ tar zxvf arm-linux-musleabihf-cross.tgz
# now add the toolchain to path and configure + make
❯ export PATH=$PATH:$PWD/arm-linux-musleabihf-cross/bin
starting pid 1017, tty '/dev/ttyS0': '/usr/bin/login.sh'
(none) login: ROM: Use nor flash.
ERR: Param type error
ERR: Param type error
R
U-Boot 2010.06-dirty (Dec 02 2020 - 10:12:00)
DRAM: 64 MiB
SF: Got idcode 20 70 18 20 70
/ip address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
add address=192.168.1.2/24 network=192.168.1.0 broadcast=192.168.1.255 interface=WAN1
add address=192.168.2.2/24 network=192.168.2.0 broadcast=192.168.2.255 interface=WAN2
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=221.132.112.8,8.8.8.8
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2