Skip to content

Instantly share code, notes, and snippets.

@simonsj
simonsj / extract-ttf-from-ttc.py
Created July 12, 2022 01:20
extract-ttf-from-ttc.py
#!/usr/bin/env python3
#
# extract-ttf-from-ttc.py <input.ttc>
#
# Extract individual .ttf files from a .ttc.
#
from fontTools.ttLib import TTCollection
import sys
@simonsj
simonsj / sd.sh
Last active October 4, 2019 22:35
sd.sh -- spool and sniff stdin stream to dispatch depending on contents
#!/bin/bash
#
# sd.sh -- spool and sniff stdin stream to dispatch depending on contents
#
# Dependencies: basename, bash, cat, head, mktemp, stat, tail, tr.
#
set -e
header=$(mktemp -t $(basename $0)-XXXXXX)
@simonsj
simonsj / throttle-count.sh
Created May 16, 2018 19:02
How much time can be attributed to CPU throttling?
#!/bin/sh
# throttle-count.sh -- "how much time can be attributed to CPU throttling?"
stat_nodes=$(find /sys/fs/cgroup/cpu/kubepods -type f -name 'cpu.stat')
for stat_node in $stat_nodes; do
#
# Grab cpu.stat values which will end up looking something like:
#
Hi!
@simonsj
simonsj / show-cgroups-accounting.sh
Last active March 18, 2016 08:56
Scrape out Some cgroups memory.stat Accounting
#!/bin/sh
#
# Original raw output looks something like this:
#
# # cat /sys/fs/cgroup/memory/git/memory.stat
# cache 33129496576
# rss 13348773888
# mapped_file 4296413184
# pgpgin 16204719443
@simonsj
simonsj / ruby-object-grown-str-literals-frozen-unfrozen-and-ord-regex.rb
Created October 14, 2015 17:12
Ruby Object Growth: String literals (frozen and not) versus or'd Regex
#!/usr/share/rbenv/shims/ruby
# ruby 2.1.7p400-github-tcmalloc (b3255a8b57) [x86_64-linux]
# object start: 3522021
# running start_with on frozen args
# object growth: 8976
# object growth: 664
# object growth: 664
# object growth: 664
# running start_with on unfrozen args

Quick Audit Notes for https://github.com/grobian/carbon-c-relay Jon Simons 3/23/2015

--

Looks mostly okay. There are a number of unchecked mallocs and strdups throughout but it's not clear whether with our memory profiles in production these spots would actually result in real-life problems. We can fix them. There was at least one spot in the code using usleep as a pre-cleanup step for some of its state: that spot is likely incorrect

@simonsj
simonsj / dentry_create_trace.stp
Last active August 29, 2015 14:10
SystemTap Script to Monitor d_instantiate Calls (for non-sockets)
probe kernel.function("d_instantiate").return {
dname = d_name($entry)
dflags = $entry->d_flags
rpw = reverse_path_walk($entry)
if (dname != "") {
printf("d_instantiate: PID=%d execname '%s' cmd: '%s' d_name '%s' d_flags 0x%x rpw '%s'\n",
pid(), execname(), cmdline_str(), dname, dflags, rpw)
}
}
@simonsj
simonsj / gist:b9e4b30d806d7da5a8df
Last active August 29, 2015 14:07
Pointing OSX 'ssh-agent' to Your Own Copy
Modify this file: /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist.
To point the 'ssh-agent' path to whatever one you built, or maybe one that you can find in your brew area.
I do a clean restart to get the change to take effect.
Once I do that 'ssh-add -l' shows my ed25519 key in ssh-agent as desired.
@simonsj
simonsj / gen.rb
Last active December 15, 2015 06:39
Fun.
#!/bin/env ruby
#
# gen.rb --
s = '{ "app": "github", "error":"something bad happened" }'
require 'socket'
1000.times do |i|