Skip to content

Instantly share code, notes, and snippets.

@dreness
dreness / ifsocket.sh
Created February 7, 2021 21:52
Realtime graph from WebSocket data
#!/bin/zsh
D=$(date "+%Y-%m-%d")
#D=$(date "+%s")
ifstat -t -n -i en0 \
| sed -l '1d;2d' \
| while read -A IFSTAT
do
echo -n "{"
echo -n "\"Time\": \"${D} ${IFSTAT[1]}\", "
#echo -n "\"Time\": \"${IFSTAT[1]}\", "
@dreness
dreness / lscap.py
Created December 5, 2020 16:17
Reformat tcpdump output for logstalgia on macOS
# /usr/bin/env python -u
from colorhash import ColorHash
from pprint import pprint as pp
from pcapng import FileScanner
import asyncio
import sys
import re
cmd = "tcpdump --immediate-mode -l -g -k -n -i pktap,en0 ip or udp"
@dreness
dreness / stargazer-repos.graphql
Created November 25, 2020 05:04
Enumerate pinned items owned by stargazers of a repository with given owner and name
query ($owner: String!, $name: String!, $gazers: Int, $items: Int) {
repository(owner: $owner, name: $name) {
name
description
resourcePath
id
stargazers(last: $gazers, orderBy: {field: STARRED_AT, direction: DESC}) {
edges {
starredAt
node {
@dreness
dreness / websizer.py
Created October 9, 2020 06:20
Sum Content-Lengths of a bunch of HTTP resources on servers that might not return Content-Length in HEAD responses.
#!/usr/bin/env/ python
import requests
import fileinput
import sys
from humanfriendly import format_size
f = open("/Users/andre/Desktop/urls.txt", "r")
s = requests.session()
@dreness
dreness / playbackRate_sandbox.html
Created October 8, 2020 01:12
Compare the shrill, harsh timbres of Safari's audio playback at rates other than 1.0x with the much more respectable output from Chrome.
<html>
<head>
<title>html5 video / audio playbackRate sandbox</title>
<style>
body {
height: 99%;
}
div {
@dreness
dreness / gist:35fceeb1bb17ae757ef429a2a5628fbd
Created September 13, 2020 22:37
letsencrypt_synchronize_certs.sh
#!/bin/bash
set -x
set -e
# This script intends to compliment an automated LetEncrypt setup on
# OS X Server. After updating certs, the new files should be imported into
# Keychain, which Server will notice. Amusingly, we need to encrypt the
# certs for this to work, so this script does that (hard-coded password!)
# Developed by Greg Miller, grmiller@ucdavis.edu
# Version 3.05
# Last Updated April 13, 2020
# Tweaks by Dre on 8/18/2020 to fix bad assumptions about file paths
# Purpose: To compile publicly-available CAISO system-wide electricity demand, supply, and emissions data into a csv file
# Currently configured to coninue downloading data until the most recent data has been downloaded.
# All directories and files will be created the first time you run the script
# Run in unbuffered mode to make sure time.sleep() works: $ python -u
@dreness
dreness / what_is_up_with_that.md
Last active July 24, 2020 09:11
Who resolves the resolver?

I remember this one time, I was messing with stuff and my DNS lookups stopped working. So I looked around...

effective DNS servers for en0

❯ scutil --dns | grep -B 1 en0        
  nameserver[0] : 2600:1700:43b0:d640::1
  if_index : 18 (en0)
--
  nameserver[0] : 2600:1700:43b0:d640::1
  if_index : 18 (en0)
@dreness
dreness / iShapeParser.py
Created July 22, 2020 20:29
Export Keynote shapes to SVG
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json # Native JSON Library
import argparse # Native Argument parser Library
# This is a slightly updated version of a script found on ye cyberwebs to
# add batch conversion support. Just don't specify an image ID to export the world.
# ==============================#
@dreness
dreness / notes.md
Created June 24, 2020 05:53
Low Latency HLS test: how low can you go?