Skip to content

Instantly share code, notes, and snippets.

View jxu's full-sized avatar
:shipit:
If it compiles it ships

jxu

:shipit:
If it compiles it ships
  • Wit's End
View GitHub Profile
@jxu
jxu / password.py
Created September 13, 2019 22:17
simple password generator
import string, random
pool = string.ascii_letters + string.digits
print(''.join(random.choices(pool, k=16)))
@jxu
jxu / filter-screenshots
Created October 18, 2019 21:27
bash experiment
#!/bin/bash
# Doesn't seem to handle filenames with spaces correctly
find . -iname "*.png" -type f -exec identify -format '%w %h %i\n' '{}' \; |
awk '($1==1080 && $2==1920) || ($1==1920 && $2==1080) || ($1==648 && $2==1108) { print $3 }' | xargs cp -t filter
" Fix text/data segment dump of MARS 4.5
" Convert tabs to 8 spaces
set tabstop=8
retab
" Justify line number col: select visual block then indent
<C-v> >
@jxu
jxu / google-chrome.desktop
Last active December 31, 2019 20:53
obsolete --force-device-scale-factor
# Put in ~/.local/share/applications to override .desktop file in /usr/share/applications
[Desktop Entry]
Version=1.0
Name=Google Chrome
# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413.
GenericName=Web Browser
GenericName[ar]=متصفح الشبكة
GenericName[bg]=Уеб браузър
GenericName[ca]=Navegador web
#!/bin/bash
# Executing grep every time is a little slow, but bash regex doesn't support
# lazy evaluation and it's not worth rewriting...
IFS='' # Preserve whitespace for read
while read p; do # Read /boot/grub/grub.cfg line by line
LINE_REGEX=`echo $p | grep -Po "menuentry ['\"]\K.+?(?=['\"])"`
if [ "$LINE_REGEX" ]; then
# Submenu lines begin with a tab, so lazy method is to check for that
@jxu
jxu / pkg-list.sh
Created October 18, 2019 21:40
list packages and size
dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr
@jxu
jxu / rc.local
Created October 18, 2019 21:42
from old chromebook?
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
echo "$1" | tr '\!-~' 'P-~\!-O'
@jxu
jxu / term-colors
Created October 18, 2019 21:47
wip
#!/bin/bash
# See full range of terminal colors
for C in {0..255}; do
tput setab $C
printf "%4d" "$C"
if ((C%16 == 15)); then echo; fi
done
tput sgr0
@jxu
jxu / download_audio
Last active July 24, 2022 20:07
`--audio-quality 320k` to set bitrate but unnecessary
yt-dlp -x --audio-format mp3 $1