Skip to content

Instantly share code, notes, and snippets.

@jdiaz5513
jdiaz5513 / ascii_arty.py
Last active December 30, 2023 02:32
Console ASCII Art Generator
#! /usr/bin/env python2
# Requires: PIL, colormath
#
# Improved algorithm now automatically crops the image and uses much
# better color matching
from PIL import Image, ImageChops
from colormath.color_conversions import convert_color
from colormath.color_objects import LabColor
from colormath.color_objects import sRGBColor as RGBColor
@fevangelou
fevangelou / my.cnf
Last active August 22, 2025 08:47
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated September 2024 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
#!/usr/bin/python3
"""
Usage:
plasmasetconfig # List all widget namespaces
plasmasetconfig org.kde.plasma.digitalclock # List all config groups+keys
plasmasetconfig org.kde.plasma.digitalclock Appearance showSeconds true
Install:
chmod +x ~/Downloads/plasmasetconfig.py
sudo cp ~/Downloads/plasmasetconfig.py /usr/local/bin/plasmasetconfig
Uninstall:
/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
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
@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
@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
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
@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
@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