Skip to content

Instantly share code, notes, and snippets.

View timmc's full-sized avatar

Tim McCormack timmc

View GitHub Profile
@timmc
timmc / split headers.sh
Last active November 16, 2022 03:23
Get HTTP status code and body in separate variables using curl
View split headers.sh
#!/bin/bash
all_output="$(curl -isS https://www.spidersge.org/)"
status=$(echo "$all_output" | grep -Po '\s[0-9]{3}\s' | head -n1 | tr -dc 0-9)
echo "Status is [$status]"
body="$(echo "$all_output" | sed -ne $'/^\r$/,$p' | tail -n+2)"
echo "Body is [$body]"
@timmc
timmc / delete-tweets.md
Last active April 30, 2022 17:47
Delete all Twitter posts and faves without a developer key
View delete-tweets.md
  • Request archive, wait for them to generate it, download it
  • Open Network Tab
  • Delete a tweet
  • Find a POST to DeleteTweet
  • "Copy as curl"
  • Save to file deltw.sh and mark as executable
  • Add -sS -o /dev/null -w '%{http_code}\n' to the end
  • Replace the tweet ID (just the numbers) with '$1'

Run this:

@timmc
timmc / avvo.py
Last active April 6, 2022 13:54
Avvo reverse attempts
View avvo.py
"""
Attempt to reverse-engineer Avvo.com's hash algorithm,
given a leaked record and a known password.
Sample for validation of hash checker:
$ cat ~/tmp/ram/sample-record.txt
some@email,1199546,3e6139dd5bba6c8617c112abdb026a648e9bf592,45aa026ed8621c824dfa0acbb478d3eef87020bd,NULL
$ cat ~/tmp/ram/sample-password.txt
@timmc
timmc / simantle.js
Last active February 22, 2022 23:02
View simantle.js
var ants = [
'<span style="filter: brightness(0%) saturate(0%)">🐜</span>', // black
'<span style="filter: brightness(220%) saturate(600%) hue-rotate(150deg)">🐜</span>', // red
'<span style="filter: brightness(470%) saturate(1000%) hue-rotate(244deg)">🐜</span>', // yellow
];
function one_ant() {
return ants[Math.floor(Math.random() * 2.2)]; // small chance of yellow
}
View suffolk covid-19 wastewater plot.sh
#!/usr/bin/env bash
set -eu -o pipefail
data_path="/home/timmc/warehouse/biobot-data.csv"
png_path_prefix="/home/timmc/warehouse/biobot-data.Suffolk"
case "$1" in
fetch)
curl -sS https://raw.githubusercontent.com/biobotanalytics/covid19-wastewater-data/master/wastewater_by_county.csv > "$data_path"
;;
View absurdle score.js
var letters = [...document.getElementsByTagName('table')[0].textContent];
var emoji = {'wrong':'❌', 'inexact':'💛', 'exact':'💚'};
var cellClass = 'absurdle__guess-box';
function getEmoji(node) {
var cl = [...node.classList].filter(e => e.startsWith(cellClass + '--'))[0];
return emoji[cl.replace(cellClass + '--', '')];
}
var icons = [...document.querySelectorAll('td.' + cellClass)].map(getEmoji);
var out = "";
while (letters.length > 0) {
View working notes for borg history manifest.md

borg history

New command borg history --manifest will list out all segment entries that are PUTs of an all-zeroes key, along with their decrypted values.

If a repo has been maintained strictly in an append-only manner, and no deletions attempted by an adversary with append-only access, then this will provide a listing of all archives that were ever created. If such an adversary attempts to delete an archive, they'll have to add a

@timmc
timmc / essentially.clj
Last active June 23, 2020 15:25
originally refheap.com/97879
View essentially.clj
(defmacro essentially
"Like letfn, but with the bindings at the end. Connotes that the
bindings are not important for the core logic, just for logging,
metrics, debugging etc. Recommend using footnote-looking bindings such
as *0, *1, *2 or even Unicode daggers if you are super-brave.
This is like Haskell's `where`. Thanks to amalloy for the pointer; no
blame attaches to him, though."
[& args]
`(letfn ~(last args)
~@(butlast args)))
@timmc
timmc / gist:4a4711c15ff87b2735f2c74bc1efba4a
Last active March 16, 2020 01:17
Download all CDC MMWR for 2017
View gist:4a4711c15ff87b2735f2c74bc1efba4a
for i in {01..42}; do curl -sS "https://www.cdc.gov/mmwr/volumes/66/wr/pdfs/mm66${i}.pdf" > "66_${i}.pdf" & done
for i in {43..50}; do curl -sS "https://www.cdc.gov/mmwr/volumes/66/wr/pdfs/mm66${i}-H.pdf" > "66_${i}.pdf" & done
curl -sS "https://www.cdc.gov/mmwr/volumes/66/wr/pdfs/mm665152-H.pdf" > "66_51_52.pdf"
Text extraction:
for x in ./*; do pdftotext $x $x.txt; done
View parallel.sh
#!/bin/bash
# Call a script in a tight loop from multiple processes.
# Run as `$0 master <#seconds> <#children> script-and-args...`.
# seconds and children control run length and concurrency
# Modes:
# master <seconds> <children>: Fork and run n child processes for m seconds
# child: Call on tight loop, indefinitely
# test: Call just once