Skip to content

Instantly share code, notes, and snippets.

View ydnar's full-sized avatar

Randy Reddig ydnar

View GitHub Profile
@ydnar
ydnar / types.wit.go
Last active February 21, 2024 04:44
Go representation of wasi:filesystem/types@0.2.0
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package types represents the interface "wasi:filesystem/types@0.2.0".
//
// WASI filesystem is a filesystem API primarily intended to let users run WASI
// programs that access their files on their existing filesystems, without
// significant overhead.
//
// It is intended to be roughly portable between Unix-family platforms and
// Windows, though it does not hide many of the major differences.
@ydnar
ydnar / README.md
Last active December 13, 2023 19:26
wasi:cli/command

wasi:cli/command

Generating

  1. Install the wit-bindgen-cli crate via cargo install wit-bindgen-cli.
  2. Check out the wasi:cli repo.
  3. Run wit-bindgen c --world command wit in the wasi-cli directory.
package poll
import (
"unsafe"
"github.com/ydnar/wasm-tools-go/wasm/cm"
)
// Interface implements WIT interface "wasi:io/poll".
type Interface interface {
@ydnar
ydnar / fs.go
Created September 12, 2023 17:12
platform package for GOOS=wasip1
package platform
import (
"os"
"path/filepath"
)
// ExecutableDir returns the directory containing the current executable,
// or when an error occurs, the current working directory.
func ExecutableDir() (string, error) {
@ydnar
ydnar / zero.go
Created July 17, 2023 19:40
nil as untyped zero value for Go
package main
func main() {
var s string
var _ = s == nil // true
var i int
var _ = i == nil // true
var v struct {
@ydnar
ydnar / queue.go
Last active April 26, 2023 00:54
Weighted queue using multi-channel select in Go
package priority
import (
"context"
"sync/atomic"
)
type Priority int
const (
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "Packages",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
],
products: [
@ydnar
ydnar / main.go
Created June 4, 2020 19:22
protoc-gen-good
package main
import (
"errors"
"flag"
"fmt"
"os"
"path/filepath"
"strings"
"unicode"
@ydnar
ydnar / main.go
Created April 17, 2020 20:59
Get Tailscale IP from terminal
package main
import (
"flag"
"fmt"
"net"
"os"
)
func main() {
@ydnar
ydnar / swift.yaml
Created April 5, 2020 19:42
SwiftFormat with GitHub Actions
name: Swift
on:
push:
branches:
- master
paths:
- ".github/workflows/swift.yaml"
- "**.swift"
- "**/Package.resolved"