Skip to content

Instantly share code, notes, and snippets.

View stevegt's full-sized avatar

Steve Traugott stevegt

View GitHub Profile
// Single line comment
/* Multi-
line comment */
// A package clause starts every source file.
// Main is a special name declaring an executable rather than a library.
package main
// Import declaration declares library packages referenced in this file.
import (
@stevegt
stevegt / makekey.py
Last active May 9, 2022 18:04 — forked from tdfischer/makekey.py
Schlage 5 Cylinder Key Generator from https://noisebridge.net/wiki/Key_Milling
#!/usr/bin/env python
# makekey.py - A key making tool
# This program will accept a pin configuration for a Schalge 5 Pin lock and produce GCode to mill out the corresponding key.
#
# For example, this will produce a bump key:
# $ ./makekey.py 99999
#
# This could produce a key to something else:
# $ ./makekey.py 38457
#
@stevegt
stevegt / atan2.thinkscript
Created January 30, 2022 19:51
thinkscript atan2
script atan2 {
input y = 1.1;
input x = 1.1;
# approx from wikipedia
plot atan2 = 2 * atan(y/(sqrt(sqr(x) + sqr(y)) + x));
}
@stevegt
stevegt / mob-consensus
Last active January 6, 2022 19:31
simple shell script for mob programming: provides fast merge and review, supports async work
#!/bin/bash -e
repo_root=$(git rev-parse --show-toplevel)
current_branch=$(git rev-parse --abbrev-ref HEAD)
twig=$(basename $current_branch)
usage() {
echo "Usage: $0 [-cFn] [-b BASE_BRANCH] [OTHER_BRANCH]
With no arguments, compare $current_branch with other branches named "'*'"/$twig.
package main
import (
"log"
"os"
"regexp"
"strings"
"text/template"
)
@stevegt
stevegt / buildah-flow.dot
Last active August 9, 2021 23:52
journal engine flowchart using buildah as example
digraph docker {
rankdir=LR;
io [label="I/O"];
subgraph cluster_20 {
label=journal;
// open [label="open\nexisting\njournal"];
notify [label="start\nprocess"];
create [label="create\nnew\njournal"];
@stevegt
stevegt / main.go
Created August 6, 2021 00:16
contexts: simple cancel implementation using Go's context
package main
import (
"bufio"
"context"
"fmt"
"os"
"time"
)
@stevegt
stevegt / main.go
Created August 6, 2021 00:07
contexts: why Go's context is typically needed
package main
import (
"bufio"
"fmt"
"os"
"time"
)
func main() {
@stevegt
stevegt / api.go
Created July 30, 2021 23:59
sketch of journal engine API
package tjournal
import (
"fmt"
)
// XXX get this from pitbase
type Addr string
// type Input fmt.Stringer
@stevegt
stevegt / simple-flow.dot
Last active August 9, 2021 00:14
simple engine flowchart
digraph g {
rankdir=LR;
io [label="I/O"];
subgraph cluster_20 {
label=journal;
open [label="open\nexisting\njournal"];
notify [label="start\nprocess"];
create [label="create\nnew\njournal"];