Skip to content

Instantly share code, notes, and snippets.

View fanyang89's full-sized avatar

fanyang fanyang89

View GitHub Profile
@floooh
floooh / zig_test_debugging_vscode.md
Last active June 18, 2025 02:11
How to debug Zig tests in VSCode

Tested on macOS:

  1. Install the CodeLLDB VSCode extension. Unlike the debugger in the C/C++ extension, this allows to set breakpoints inside Zig "test" blocks (in the MS C/C++ extension debugger, breakpoints inside test blocks will be disabled once the debugger starts for unknown reasons.
  2. When compiling the test, tell it to also emit a binary: zig test -femit-bin=zig-out/bin/my-test src/bla.zig, otherwise there will be no executable to debug.
  3. The compiled test executable expects the path to the Zig executable as first command line argument, the launch.json file needs to be setup accordingly (note the args item):
@andrewhodel
andrewhodel / go-pprof.md
Last active September 2, 2025 06:56
Go profiling with pprof

Importing net/http/pprof adds HTTP endpoints to serve profile files that can be viewed or charted with a command line tool when the runtime.Set* functions are executed.

1. import pprof into the go program

import _ "net/http/pprof"

If your application is not already running an http or https server, add net/http to the program imports and the following code to the start of the main function:

go http.ListenAndServe(":8550", nil)
@fanyang89
fanyang89 / Example health-check script with systemd socket activation Simple HTTP health-check by abusing systemd socket activation with shell scripts
$ curl --dump-header - localhost:12345
HTTP/1.0 404 Not Found
Content-Type: text/html
Content-Length: 43
Date: Fri, 05 Dec 2014 17:48:56 +0000
<html>
<body>
<h1>WUT</h1>
</html>