Skip to content

Instantly share code, notes, and snippets.

View InternetUnexplorer's full-sized avatar

InternetUnexplorer

  • Portland, OR
View GitHub Profile
@InternetUnexplorer
InternetUnexplorer / print-report.py
Created December 22, 2022 06:01
Python script for pretty-printing timing/utilization reports produced by nextpnr
#! /usr/bin/env python3
#
# This script pretty-prints timing/utilization reports produced by nextpnr.
# You can use it in your build process like this:
#
# nextpnr-ecp5 ... --report report.json
# ./print-report.py < report.json
#
# License: CC0 <https://creativecommons.org/publicdomain/zero/1.0>
@InternetUnexplorer
InternetUnexplorer / command-not-found.sh
Last active March 17, 2024 11:53
Improved home-manager nix-locate configuration, with an auto-updated index and a better command-not-found handler
# Adapted from https://github.com/bennofs/nix-index/blob/master/command-not-found.sh
command_not_found_handle () {
if [ -n "${MC_SID-}" ] || ! [ -t 1 ]; then
>&2 echo "$1: command not found"
return 127
fi
echo -n "searching nix-index..."
ATTRS=$(@nix-locate@ --minimal --no-group --type x --type s --top-level --whole-name --at-root "/bin/$1")
@InternetUnexplorer
InternetUnexplorer / reactor.lua
Created May 15, 2022 00:05
ComputerCraft program to control a Mekanism fission reactor
local state, data, reactor, turbine, info_window, rules_window
local STATES = {
READY = 1, -- Reactor is off and can be started with the lever
RUNNING = 2, -- Reactor is running and all rules are met
ESTOP = 3, -- Reactor is stopped due to rule(s) being violated
UNKNOWN = 4, -- Reactor or turbine peripherals are missing
}
------------------------------------------------
@InternetUnexplorer
InternetUnexplorer / discord.nix
Last active March 10, 2022 06:13
Hacky workaround for the Discord desktop tray icons being blurry
# This is a hacky workaround for the Discord desktop app tray icons being
# blurry. It adds a script to the top of the app's wrapper script that unpacks
# `core.asar` (the archive containing the icons), replaces the 24x24 icons with
# 128x128 ones from the Papirus icon theme, and repacks everything. The sha256
# of the patched `core.asar` is saved in `core.asar.sha256` and checked when the
# script is run again to avoid repeated work.
#
# Comparison: https://i.imgur.com/SBGJlzX.png
#
# It should work with discord, discord-ptb, and discord-canary.
@InternetUnexplorer
InternetUnexplorer / cross-compiler.nix
Created December 28, 2021 22:03
Nix derivation for an rv32i/ilp32 cross compiler
# nix profile install -f cross-compiler.nix
let
pkgs = import <nixpkgs> {
crossSystem = {
config = "riscv32-none-elf";
libc = "newlib";
gcc.abi = "ilp32";
gcc.arch = "rv32i";
};
};
@InternetUnexplorer
InternetUnexplorer / ckan.nix
Created September 20, 2021 19:07
Nix shell providing CKAN with a patched version of Mono that fixes https://github.com/KSP-CKAN/CKAN/issues/3359
{ pkgs ? import <nixpkgs> { } }:
let
patchedMono = pkgs.mono.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [
(pkgs.fetchpatch {
url = "https://patch-diff.githubusercontent.com/raw/mono/mono/pull/21136.patch";
sha256 = "sha256-4mUkkRl2IoNjkZN8+1Ps3kvI9Tu2BnH4YqeRZ6A/UMU=";
})
];
@InternetUnexplorer
InternetUnexplorer / gps_installer.lua
Created March 19, 2021 05:43
ComputerCraft program to make setting up a GPS cluster a bit easier
local read_position
read_position = function()
local read_axis
read_axis = function(name, color)
term.setTextColor(color)
write(tostring(name) .. ": ")
term.setTextColor(colors.white)
return tonumber(read())
end
print("Enter the position of this computer (NOT the position of the modem).")
@InternetUnexplorer
InternetUnexplorer / wg-menu.sh
Last active August 16, 2021 04:06
Script to quickly connect to/disconnect from WireGuard servers using wg-quick.
#! /usr/bin/env bash
set -euo pipefail
CONFIG_DIR="$XDG_DATA_HOME/WireGuard"
STATE_FILE="/tmp/wg-menu"
color() { echo -n "$(tput bold)$(tput setaf ${1})${2}$(tput sgr 0)" ; }
step() { echo "$(color 2 '[*]') $(color 7 "${@}")" ; }
@InternetUnexplorer
InternetUnexplorer / kwin-lowlatency-build.sh
Last active February 18, 2021 04:28
Systemd timer/service file and hooks for nix-channel-watcher
#! /usr/bin/env bash
REPOSITORY=InternetUnexplorer/kwin-lowlatency-overlay
set -eu
source .secrets
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
@InternetUnexplorer
InternetUnexplorer / fix-starlight.patch
Created January 1, 2021 20:52
Patch and NixOS overlay to add support for starlight mode on the Mid 2017 Razer Blade Stealth to OpenRazer
diff --git a/driver/razerkbd_driver.c b/driver/razerkbd_driver.c
index 909a797..a209cfc 100644
--- a/driver/razerkbd_driver.c
+++ b/driver/razerkbd_driver.c
@@ -1242,6 +1242,7 @@ static ssize_t razer_attr_write_mode_starlight(struct device *dev, struct device
}
break;
+ case USB_DEVICE_ID_RAZER_BLADE_STEALTH_MID_2017:
case USB_DEVICE_ID_RAZER_BLADE_STEALTH_LATE_2017: