Skip to content

Instantly share code, notes, and snippets.

View andrewrk's full-sized avatar

Andrew Kelley andrewrk

View GitHub Profile
@andrewrk
andrewrk / 3let.py
Created February 15, 2016 03:27
origin of the zig programming language name. https://github.com/andrewrk/zig/
import string
import random
vowels = "aoeuiy"
def m():
c1 = vowels[random.randint(0,len(vowels)-1)]
c2 = string.ascii_lowercase[random.randint(0,len(string.ascii_lowercase)-1)]
c3 = string.ascii_lowercase[random.randint(0,len(string.ascii_lowercase)-1)]
print('z' + c1 + c2 + c3)
m()
@andrewrk
andrewrk / instructions.ps1
Last active April 1, 2024 00:17
instructions to set up a runner
# Create a folder under the drive root
mkdir actions-runner; cd actions-runner
# Download the latest runner package
Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-win-arm64-2.311.0.zip -OutFile actions-runner-win-arm64-2.311.0.zip
# Optional: Validate the hash
@andrewrk
andrewrk / 0example.zig
Created March 13, 2024 00:24
wait4 maxrss includes parent memory, why?
const std = @import("std");
const assert = std.debug.assert;
const expect = std.testing.expect;
pub fn main() !void {
const big = try std.heap.page_allocator.alloc(u8, 2 * 1024 * 1024 * 1024);
_ = big;
var child = std.ChildProcess.init(&.{"/usr/bin/env"}, std.heap.page_allocator);
child.stdin_behavior = .Ignore;
@andrewrk
andrewrk / microsoft_craziness.h
Created September 1, 2018 14:35
jonathan blow's c++ code for finding msvc
//
// Author: Jonathan Blow
// Version: 1
// Date: 31 August, 2018
//
// This code is released under the MIT license, which you can find at
//
// https://opensource.org/licenses/MIT
//
//
@andrewrk
andrewrk / referrers.txt
Created November 20, 2018 00:42
zig referrers
Here's a bunch of stuff I found in referrer URL to ziglang.org.
I'm not stating any opinions on any of this content, just exposing the information.
---
http://chriswarbo.net/blog/2017-03-03-free_elves.html
> Note that while Haskell doesn't have a "compile-time phase" (unlike, say, Zig), we can use Template Haskell to mess around with the syntax tree during compilation, which seems to be enough for our purposes.
> if I were really going to implement such a thing, I'd maybe target something more low-level (e.g. without garbage collection, RTS, etc.) so that I could tease out as much performance as possible. Languages like Zig, Terra, Nim or Rust.
@andrewrk
andrewrk / README.md
Created September 1, 2022 02:31
rebase failing pull requests - useful when your contributors unfortunately open PRs against a broken master branch

Rebase Failing Pull Requests

Dependencies

  • gh with a logged in user
  • git clone zig repo in zig
  • jq, date, and git in PATH.

Instructions

@andrewrk
andrewrk / sine.zig
Last active January 29, 2024 16:05
libsoundio zig example. zig build_exe sine.zig --library c --library soundio
const c = @cImport(@cInclude("soundio/soundio.h"));
const std = @import("std");
const io = std.io;
const cstr = std.cstr;
const panic = std.debug.panic;
const math = std.math;
fn sio_err(err: c_int) !void {
switch (@intToEnum(c.SoundIoError, err)) {
c.SoundIoError.None => {},
@andrewrk
andrewrk / build.zig
Created February 20, 2023 16:20
sprinkling a little zig into a C project to help with debugging
const std = @import("std");
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select
const std = @import("std");
const net = std.net;
const fs = std.fs;
const os = std.os;
pub const io_mode = .evented;
pub fn main() anyerror!void {
var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = &general_purpose_allocator.allocator;
@andrewrk
andrewrk / bar.zig
Created December 19, 2023 00:26
demo of specifying different target CPU features per module. context: https://github.com/ziglang/zig/pull/18160
pub fn add(a: i32, b: i32) i32 {
return a + b;
}