Skip to content

Instantly share code, notes, and snippets.

@themisir
themisir / vm.awk
Last active December 6, 2025 15:41
A Turing complete virtual machine implementation with AWK..
#!/usr/bin/awk -f
BEGIN {
split("", stack);
split("", locals);
split("", lookback);
split("", labels);
skip_ops = 0;
@tetsu-koba
tetsu-koba / c2zig
Last active July 2, 2024 07:37
shell script for zig translate-c
#!/bin/bash -eu
if [ $# -ne 1 ]; then
echo "Usage: $0 <cfilename> ending '.c' or '.h'"
exit 1
fi
if [[ $1 == *.c ]]; then
OUTPUT=$(basename $1 .c)_translated.zig
elif [[ $1 == *.h ]]; then
OUTPUT=$(basename $1 .h)_h_translated.zig
else
@bgeneto
bgeneto / fortran-vs-python-integration-loop.md
Last active February 17, 2025 13:19
Python vs Fortran performance on trapezoidal numerical integration

Python numerical integration performance

Out of the box performance of python numerical integration is poor. Here we present three python versions of the trapezoidal rule.

Python code (naive version)

import math
import time
@doccaico
doccaico / main.zig
Last active March 25, 2024 16:00
Conway's Game of Life
// Build: zig build-exe -O ReleaseFast --strip src/main.zig
// Run: zig build run -- -w 70 -h 40 -m "*" -s 0.07 -c 25
// Version: 0.10.0-dev.3475+b3d463c9e
// Date: 2022/08/09
const std = @import("std");
const fmt = std.fmt;
const mem = std.mem;
const os = std.os;
@Daniel15
Daniel15 / slack-invite-link-security-issue.txt
Last active July 17, 2023 01:16
Slack invite link security issue
@leandronsp
leandronsp / 001-server.bash
Last active May 21, 2025 10:02
A complete yet simple Web server (with login & logout system) written in Shell Script
#!/bin/bash
## Create the response FIFO
rm -f response
mkfifo response
function handle_GET_home() {
RESPONSE=$(cat home.html | \
sed "s/{{$COOKIE_NAME}}/$COOKIE_VALUE/")
}
@meeech
meeech / a_help-osx-borked-my-nix.md
Last active January 16, 2026 22:01
Some steps to (hopefully) help you fix your Nix install on OS X after an upgrade.

Apple Borked my Nix!

Ok, so you've had nix (home-manager) working fine. Then Apple tells you it's time to update.

Ok. Reboot. Oops. It has now broken your Nix setup. Here's some stuff to work through. YMMV.

Note: This is what worked for me, who was just using nix + home-manager. The upgrade that I last did that caused all these issues was 12.3.X > 12.4

Useful Links

@startergo
startergo / virtual box_UUID.sh
Created February 28, 2022 04:34
BASH script to automate the configuration of the SMBIOS UUID
#!/bin/bash
VM_NAME="Win10VM" #name
VSETED="VBoxManage setextradata $VM_NAME"
#CFG_PATH="VBoxInternal/Devices/pcbios/0/Config" # for bios (legacy) boot machines (i.e. windows 7 build)
CFG_PATH="VBoxInternal/Devices/efi/0/Config" # for efi boot machines (i.e. windows 10 build)
#SLIC.bin file
sudo dd if=/sys/firmware/acpi/tables/SLIC of=~/.config/SLIC.bin
@fernandoherreradelasheras
fernandoherreradelasheras / smart-video-cutter.sh
Created February 26, 2022 17:01
Smart video cutter with minimal transcoding using ffmpg
#!/usr/bin/bash
#
# Cut a fragment of a video with the minimal possible re-encoding.
# If the new start point is not a key frame it reencodes the video
# from that point until the frame before a new keyframe. The remaining
# part is copied as passthrough and both fragments are concatenated
#
# In order to make the video streams compatible we use the same codec
# and bitrate. This works fine with h264. No idea about other codecs
@Chenx221
Chenx221 / recovery.json, cloudready_recovery.json
Last active March 17, 2026 11:53
Chrome OS recovery images manual download (Flex)
# Chrome OS recovery images manual download
https://dl.google.com/dl/edgedl/chromeos/recovery/recovery2.json
https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.json
# Google Chrome OS Flex images manual download
https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.json
https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery.json