Skip to content

Instantly share code, notes, and snippets.

@zevaverbach
zevaverbach / id_rsa.pub
Created December 28, 2023 18:45
id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDiUFb1IFEx/wV7z4/j6VevX5RJzlOB35aS4aXUSwaqfqFn/lq9/z73sfqymFUyH+lpFU8bqJ9CopT+pAj1OoJTdnb1guTEqdkwiwlAdU7rVn4c3qTU2o3Nk4f/85/FOWZJzXwAHK/CvRpiHVKBQv25gyW3rMCD/Gnx/KfUC5cwoQEyAfW91O+JmgkgWupka/+Rdgao1G942qbM4MseiAuL1E3TN2YkrrAVKX8DvueS35GvK707qpgyia02NOcsHStmONEd/daKl3qzJSfhETJc7ucE7/1vX/mHqpRP30ICc19knPMuzHQv9Gfh4r58om1xcul9DHAjuduVbYVJyKHzeYNxQ7XQT4+GrucPS/Fcut01fqAy+7FVFr/Ox/K8bpfXzuuZNaThFuMqD/SdX/Oq7ZeMKwAKp+arBrdjzQsUBVYxxAqgAga/kdd10VgiD8h2XCQHbyg5KvpPZ8G3VC/ya+1iDLkeNEfPow3l7z5LQmGxD1J417yaTi0LzEccuSM= zev@Zevs-MBP.fritz.box
@zevaverbach
zevaverbach / .bashrc
Created November 7, 2023 15:21
basic .bashrc and .vimrc to hit the ground running
bind -r '\C-s'
stty -ixon
@zevaverbach
zevaverbach / main.js
Last active November 20, 2023 06:55
Get remaining time in a Teachable course
// I created this for (and tested it on) a learn.cantrill.io course
// to quickly determine how much more video I have left to finish the course,
// so I could plan my time in advance of an AWS exam.
function getTotalMinutesLeftInCourse() {
let totalMinutes = 0;
for (const chapter of getChapters()) {
if (!chapterIsComplete(chapter)) {
const [minutes, seconds] = getMinutesAndSeconds(getLengthString(chapter.innerText))
@zevaverbach
zevaverbach / post-checkout
Created April 26, 2023 15:36
some git hooks for encrypting and decrypting secret files automatically, from this blog post: https://zev.averba.ch/oops
#!/bin/sh
# ~/.githooks/post-checkout, identical to post-commit
set -o nounset
FILE_PATTERN="\\.bashrc\\|\\.env"
ENCRYPTED_PATTERN="\\$ANSIBLE_VAULT"
decrypt_if_needed() {
local file=$1
@zevaverbach
zevaverbach / gist:0f3668cd2e3f42c6d2f152b97471461e
Created February 5, 2023 10:09
wp 6.1.1 response to POST
{"id":5,"date":"2023-02-05T10:05:40","date_gmt":"2023-02-05T10:05:40","guid":{"rendered":"https:\/\/myxomycete-principa.000webhostapp.com\/2023\/02\/test-wp-api","raw":"https:\/\/myxomycete-principa.000webhostapp.com\/2023\/02\/test-wp-api"},"modified":"2023-02-05T10:05:40","modified_gmt":"2023-02-05T10:05:40","password":"","slug":"test-wp-api","status":"publish","type":"post","link":"https:\/\/myxomycete-principa.000webhostapp.com\/2023\/02\/test-wp-api","title":{"raw":"Test WP-API","rendered":"Test WP-API"},"content":{"raw":"This is my first post created using restAPI","rendered":"<p>This is my first post created using restAPI<\/p>\n","protected":false,"block_version":0},"excerpt":{"raw":"","rendered":"<p>This is my first post created using restAPI<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"permalink_template":"https:\/\/myxomycete-princip
@zevaverbach
zevaverbach / get_cs61a_vids.sh
Last active January 23, 2023 20:59
Download all the CS61A videos (UC Berkeley 2011)
# The lecture listing is here: https://archive.org/details/ucberkeley-webcast-PL3E89002AA9B9879E?sort=titleSorter
# NOTE: the URLs were obtained by running this in the JS console on each of the lecture pages:
# > copy(document.getElementsByClassName("item-download-options")[0].children[2].children[1].href)
cat vid_urls.txt | while read line; do echo $line | wget $line -O lecture_$(sed -E 's/.*Lecture%20([0-9]+).*/\1/').mp4; done
@zevaverbach
zevaverbach / plugins_to_try.txt
Last active December 16, 2021 14:07
vim plugins to try (from this talk https://www.youtube.com/watch?v=434tljD-5C8 by Jess Archer)
airline.vim
arduino.vim
coc.vim
commentary.vim
context-commentstring.vim
dispatch.vim
dracula.vim
editorconfig.vim
eunuch.vim
exchange.vim
@zevaverbach
zevaverbach / copy_urls_from_reminders.kmmacros
Last active December 1, 2021 12:17
A Keyboard Maestro macro to copy the URLs from an Apple Reminders list to a text file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>CreationDate</key>
<real>657286652.24957097</real>
<key>Macros</key>
@zevaverbach
zevaverbach / partition.py
Created November 8, 2021 11:45
Partition a list in Python 3.7
from typing import Dict, Tuple, Any, List
def make_tuple_partitions(
unique_values: List[Any], num_partitions: int
) -> Dict[Tuple[int, int], Tuple[Any, Any]]:
"""
Given a list of values, return a dictionary with (the_index, the_index + 1) as the keys
and (chunk_start_value, chunk_end_value) as the values such that the chunks are equal
or close to equal in size.
@zevaverbach
zevaverbach / convert_sqlalchemy_model_to_table_str.py
Created October 27, 2021 11:06
Some spaghetti to produce a SQLAlchemy Table *string* from a SQLA model.
import re
from black import format_str, FileMode
def convert_tablemapping_to_table_object(model) -> str:
schema_name = model.__table_args__["schema"].lower()
table_repr = repr(model.__table__)
header_str, *columns = table_repr.split("Column(")
# from https://stackoverflow.com/a/4145486/4386191