Skip to content

Instantly share code, notes, and snippets.


Mitchell Hashimoto mitchellh

View GitHub Profile
mitchellh / heap.zig
Last active Jan 22, 2023
Zig implementation of an intrusive heap based on pairing heaps
View heap.zig
const std = @import("std");
const assert = std.debug.assert;
/// An intrusive heap implementation backed by a pairing heap[1] implementation.
/// Why? Intrusive data structures require the element type to hold the metadata
/// required for the structure, rather than an additional container structure.
/// There are numerous pros/cons that are documented well by Boost[2]. For Zig,
/// I think the primary benefits are making data structures allocation free
/// (rather, shifting allocation up to the consumer which can choose how they
mitchellh / overlay.nix
Last active Nov 16, 2022
Playdate SDK on Nix on aarch64
View overlay.nix
# Playdate distributes their SDK as precompiled x86_64 binaries
# currently so we have to import cross-compiled packages for it
# if we're not on an x86_64 system.
pkgsIntel = import <nixpkgs> {
crossSystem = {
config = "x86_64-unknown-linux-gnu";
mitchellh / Atlas.zig
Last active Dec 22, 2022
Bin-packed texture atlas implementation in Zig.
View Atlas.zig
//! Implements a texture atlas (
//! The implementation is based on "A Thousand Ways to Pack the Bin - A
//! Practical Approach to Two-Dimensional Rectangle Bin Packing" by Jukka
//! Jylänki. This specific implementation is based heavily on
//! Nicolas P. Rougier's freetype-gl project as well as Jukka's C++
//! implementation:
//! Limitations that are easy to fix, but I didn't need them:
mitchellh / vmware-guest.diff
Created Oct 20, 2021
aarch64: vmmouse and vmware video driver not yet working, but shared folders and copy & paste do work!
View vmware-guest.diff
diff --git a/machines/vm-arch/aarch64-linux.nix b/machines/vm-arch/aarch64-linux.nix
index 7944fbc..932ce99 100644
--- a/machines/vm-arch/aarch64-linux.nix
+++ b/machines/vm-arch/aarch64-linux.nix
@@ -9,6 +9,13 @@
+ # Disable the default module and import our override. We have
+ # customizations to make this work on aarch64.
mitchellh / RadixTrees.tla
Last active Jun 30, 2021
Radix tree and validation in TLA+
View RadixTrees.tla
This module contains operations for working with radix trees. A radix tree
is a data structure for efficient storage and lookup of values that often
share prefixes, typically used with strings.
A common question when I show this to people is: how do I add to the tree?
delete? update? For these, grab the Range of the tree, use set logic to
add/remove any elements, and construct a new tree with RadixTree.
For educational purposes, I've heavily commented all the operations. I
recommend using the constant expression evaluator to try the building blocks
mitchellh / example.nix
Created May 10, 2020
Nix function for creating a derivation (package) that installs binaries from
View example.nix
self: super: {
consul-bin = self.callPackage ./hashicorp-generic.nix {
name = "consul";
version = "1.7.3";
sha256 = "0k03n7h5h8miqhh3n3y47894vhwdcp8m611w55f826swmq9angl1";
# and so on...
mitchellh /
Last active Aug 31, 2021
macOS Catalina (10.15+) Notarization Requirement for Go

macOS 10.15 Catalina requires binaries are notarized to run without annoying additional steps. See the issue here: hashicorp/terraform#23033

These are steps to notarize a direct binary. This does not cover stapling, installers (pkg), etc. This is primarily useful for static binary developers such as Go developers.

Manual Steps

Apple Developer Account

You first need an Apple Developer Account ($99/year). You need to accept all the agreements and stuff.

mitchellh /
Created Aug 13, 2019
Originally posted on Tumblr on Feb 25, 2011.

THIS WAS ORIGINALLY POSTED ON MY TUMBLR ON FEB 25, 2011. I forgot I had a Tumblr account. I recently logged in (in light of the acquisition by Automattic), found some old posts, and I'm republishing them exactly as they were with zero modifications.

CloudFormation: The Big Picture

Amazon announced CloudFormation to the public yesterday, and while the general opinion I could glean from various sources shows that people are excited about this new technology, many are still unsure what it is and how it fits into their current cloud workflow. I feel as though I have a firm grasp on CloudFormation and will attempt to answer some questions here.

Note: I'm definitely not a representative of Amazon in any way, and anything here is simply my educated opinion on the matter.

mitchellh / parse.go
Created Jan 22, 2019
HCL2 parsing example.
View parse.go
package config
import (
mitchellh / Makefile
Created Jan 21, 2019
Makefile target to test all modules in a repo.
View Makefile
.PHONY: test
@find ${CURRENT_DIR} -type f -name go.mod | xargs -n1 dirname | while read line ; do \
echo $${line} ; \
pushd $${line} >/dev/null ; \
go test ./... ; \
popd >/dev/null ; \
echo ; \