Skip to content

Instantly share code, notes, and snippets.

View shell-latency-test-infinite.py
#!/usr/bin/env python3
import sys, pty, os, time, threading, queue, argparse
ap = argparse.ArgumentParser()
parser = argparse.ArgumentParser(
description='Tests the input latency of a shell',
usage='usage: shell-latency-test-infinite.py [--sleep] [--] argv-to-execute...',
)
parser.add_argument('--sleep',
action='store_true',
View nusimulator2.py
# This will respond to keyboard input after either a 12ms delay (capital A) or
# no delay (lowercase a).
# For some reason this causes up to 50ms of difference in Terminal.app.
# Press Ctrl-C to stop.
import os, time, re, tty, termios
try:
old_settings = termios.tcgetattr(0)
tty.setraw(0)
@comex
comex / shell-latency-test.py
Created September 23, 2023 23:26
Tool to test a shell's input latency
View shell-latency-test.py
import sys, pty, os, time, signal, threading, string, random
sub_argv = sys.argv[1:]
if not sub_argv:
raise Exception("usage: shell-latency-test.py shell-to-test (e.g.: shell-latency-test.py nu)")
# Spawn the shell in a pty which we own the controlling end of.
child_pid, fd = pty.fork()
if child_pid == 0:
# This is the child process. Exec the shell.
@comex
comex / test.c
Last active August 13, 2023 22:12
View test.c
#pragma STDC FENV_ACCESS ON
#include <signal.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <fenv.h>
static void check(const char *where) {
printf("%-40s: fegetround() => %#x\n", where, fegetround());
}
@comex
comex / assh
Last active July 14, 2023 21:36
View assh
#!/usr/bin/env python3
# SPDX-License-Identifier: CC0-1.0
'''Wraps the ssh command, but quotes arguments so that they are passed 1:1 to
the remote command.
'''
import shlex, sys, os
args = sys.argv[1:][::-1]
out = ['ssh']
while args and args[-1].startswith('-'):
arg = args.pop()
View spawn-bench.c
#include <spawn.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <stdio.h>
extern char **environ;
int main(int argc, char **argv) {
if (!argv[1]) {
fprintf(stderr, "usage: spawn-bench <command> [args...]\n");
View gist:0bfb0ba09d98627a49c671ee1037365e

[Generated by LLaMA 13B with prompt "In the end". I found it amusing.]

In the end, it was always going to be this way.

After 12 years and over 400 hours of TV time, The Simpsons ended with a bittersweet, emotional episode where Homer's dad dies in the most un-Homer Simpson way possible — he passed away peacefully, surrounded by family members who were holding him in his final moments.

And while Homer had always been openly hostile toward his father over the years — especially after finding out Grandpa was a Nazi — it was clear that he actually loved him. This was seen when Homer and Grandpa spent time together, and during an emotional scene where Homer read him a bedtime story.

But as we've grown up with The Simpsons, this episode felt different than any other in the show's history. As a diehard fan of the series, this was one of those episodes that I knew would be the most powerful one yet — and it lived up to my expectations.

View gist:eb0a6d935baa29e15eedfe18e96f9693
~/src/ipsw % git describe
v3.1.277
~/src/ipsw % ./ipsw dyld extract /System/Volumes/Preboot/Cryptexes/Incoming/OS/System/Library/dyld/dyld_shared_cache_arm64e /usr/lib/libsqlite3.dylib -o /tmp/dsc-ipsw --stubs --force --objc
• parsing public symbols...
• parsing private symbols...
• cache does NOT contain local symbols
• parsing objc info...
⨯ failed to parse objc selectors: failed read selector objc_stringhash_t: unexpected EOF
~/src/ipsw % sw_vers
ProductName: macOS
View foo.m
@implementation Foo
-(void)bar {}
@end
int main() {}
View gist:6eee694c5f4748f89d3168cbf760d5fe
@ valgrind --undef-value-errors=no --freelist-vol=10000000000 ./binaryninja/binaryninja /tmp/main_301.bndb
==65305== Memcheck, a memory error detector
==65305== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==65305== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==65305== Command: ./binaryninja/binaryninja /tmp/main_301.bndb
==65305==
==65305== Invalid read of size 8
==65305== at 0x4025964: strncmp (strcmp.S:170)
==65305== by 0x4005EAD: is_dst (dl-load.c:216)
==65305== by 0x4006F26: _dl_dst_count (dl-load.c:253)