Skip to content

Instantly share code, notes, and snippets.

@violet4
violet4 / detect_functional_dependencies.py
Created August 29, 2018 13:54
detect_functional_dependencies.py
#!/usr/bin/env python
import os
import subprocess
from itertools import combinations
from mysql import connector
conn = connector.connect(
option_files=os.path.expanduser('~/.my.cnf'),
# note that this only works on linux-based OSes like ubuntu and mac. doesn't work on windows.
password=subprocess.check_output('grep password ~/.my.cnf | head -1 | sed s/.*=//', shell=True).decode().strip()[1:-1],
@violet4
violet4 / brightness.py
Created January 4, 2022 02:54
interactive python curses script that uses redshift to change the gamma/redness using arrow keys
#!/usr/bin/env python3
import curses
import subprocess
import re
# use something that won't hurt the eyes if it's evening
brightness_re = re.compile(r'Color temperature: (\d+)K')
start_brightness = 3000
#!/usr/bin/env python3
"""
only works on macos, and isn't configurable. for now, just change the code directly.
hit the spacebar to take a picture. i wrote this for taking pictures of all my mtg cards as easily as possible.
"""
import curses
import subprocess
import os
import sys
@violet4
violet4 / uri_handler_add.py
Created October 18, 2023 23:52
uri_handler_add.py
#!/usr/bin/env python3
"""
Add a new uri handler for any .desktop system that follows XDG (X Desktop Group) standards.
Requires that you have update-desktop-database executable in your PATH.
"""
import os
import argparse
import logging
import subprocess
@violet4
violet4 / zfs_syncoid_configuration.md
Last active February 1, 2025 04:42
Configure syncoid (sanoid) to stream backups across the network with good security practices.

Caveats

Ensure the path to your zfs binary is correct on each machine wherever the full path appears below. For both my source and destination machines, this is /usr/sbin/zfs.

Source Machine

# -r, --system create a system account
useradd -r zfsbackup
mkdir -p /home/zfsbackup/.ssh
@violet4
violet4 / 0 Linux-On-MBP-Late-2016.md
Created March 11, 2025 23:15 — forked from roadrunner2/0 Linux-On-MBP-Late-2016.md
Linux on MacBook Pro Late 2016 and Mid 2017 (with Touchbar)

Introduction

This is about documenting getting Linux running on the late 2016 and mid 2017 MPB's; the focus is mostly on the MacBookPro13,3 and MacBookPro14,3 (15inch models), but I try to make it relevant and provide information for MacBookPro13,1, MacBookPro13,2, MacBookPro14,1, and MacBookPro14,2 (13inch models) too. I'm currently using Fedora 27, but most the things should be valid for other recent distros even if the details differ. The kernel version is 4.14.x (after latest update).

The state of linux on the MBP (with particular focus on MacBookPro13,2) is also being tracked on https://github.com/Dunedan/mbp-2016-linux . And for Ubuntu users there are a couple tutorials (here and here) focused on that distro and the MacBook.

Note: For those who have followed these instructions ealier, and in particular for those who have had problems with the custom DSDT, modifying the DSDT is not necessary anymore - se

@violet4
violet4 / about_this_page.html
Created March 15, 2025 23:35
A webpage that tells you as much about itself as it can using javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A tool to explore webpage information">
<meta name="author" content="Example Author">
<title>Webpage Information Explorer</title>
<style>
body {
<!DOCTYPE html>
<html>
<head>
<title>Proportion Calculator</title>
</head>
<body>
<div>
<div>
<input id="proportion_numerator" type="number" placeholder="Proportion Numerator">
<input id="amount_numerator" type="number" placeholder="Amount Numerator">