Skip to content

Instantly share code, notes, and snippets.

@s-zeid
s-zeid / numbers.py
Last active December 29, 2015 15:19
#!/usr/bin/env python
import sys
STRINGS = dict(
negative = ["negative"],
base = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
"nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"],
tens = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"],
#!/usr/bin/env python2
import random
import re
import threading
import time
import sys
class JokeSorts:
@classmethod
#!/bin/sh
# Thanks to Zorawar on unix.stackexchange: <https://unix.stackexchange.com/a/202489>
KEYBOARD_ID=12 # from `xinput list`
press="key press "
release="key release"
@s-zeid
s-zeid / 80-udisks2-ignore-loop.rules
Last active October 6, 2018 08:48
udev rules file to make udisks ignore loop devices
KERNEL=="loop*", ENV{UDISKS_IGNORE}="1"
@s-zeid
s-zeid / disable-wakeups.service
Created March 8, 2020 09:52
Disable USB and lid wakeup triggers in /proc/acpi/wakeup. Adapted from <https://bbs.archlinux.org/viewtopic.php?pid=1575617#p1575617> by 9233.
[Unit]
Description=Disable USB and lid wakeup triggers in /proc/acpi/wakeup
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'for i in EHC1 EHC2 XHC LID0; do echo $i > /proc/acpi/wakeup; done'
ExecStop=/bin/sh -c 'for i in EHC1 EHC2 XHC LID0; do echo $i > /proc/acpi/wakeup; done'
RemainAfterExit=yes
[Install]
@s-zeid
s-zeid / tt-rss.css
Last active March 14, 2020 12:17
Custom colors, fonts, and scrollbars for Tiny Tiny RSS
/* Options */ :root {
--accent-normal: #642792;
--accent-light: #642792cc;
--accent-dark: #642792;
--scrollbar-thumb-normal: #ccc;
--scrollbar-thumb-sidebar: #d8d8d8;
--scrollbar-thumb-inactive: #e6e6e6;
--scrollbar-track: transparent;
--font-family-sans: "Ubuntu", "Droid Sans", "Trebuchet MS", "DejaVu Sans", "Bitstream Vera Sans", "Verdana", sans-serif;
@s-zeid
s-zeid / gtk-3.0_light-font.css
Last active March 14, 2020 13:43
Force light font in GTK+ 3 windows
window {
font-weight: 300;
}
@s-zeid
s-zeid / get-sessionstore-json.js
Last active April 8, 2020 07:49
Get sessionstore JSON for a single Firefox window (including private windows)
// Run in Browser Console (Ctrl+Shift+J; ≡ menu → Web Developer → Browser Console),
// then right click on the JSON output and click Copy object.
// Use (eg.) <https://code.s.zeid.me/bin/blob/master/sessionstore2html> to convert to HTML.
SessionStore.getWindowState(window);
@s-zeid
s-zeid / mpv.kwin-translucent-hack.conf
Last active April 10, 2020 21:34
mpv + kwin - Hack to make the window translucent when there is no video track
[kwin-translucent-hack]
# Hack to make the window translucent when there is no video track.
#
# * Set up 2 KWin window rules:
# * class: exact match `mpv`, title: regular expression `\x034f$`
# -> active/inactive opacity: force 50%
# * class: exact match `mpv`, title: regular expression `^[^\x034f]*$`
# -> active/inactive opacity: force 100%
#
# * U+034F is used because KWin strips non-printable characters and replaces
@s-zeid
s-zeid / qisprint.cc
Last active April 14, 2020 17:15
Print whether Qt 5's `QChar::isPrint()` is true for one or more code points
// g++ -fPIC -I/usr/include/qt5 -lQt5Core qisprint.cc -o qisprint
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <QtCore/qchar.h>