Skip to content

Instantly share code, notes, and snippets.

@varenc
varenc / Quickly look up a URL in the Wayback Machine in Chrome
Last active July 22, 2024 11:07
Chrome Wayback Machine search engine/bookmarklet. Accepts full URLs and works on Chrome's New Page window.
data:text/html,<script>location.href='https://web.archive.org/web/*/%s'</script>
@varenc
varenc / close_notifications_applescript.js
Created June 6, 2021 21:56 — forked from lancethomps/close_notifications_applescript.js
AppleScript to close all notifications on macOS Big Sur
function run(input, parameters) {
const appName = "";
const verbose = true;
const scriptName = "close_notifications_applescript";
const CLEAR_ALL_ACTION = "Clear All";
const CLEAR_ALL_ACTION_TOP = "Clear";
const CLOSE_ACTION = "Close";
@varenc
varenc / srt_to_sentences.lua
Last active February 11, 2024 07:48
Combine sentences in a .srt input subtitle. Lua script that works as a command line/terminal utility.
#!/usr/bin/env lua
-------------------------------------
-- This script takes an .srt file as an argument, and outputs an srt file with the sentences combined.
-- Output is sent to STDOUT. So to convert a .srt file, you can do something like this
--
-- $ chmod +x ./srt_to_sentences.lua
-- $ ./srt_to_sentences.lua input.srt > input-sentences.srt
--
-- Optimized for my use case. Try tweaking the options below if you have issues.
-- note: the key property of this over other solutions I found is that the outputed srt timecodes are a strict
@varenc
varenc / fast_home_brew_search.sh
Last active October 22, 2023 11:46
Fast local homebrew `brew search` results. Returns first matches in 0.1 seconds instead of 10-30 seconds.
# Emulate `brew search` but make it fast. Search locally taps only.
# Results are returned immediately, but then the `brew info` is ran for each result which is slow.
function brewSearchFast() {
bold=$(tput bold)
normal=$(tput sgr0)
[[ -z $1 ]] && echo "Input missing" && return;
QUERY=$(echo $1 | tr '[:upper:]' '[:lower:]')
## replace that path with `$(brew --repository)/Library/Taps` if you don't mind an extra 30ms
@varenc
varenc / plaid_ccpa_request_dump_data.py
Created September 3, 2021 18:52
Plaid CCPA data export to JSON converter
#!/usr/bin/env python3
### Converts your Plaid CCPA data export to JSON
#
# Plaid's CCPA export of your personal data comes in a bespoke unparseable format. It's almost
# a literal Python object but not quite. This script converts that data to JSON.
# To make a CCPA request go here: https://plaid.com/legal/data-protection-request-form/
# (You might not even have to be a California resident)
#
# Once you have the data, just call this script and provide one of the files as an argument:
@varenc
varenc / !README.md
Created November 20, 2021 03:40
Economist.com graphql schema

Fetched the graphql schema for the Economist. Introspection is enabled in production. Not a big deal but they should probably turn it off. Their server only accepts GET requests (probably to make cloudflare caching happy) so you can put your query in /tmp/query then query it like this:

$  curl -H "Host: www.economist.com" --compressed -v "https://www.economist.com/graphql?version=v1&operationName=IntrospectionQuery&variables=%7B%7D&query=$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$(cat /tmp/query)")"  | jq
@varenc
varenc / README.md
Last active December 4, 2021 22:03 — forked from Jahhein/README.md
Display Apple AirPods battery levels via Terminal
@varenc
varenc / launchctl_man_pages.md
Created January 6, 2022 00:49 — forked from dmattera/launchctl_man_pages.md
macOS man page entries for launchctl services

This list was auto-generated on macOS 10.15 (Catalina) using a script that did the following:

  1. grabbed the name of all the .plist files located in the 5 folders used by launchctl:
  • ~/Library/LaunchAgents Per-user agents provided by the user.
  • /Library/LaunchAgents Per-user agents provided by the administrator.
  • /Library/LaunchDaemons System wide daemons provided by the administrator.
  • /System/Library/LaunchAgents OS X Per-user agents.
  • /System/Library/LaunchDaemons OS X System wide daemons.
@varenc
varenc / potentially_missing_big_sur_security_fixes.md
Last active January 26, 2022 23:04
Monterey 12.2 security update fixes not present in Big Sur 11.6.3 update

About

This is a list of the Monterey 12.2 security updates not present in the Big Sur 11.6.3 security update. It's unclear if Big Sur is vulnerable to these or not. If Big Sur is though then they appear unpatched at the moment.


AMD Kernel

Available for: macOS Monterey

Impact: A malicious application may be able to execute arbitrary code with kernel privileges

@varenc
varenc / _retrieve_mac_apps.sh
Last active March 29, 2022 23:41
Fix macOS zsh `open -a` application completion! Apple's version has a very old bug. See: https://stackoverflow.com/questions/59865427/zsh-hangs-on-open-application-tab-autocompletion#63097652
#autoload
### 2022-02-09 @varenc
### This is a fixed version of the macOS zsh completion script for the `open` command.
### See my response here for a description of the bug:
### https://stackoverflow.com/questions/59865427/zsh-hangs-on-open-application-tab-autocompletion#63097652
###
### tl;dr; The original completion script is provided by Apple and not-editable by the user without disabling SIP.
### It has a bug in it and doesn't use the Spotlight index to list applications. This makes auto-completion
### for the command "open -a ..." very slow/impossible.