Skip to content

Instantly share code, notes, and snippets.

View reqshark's full-sized avatar
🎚️
back at it

Bent Cardan reqshark

🎚️
back at it
View GitHub Profile
@reqshark
reqshark / lldb-otool-debugging.markdown
Last active April 14, 2026 06:52
debugging optimized native code with lldb and otool

Debugging optimized native code with lldb and otool

Notes from a real debugging session chasing a register-corruption bug in inline-asm coroutine scheduling on Apple Silicon. The bug itself isn't the point — these are the tool habits and mental models that let me actually find it.

Reading disassembly for the story, not the instructions

otool -tvV dumps Mach-O disassembly with symbols and PC

@reqshark
reqshark / gist:ace6dd583947a1bdfd7ede9abd310160
Created April 3, 2026 17:05
why people switched to Go from JavaScript
Promises in Javascript trade one problem (callback nesting) for a worse one (silent failures).
With callbacks you always knew when something broke. With swallowed errors, you have to add debug statements
until you've tracked down where the error got swallowed.
10 seconds vs. 10 minutes

Installation

Installing dependencies

sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev \
                       libnotify-dev libgnome-keyring-dev libgconf2-dev \
                       libasound2-dev libcap-dev libcups2-dev libxtst-dev \
                       gcc-multilib g++-multilib \
                       libgtk2.0-0 libgconf-2-4 \
                       libasound2 libxtst6 libxss1 libnss3 xvfb \
@reqshark
reqshark / readme.markdown
Created April 26, 2019 05:18
why i am switching to go from javascript

promises and bloat

javascript got one thing right with callbacks. that got thrown out with promises.

error swallowing and other anonymous/bad syntax conventions

  • who cares about function declarations?
  • named functions provide an informative callstack for debugging/visibility, oops not arrows =>
  • async await is not a coroutine
  • chained promises swallow errors and are complex/unintuitive

go run

@reqshark
reqshark / binary_convert.js
Last active April 9, 2019 00:01
binary math conversion
// take a number 6 -> binary
console.log(convert(10))
function convert(n){
let remainder = []
while (n){
remainder.push(n % 2)
n = parseInt(n/2) // keep dividing it
}
@reqshark
reqshark / primesum.js
Last active March 16, 2019 00:20
summing primes from 2 million
console.log(primesum(2000000))
function primesum(m){
let ret = 7, i = 1 //(ret=7) prepopulate 2 and 5, dropped by optimization
while (i++ < m) {
if (isprime(i))
@reqshark
reqshark / segfault.c
Created August 11, 2018 00:32
catch your segfault
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
static void do_segv() {
/* lets do some stuff that would segfault on any system */
int *segv;
segv = 0; /* malloc(a_huge_amount); */
@reqshark
reqshark / ethminer_ubuntu_nvidia.md
Created July 18, 2018 18:40 — forked from johnstcn/ethminer_ubuntu_nvidia.md
NVIDIA/CUDA ethminer setup under Ubuntu Server 16.04

Headless Ethminer (nVidia) Setup Guide

Cian Johnston, July 2017

A couple of weeks ago, I decided I should put my gaming rig to work crypto mining. I did not expect to make any significant profit on this, it was more of a fun project to set up. However, there were a large number of tutorials and guides already out there, and many were more than a year out of date.

This guide assumes the reader already has a crypto wallet set up, is comfortable with Linux and the command line, and knows how to use Google if they run into problems.

The end result is an Ubuntu 16.04 LTS headless server running CUDA ethminer via systemd.

Hardware

@reqshark
reqshark / 00-MINING.md
Created January 14, 2018 04:32 — forked from gboddin/00-MINING.md
Mining optimisation under Linux

Mining under linux

Disclaimer

I'm in no case responsible for fried hardware, erased software or burning down houses. Make sure your miners are always well cooled.

General recommendation

Though you can easily mix nVidia and AMD in the same rig with Linux, it's recommended to use a different thread for each platform so a Driver crash doesn't bring the whole rig down. It should be noted however, that some mining software have trouble when both architecture are found on the same rig.

@reqshark
reqshark / rocm.sh
Created January 11, 2018 22:31
asking rocm-smi about GPU power on linux?
miner@rig3:~$ /opt/rocm/bin/rocm-smi -P
==================== ROCm System Management Interface ====================
================================================================================
GPU[1] : Cannot get GPU power Consumption: Average GPU Power not supported
GPU[2] : Cannot get GPU power Consumption: Average GPU Power not supported
GPU[0] : Cannot get GPU power Consumption: Average GPU Power not supported
================================================================================
==================== End of ROCm SMI Log ====================