Skip to content

Instantly share code, notes, and snippets.

@isaac-ped
isaac-ped / git-trash
Created August 7, 2023 00:16
git-trash
#!/usr/bin/env bash
REALPATH="$(nix-shell -p coreutils -p which --pure --run 'which realpath')"
#echo $REALPATH
usage() {
echo "Usage: $0 files..."
echo "Move files into a datestamped .trash/ directory at the root of the git repo"
}
@isaac-ped
isaac-ped / .envrc
Created June 27, 2023 18:43
Minimal nix setup
#!/usr/bin/env bash
## This is copied directly from `lorri init`
# the shebang is ignored, but nice for editors
if type -P lorri &>/dev/null; then
eval "$(lorri direnv)"
else
echo 'while direnv evaluated .envrc, could not find the command "lorri" [https://github.com/nix-community/lorri]'
use nix
@isaac-ped
isaac-ped / enable-touchbar-sudo.sh
Last active June 22, 2023 17:05
Enable touch-id authentication for sudo privileges on mac OS
#!/usr/bin/env bash
# From: https://it.digitaino.com/use-touchid-to-authenticate-sudo-on-macos/
# Check if it's already done
if grep 'auth[[:space:]]*sufficient[[:space:]]*pam_tid.so' /etc/pam.d/sudo; then
echo "Already done"
else
# One-liner to do it
sudo sed -i.backup 's/\(auth[[:space:]]*sufficient[[:space:]]*pam_smartcard.so\)/\1\nauth sufficient pam_tid.so/' /etc/pam.d/sudo
fi
@isaac-ped
isaac-ped / ResourceGroup.py
Last active May 8, 2023 21:30
Automatic instantiation of single-use component resources
"""
Automatically define singleton resource groups
The structure of the python pulumi library is such that many properties
of resources are not easily modifyable after initialization.
This module functions by delaying the creation of resource attributes
within the ResourceGroup class until the class has been fully instantiated.
"""
from typing import Any, ClassVar, Iterable, TypeVar, Generic
@isaac-ped
isaac-ped / index.html
Created April 29, 2023 21:15
gibbering attempts
This file has been truncated, but you can view the full file.
<html>
<head><meta charset="utf-8" /></head>
<body>
<div> <script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script type="text/javascript">/**
* plotly.js v2.20.0
* Copyright 2012-2023, Plotly, Inc.
* All rights reserved.
* Licensed under the MIT license
*/
@isaac-ped
isaac-ped / local.nix
Created April 26, 2023 22:37
Nix file defining additional packages to import to darwin-configuration.nix
{ pkgs, ... } :
{
environment.systemPackages = [
pkgs.gh # The github command-line tool
pkgs.unixtools.watch # The 'watch' command
];
}
@isaac-ped
isaac-ped / wifi-qrcode.sh
Created April 13, 2023 20:05
Create WIFI QRCode
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p qrencode
usage() {
echo "Usage: $0 <SSID> <PASSWORD> [-e ENCODING] [-o OUTPUT] -- Passthrough to qrencode"
echo "ENCODING defaults to WPA, but can also be WEP"
echo "OUTPUT defaults to <SSID>.png"
}
ssid=""
def log_exception(msg: str, e: Exception) -> None:
"""Log detailed exception info.
Only the exception stack logs to logging.critical
Local variales are also appended to logging.debug
:param msg: A message to prefix the exception output
:param e: An exception object to inspect for local variables
"""
@isaac-ped
isaac-ped / trash
Last active January 14, 2021 20:14
Trash, don't remove!
#!/bin/bash -e
usage() {
echo "Move to trash directory without deleting"
echo "Usage: $(basename $0) [-v] thing-to-trash1 [thing-to-trash2 ...]"
}
VERBOSE=0
POSITIONAL=""
while (( "$#" )); do # While there are arguments left
Time for the annual unnecessary-analysis-of-isaac’s-text-messages:
This year, the relatively-most-common words:
Me Alex Abhi Julia George Deborah Emily Ocko
0 hahah julia's upto kk okey hahaa watcha na
1 till downstairs aite dunno dokey hihi bitch subway
2 tired gotcha sixers alex didnt hbu porch megs
3 headed janki walnut thanks thats lololol dope meg
4 hah julia pm ha dont etc suburbs st
5 naw ken quizzo guys its hooray science breakfast
6 hahahah min otherwise well im stephen comin