Skip to content

Instantly share code, notes, and snippets.

View guidoschmidt's full-sized avatar
🦩
🌋🦎🧅

Guido Schmidt guidoschmidt

🦩
🌋🦎🧅
View GitHub Profile
@peterc
peterc / zig.txt
Created April 14, 2025 18:18
Basic Zig programming cheat sheet for LLM AI agent
# Zig Programming Cheat Sheet
This guide condenses the key ideas from Chapter 1 of the Zig book, emphasizing Zig's syntax, semantics, workflows, and philosophy. It distills nuanced language details, technical rules, compiler constraints, and examples for direct application by AI or technical users.
---
## 1. Zig Philosophy and Paradigm
- Zig is a **low-level, general-purpose, modern programming language** designed for safety, control, and simplicity.
- Major design goal: **Less is more** (removes confusing/unsafe C/C++ behaviors; adds consistency).
@alichraghi
alichraghi / zig-shaders.md
Last active November 26, 2025 09:46
Zig Shaders

What does it look like?

Here is a simple fragment shader with uniform buffers:

const std = @import("std");
const gpu = std.gpu;

const UBO = extern struct {
    object_color: @Vector(4, f32),
    light_color: @Vector(4, f32),
@jongalloway
jongalloway / FixMermaidSvg.js
Last active November 20, 2025 12:35
Mermaid diagrams use non-standard foreignObject and HTML instead of standard SVG. This snippet can be run in a browser console to get most of the way to SVG that can be edited in Inkscape and other SVG editors. More info about the issue this fixes here: https://github.com/mermaid-js/mermaid/issues/2688
(function() {
// Manually set x and y values for text elements since calculation isn't reliable. Set to what works for your theme.
const textX = 0;
const textY = 17;
// Optional feature to insert a white rectangle below the diagram for dark mode visibility
const addBackgroundRect = false;
// Get the SVG element
const svg = document.querySelector('svg');
@therealparmesh
therealparmesh / zed-vim-mode-cheatsheet.md
Created October 24, 2024 14:38
Zed vim mode cheatsheet

Zed Vim Mode Cheat Sheet

Zed's Vim mode replicates familiar Vim behavior while integrating modern features like semantic navigation and multiple cursors. This cheat sheet summarizes essential shortcuts and settings to help you navigate and edit code efficiently in Zed.


Enabling/Disabling Vim Mode

  • Enable/Disable Vim Mode: Open the command palette and use Toggle Vim Mode.
  • This updates your user settings: "vim_mode": true or false.
@jinzhongjia
jinzhongjia / std_io_poll_example.zig
Created May 25, 2024 02:42
`std.io.poll` usage
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
defer {
const deinit_status = gpa.deinit();
if (deinit_status == .leak) @panic("TEST FAIL");
}
import tarfile
import hashlib
import os
import sys
import requests
import io
def compute_hash(tar_path, is_url=False):
if is_url:
response = requests.get(tar_path)

1. Download your Twitter archive

You can find this feature in Settings > Download Twitter Archive. It might take 24 hours to receive. Unzip the file and open the data folder in your terminal:

cd ~/Downloads/twitter-archive-zip-you-downloaded/data

(I have seen reports that this function may no longer be working, so this guide is mostly useful to those who were lucky enough to already have downloaded their archive.)

@postspectacular
postspectacular / benchmark.js
Last active October 18, 2022 10:43
JS ImageData update benchmarks showing perf gains (2-4x) from using u32 memory views over standard u8 accesses
import { suite } from "@thi.ng/bench";
const w = 640;
const h = 480;
const idata = new ImageData(w, h);
// exposed u8clampedarray
const u8 = idata.data;
// rewrap same memory as u32
const u32 = new Uint32Array(u8.buffer);
@mattdesl
mattdesl / cli.js
Created September 13, 2022 10:37
colour palette from text prompt using Stable Diffusion https://twitter.com/mattdesl/status/1569457645182152705
/**
* General-purpose NodeJS CLI/API wrapping the Stable-Diffusion python scripts.
*
* Note that this uses an older fork of stable-diffusion
* with the 'txt2img.py' script, and that script was modified to
* support the --outfile command.
*/
var { spawn, exec } = require("child_process");
var path = require("path");
@gsf
gsf / ubu-on-mac.md
Last active October 31, 2025 06:54
Ubuntu VM on macOS with QEMU

Ubuntu VM on macOS with QEMU

For work I have an Intel Core i5 MacBook. With the Docker Desktop license changes I looked into minikube and Multipass but both failed when I got on our VPN with Cisco AnyConnect due to bridged networking in hyperkit (see links at bottom).

I realized I would be happy SSHing into a local Linux VM but passed on VirtualBox to avoid depending on legacy system extensions. I landed on libvirt for the VM, then realized I could remove libvirt from the equation to finally end up at this quick, simple setup for an Ubuntu VM on macOS with QEMU.

First, install QEMU (see https://wiki.qemu.org/Hosts/Mac for other o