Skip to content

Instantly share code, notes, and snippets.

@dannyvelas
dannyvelas / error_wrapping.go
Created March 20, 2022 23:52
Simple Example to demonstrate how the `Is` and `As` functions work in Go, once you've wrapped an error
package main
import (
"errors"
"fmt"
)
type MyError struct {
message string
}
@dannyvelas
dannyvelas / line_count_history.fish
Last active March 22, 2022 00:18
A command-line Fish script to see the your git repo's line count progression
#!/usr/bin/env fish
if test (count $argv) -lt 1
echo "Usage: scc-history <SHA>"
else
while [ (git rev-parse HEAD) != $argv[1] ]
# hash
set hash (git rev-parse --short HEAD)
# amtlines
@dannyvelas
dannyvelas / checkers.wat
Created February 19, 2022 23:34
WebAssembly Text Format For a Simple Game of Checkers using Kevin Hoffman's "Programming WebAssembly with Rust"
(module
(import "events" "pieceMoved"
(func $notify_pieceMoved (param $fromX i32) (param $fromY i32) (param $toX i32) (param $toY i32))
)
(import "events" "pieceCrowned"
(func $notify_pieceCrowned (param $fromX i32) (param $fromY i32))
)
(memory $mem 1)
(global $currentTurn (mut i32) (i32.const 0))
(global $WHITE i32 (i32.const 2))