Skip to content

Instantly share code, notes, and snippets.

View djanatyn's full-sized avatar

Jonathan Strickland djanatyn

View GitHub Profile
@djanatyn
djanatyn / nix-shell.sh
Created October 31, 2022 02:02
nix-shell vs nix shell
# why does `nix-shell` update NIX_LDFLAGS
# but `nix shell` does not?
❯ nix shell nixpkgs#libGLU -c /bin/sh -c 'env | grep -i glu'
PATH=/nix/store/xva8m3sa2yc56cglmqxgj3cdkq50hcly-glu-9.0.2/bin:/home/djanatyn/.zplug/repos/zplug/zplug/bin:/home/djanatyn/.zplug/bin:/usr/local/bin:/home/djanatyn/.local/bin:/nix/store/crrclzy9cqk55nlkcals81z1556c195c-kitty-0.26.2/bin:/nix/store/jwg4p52y4s69pyj9l8fmjc3xhckbl2rj-imagemagick-7.1.0-49/bin:/nix/store/5ki8qk489a2cmfc9sbjb2kwda8ymza3p-ncurses-6.3-p20220507-dev/bin:/run/wrappers/bin:/home/djanatyn/.nix-profile/bin:/etc/profiles/per-user/djanatyn/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
❯ nix-shell -p libGLU --command 'env | grep -i glu'
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
NIX_CFLAGS_COMPILE= -isystem /nix/store/1gs13a2259qdbxjgx4vkw1my6a80vq4q-glu-9.0.1-dev/include -isystem /nix/store/mgky1qxwsj8268q8ivp41772pp6q1kq8-libGL-1.3.2-dev/include -isystem /nix/store/k8bkfl6lf5sgq
@djanatyn
djanatyn / segfaults.txt
Created October 29, 2022 23:28
dolphin segfaults oct 29th 2022
❯ sudo dmesg -Hw | rg 'segfault.+dolphin'
[Oct15 08:05] Video thread[998831]: segfault at 20 ip 0000000000000020 sp 00007ff2757fd4c8 error 14 in .dolphin-emu-wrapped[400000+2f000]
[Oct16 11:59] Video thread[1338387]: segfault at 20 ip 0000000000000020 sp 00007ff31b7fd4b8 error 14 in .dolphin-emu-wrapped[400000+2f000]
[Oct17 22:04] Video thread[1642146]: segfault at 20 ip 0000000000000020 sp 00007fb80d3fe4b8 error 14 in .dolphin-emu-wrapped[400000+2f000]
[Oct20 10:50] Video thread[2030971]: segfault at 20 ip 0000000000000020 sp 00007f9bd5ffd4c8 error 14 in .dolphin-emu-wrapped[400000+2f000]
[ +3.720879] Emuthread - Sta[2423567]: segfault at 8 ip 000000000074cd94 sp 00007f50cdbfb740 error 6 in .dolphin-emu-wrapped[42f000+8ef000]
[Oct23 11:50] Video thread[2865150]: segfault at 20 ip 0000000000000020 sp 00007fa8353fd4b8 error 14 in .dolphin-emu-wrapped[400000+2f000]
[ +2.980908] Emuthread - Sta[2866126]: segfault at b ip 000000000074cd94 sp 00007f52227fb740 error 6 in .dolphin-emu-wrapped[42f000+8ef000]
[Oct25

I made a turnip-counter! It reads Super Smash Bros Melee replay data, searches for items pulled by Peach, and records information to a sqlite3 database!

The code looks specifically for items initially owned by me, so the good luck of other Peach players isn't counted:

/// Tokio task to send Peach item records to database worker.
async fn record_items(tx: Sender<DBCommand>, items: ItemLog, game_id: i64, me: Port) -> App<()> {
    for (item_id, history) in items {
 // only record my turnips
@djanatyn
djanatyn / systemd-run.md
Created October 16, 2022 17:47
systemd-run exploration

I've been learning about systemd-run:

systemd-run may be used to create and start a transient .service or .scope unit and run the specified COMMAND in it. It may also be used to create and start a transient .path, .socket, or .timer unit, that activates a .service unit when elapsing. If a command is run as transient service unit, it will be started and managed by the service manager like any other service, and thus shows up in the output of systemctl list-units like any other unit. It will run in a clean and detached execution environment, with the service manager as its parent process. In this mode, systemd-run will start the service asynchronously in the background and return after the command has begun execution (unless --no-block or --wait are specified, see below).

I am interested in using systemd-run as a way to start up background tasks, without needing to run a program in tmux. I ran this command to download a [YouTube pl

@djanatyn
djanatyn / ffxiv-packets.md
Last active October 15, 2022 18:10
decoding timestamps in final fantasy 14 packets

I'm capturing packets from Final Fantasy 14 and trying to decode some information!

I used ss to see which TCP socket my ffxiv_dx11.exe process was talking to (204.2.229.99:55024)

❯ sudo ss -Otnp | grep ffxiv
ESTAB      0      0                                 192.168.1.232:55060                             204.2.229.99:55024 users:(("ffxiv_dx11.exe",pid=1022957,fd=360),("wineserver",pid=1022873,fd=529))
ESTAB      0      0                                 192.168.1.232:55058                             204.2.229.99:55024 users:(("ffxiv_dx11.exe",pid=1022957,fd=361),("wineserver",pid=1022873,fd=528))

I used tshark to capture some packets:

@djanatyn
djanatyn / bpf-notes.md
Created October 12, 2022 22:08
reading PF Performance Tools

I started diving into the BPF Performance Tools book, and there's so many utilities from the BCC that I wasn't aware of!

execsnoop does what i always wanted ps to do

❯ sudo execsnoop
PCOMM            PID    PPID   RET ARGS
uname            252856 1994     0 /run/current-system/sw/bin/uname
sh               252857 2544     0 /bin/sh -c tmux     send-keys -X cancel; /home/djanatyn/.tmux/plugins/tmux-copycat/scripts/copycat_mode_quit.sh; true
tmux             252858 252857   0 /nix/var/nix/profiles/default/bin/tmux send-keys -X cancel
copycat_mode_qu  252859 252857   0 /home/djanatyn/.tmux/plugins/tmux-copycat/scripts/copycat_mode_quit.sh
@djanatyn
djanatyn / seccomp-filters-systemd-run.md
Created October 8, 2022 16:48
systemd-run SystemCallFilter seccomp filtering

running curl with systemd-run

❯ systemd-run --wait --user --pty curl google.com
Running as unit: run-u1627.service
Press ^] three times within 1s to disconnect TTY.
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
@djanatyn
djanatyn / leetcode-scrape.md
Created October 8, 2022 14:45
scraping leetcode problem description graphql api

I've been doing leetcode, so I wrote some Rust to make fetching the problem description a bit easier, using their GraphQL after capturing some requests as curl commands:

original working curl command

❯ curl https://leetcode.com/problems/contains-duplicate -vL -o/dev/null 2>&1 \
  | rg 'set-cookie: csrftoken=([^ ]+);' -or '$1'
AdasXUlUAP5wuVhq9qcTs6LYBZsk4IxKzdThaqsHcQIUR8JnReF1f4jTSJ7k8MAL

❯ curl 'https://leetcode.com/graphql' -X POST \
@djanatyn
djanatyn / github-actions-workflows.md
Created October 3, 2022 02:10
exploring github actions

My "fetch info" workflow took around 3minutes 26 seconds to complete this morning. It installs nix, gets a shell with cargo and rustc, and then executes cargo run.

I created another workflow to download rustup, run cargo build --release, and to output an artifact:

- name: build netplay-bracket-finder
  run: |
    cd rust && cargo build --release
- name: upload artifact
  uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3
 with:
@djanatyn
djanatyn / huffman-ghci.hs
Created September 29, 2022 19:30
exploring huffman coding
-- build huffman coding tree from text input
ghci> buildTree "recurse center"
Branch
(Branch
(Branch
(Leaf (Frequency {char = 'u', count = 1}))
(Branch
(Leaf (Frequency {char = 's', count = 1}))
(Leaf (Frequency {char = 't', count = 1}))))
(Leaf (Frequency {char = 'r', count = 3})))