This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- indent-tabs-mode: nil; tab-width: 4 -*- | |
"""Enable/disable tablet mode in a Crouton chroot based on lid angle.""" | |
import argparse | |
import logging | |
import logging.config | |
import math | |
import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Transfers VPN tunnel interface to a network namespace as its only | |
# non-localhost interface. | |
# | |
# Based on <https://github.com/slingamn/namespaced-openvpn>. | |
sudo ip netns add protected | |
sudo ip netns exec protected ip link set lo up | |
sudo openvpn "$@" --ifconfig-noexec --route-noexec --script-security 2\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# -*- indent-tabs-mode: nil; tab-width: 4 -*- | |
# | |
# An ugly way to bind extra mouse buttons under GNOME/Wayland or otherwise. | |
# | |
# Prerequisites: | |
# | |
# Effectively unbind extra mouse buttons by modifying udev/hwdb rules: | |
# 1. Identify scancodes: | |
# sudo evemu-record /dev/input/by-path/*event-mouse \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hybrid UEFI/BIOS multiboot USB drive | |
# Install required packages | |
sudo apt install gdisk grub2-common grub-efi-amd64-bin grub-pc-bin qemu-system | |
# Create an empty disk image | |
target_size=3.6G # $(lsblk -b --output SIZE -n -d /dev/sdX) for drive size | |
qemu-img create -f raw boottitikku.img "$target_size" | |
# Create a GUID Partition Table (GPT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# [Gedit Tool] | |
# Name=Calculate | |
# Input=selection | |
# Output=replace-selection | |
# Applicability=always | |
# Save-files=nothing | |
# Shortcut=<Primary><Alt>c | |
# Languages= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# -*- indent-tabs-mode: nil; tab-width: 4 -*- | |
command=${@:-"mitmproxy --mode transparent --showhost --set block_global=false"} | |
if [ ! -f "/etc/ssl/certs/mitmproxyuser.pem" ]; then | |
sudo apt --yes install inotify-tools mitmproxy nftables | |
sudo useradd --create-home mitmproxyuser | |
grep --max-count 1 "mitmproxy-ca-cert.pem" < <( \ | |
sudo inotifywait -mrq -e close_write --format "%f" \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HISTSIZE=1000000 | |
HISTFILESIZE=1000000 | |
HISTCONTROL=ignoreboth | |
shopt -s histappend | |
shopt -s histreedit | |
shopt -s histverify | |
PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" | |
PATH=$PATH:~/bin | |
PATH=$PATH:~/.local/bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Syncthing status.""" | |
# https://nelsonslog.wordpress.com/2021/10/01/syncthing-status-from-the-command-line/ | |
# https://svn.blender.org/svnroot/bf-blender/trunk/blender/build_files/scons/tools/bcolors.py | |
# https://docs.syncthing.net/dev/rest.html | |
import json | |
import re |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @name Click all radios | |
// @description Selects a random radio button from each uniquely named radio group. | |
javascript:(() => { | |
Object.values(Object.groupBy(document.querySelectorAll('input[type="radio"]'), e => e.getAttribute("name"))).forEach((arr) => { | |
arr[Math.floor(Math.random() * arr.length)]?.click?.(); | |
}); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Reconstructs the numerator of a rounded rational number. | |
All fractions p/q are uniquely identifiable iff abs(q) <= 10**d. | |
Args: | |
x (float): Rounded decimal value. | |
d (int): Maximum decimal places used in rounding. | |
q (int): Denominator of the fraction. | |
r (callable, optional): Rounding function (default is round). |
OlderNewer