Skip to content

Instantly share code, notes, and snippets.

@teghnet
teghnet / sign-with-frame-sh.go
Last active March 25, 2024 16:29
This is how you can sign a message with an embedded RPC server in frame.sh using https://github.com/defiweb/go-eth
package main
import (
"context"
"fmt"
"github.com/defiweb/go-eth/rpc"
"github.com/defiweb/go-eth/rpc/transport"
"github.com/defiweb/go-eth/types"
"github.com/defiweb/go-eth/wallet"
@teghnet
teghnet / state.go
Created October 30, 2023 11:33
State Machine for Charm
// Package state is for implementing a simple state machine.
// In a [tea.Model.Update] method one can use a `case` for a [Transition] message to change the state.
//
// case state.Transition:
// if !msg.Used() {
// m.State = msg.State()
// return m, msg.AsUsed()
// }
package state
func must[t any](c t, err error) t {
if err != nil {
log.Fatalln(err)
}
return c
}
@teghnet
teghnet / main.go
Last active December 12, 2021 23:20
Homemade CLI Tools
// This is an example for:
// https://www.tegh.net/2021/12/12/homemade-cli-tools/
package main
import (
"errors"
"fmt"
"io"
"log"
"os"
@teghnet
teghnet / main.go
Last active November 12, 2020 07:06
package main
import (
"log"
"sync"
"time"
)
type SemaphoredWaitGroup struct {
sem chan bool
FROM bash
COPY test*.sh ./
RUN bash test_scenario.sh