Skip to content

Instantly share code, notes, and snippets.

Avatar

S. Zeid scottywz

View GitHub Profile
@scottywz
scottywz / selfoss.user.css
Last active Oct 9, 2020
Custom CSS for Selfoss
View selfoss.user.css
@variables {
--main-background: #ffffff;
--nav-background: #f6f6f6;
--nav-background-active: #64279219;
--nav-color: #222222;
--nav-faint: #6a6a6a;
--nav-hr: #aaaaaa;
--accent-background: #64279219;
--accent-normal: #642792;
--accent-light: #642792;
@scottywz
scottywz / ms_binary_test.rs
Last active Aug 16, 2020
Rust macros for reading types from binary streams
View ms_binary_test.rs
// Imports {{{1
use std::io;
extern crate byteorder; // 1
use byteorder::{/*ReadBytesExt,*/ LittleEndian};
extern crate num_traits; // 0.2
use num_traits::ToPrimitive;
View toggle-xterm
#!/bin/sh
uid=$(id -u)
if pgrep -u $uid -x 'xterm' >/dev/null 2>&1; then
pkill -u $uid -x 'xterm'
else
xrandr_size=$(xrandr --current --prop | head -n 1 \
| grep -o 'current [0-9]\+ x [0-9]\+' \
| sed -e 's/current //g; s/ x /\n/g')
@scottywz
scottywz / show-script-opt.lua
Last active Jul 30, 2020
custom command (script message) for mpv to show a script option on the OSD
View show-script-opt.lua
-- input.conf usage: <key> script-message show-script-opt <opt-name> <default>
-- Example: t script-message show-script-opt osc-title "${media-title}"
mp.register_script_message("show-script-opt", function(name, default)
local value = mp.get_opt(name)
if not (value == nil or value == "") then
value = mp.command_native({"expand-text", value})
else
value = default or "(unavailable)"
end
View cros83-procfs-workaround
#!/bin/sh
# Workaround for <https://bugs.chromium.org/p/chromium/issues/detail?id=1087937>
# Adapted from /u/ken_duda's comment:
# * <https://old.reddit.com/r/Crostini/comments/gsxx7o/userpid_namespaces_broken_in_crostini_83/fsqn1wj/>
# * <https://bugs.chromium.org/p/chromium/issues/detail?id=1087937#c6>
for name in cpuinfo diskstats meminfo stat uptime; do
sudo umount "/proc/$name"
@scottywz
scottywz / opkg-pkgs-from-image
Created Jul 16, 2020
Get installed packages from an OpenWrt image (requires p7zip-full)
View opkg-pkgs-from-image
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $(basename -- "$0") <image-file>" >&2
exit 2
fi
7z -so e "$1" usr/lib/opkg/status \
| grep '^Package:' | cut -d' ' -f 2 | sort
@scottywz
scottywz / LICENSE.txt
Last active Jul 16, 2020
License for my Gists (unless otherwise specified or not eligible for copyright)
View LICENSE.txt
Copyright (c) S. Zeid. <https://s.zeid.me/>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@scottywz
scottywz / ec2
Created Jun 9, 2020
Convenience script for EC2 instances
View ec2
#!/bin/sh
# Requires AWS CLI version 1 (`pip3 install awscli`)
if ! [ -f "$1" ]; then
printf %s "
This script should be used as the shebang line in another script that looks like
the following (assuming this script is on \$PATH):
@scottywz
scottywz / media
Last active Jun 5, 2020
raspberry pi media tmux window
View media
#!/bin/sh
NAME=media
ACCENT_COLOR='#ab7fcc'
pane_cmd() { echo "echo '\$' $@; $@; PS1='\$ ' exec bash --posix"; }
setup_tmux() {
You can’t perform that action at this time.