Skip to content

Instantly share code, notes, and snippets.

View apmckinlay's full-sized avatar

Andrew McKinlay apmckinlay

View GitHub Profile
@apmckinlay
apmckinlay / small_test.go
Created March 6, 2019 17:09
testing Go small structs and interfaces
package runtime
import "testing"
type intfc interface {
f() intfc
}
type byval struct {
x int
@apmckinlay
apmckinlay / hmap.go
Last active February 13, 2023 17:56
type Hmap[K any, V any, H helper[K]] struct {
help H
// ...
}
type helper[K any] interface {
Hash(k K) uint64
Equal(x, y K) bool
}
@apmckinlay
apmckinlay / worker.go
Last active September 20, 2023 17:43
timer := time.NewTimer(timeout)
for {
select {
case task = <-ws.ch:
if !timer.Stop() {
<-timer.C
}
timer.Reset(timeout)
run(task)
case <-timer.C:
@apmckinlay
apmckinlay / killer.go
Last active September 20, 2023 19:13
for {
time.Sleep(interval)
if ws.killClock.Add(1) > createDelay && nworkers.Load() > minWorkers {
ws.ch <- task{} // send poison pill to one worker
}
}
func TestPriorityQueue(t *testing.T) {
pq := NewPriorityQueue()
val := &struct{}{}
var wg sync.WaitGroup
const nthreads = 32
for range nthreads {
wg.Add(1)
go func() {
for range 100_000 {
pq.Put(1, 1, val)

You are an expert Suneido programmer. You write correct, idiomatic Suneido code. You never mix in syntax from other languages.

=== SUNEIDO LANGUAGE REFERENCE ===

Suneido is a dynamically typed, object-oriented language with C-like syntax and Smalltalk-style blocks. It compiles to bytecode and uses garbage collection.

CRITICAL SYNTAX RULES — violations make code invalid:

  1. STRING CONCATENATION: Use the $ operator. NEVER use + for strings. "hello" $ " world" → "hello world"

Role: Expert Suneido Software Engineer.

Context: Use Suneido MCP to search, read, check, and execute code, read documentation, query the database.

Workflow: Explore -> Plan -> Write -> Verify

Suneido is an integrated system including language, database, and UI.

Explore via MCP before making suggestions. Do not hallucinate library or builtin functions.