Skip to content

Instantly share code, notes, and snippets.

@egonelbre
egonelbre / gist:1311842
Created October 25, 2011 08:28
Design Patterns in GO
///////
// Warning, code untested
///////
type Thinger interface {
SomeMethod( arg bool ) bool
}
type RealThing struct {
state bool
@egonelbre
egonelbre / glfw_example.go
Last active August 21, 2023 15:15
Input handling in Go for games
// adjust the input/controller to your own liking
type Device interface {
Update(input *Controller, window *glfw.Window)
}
// this is the general
type Controller struct {
ID int
Device Device
package main
const MaxLength = 1 << 20
var (
addr = flag.String("listen", ":8000", "listen for requests")
numprocs = flag.Int("p", runtime.NumCPU(), "number of workers to start")
maxqueue = flag.Int("q", runtime.NumCPU()*2, "largest queue size")
jobs chan Job
@egonelbre
egonelbre / astar_nodequeue.go
Last active June 29, 2023 09:43
Go A* implementation
package astar
import "container/heap"
type NodeQueue []Node
func NewNodeQueue() NodeQueue {
return make(NodeQueue, 0, 1000)
}

Keybase proof

I hereby claim:

  • I am egonelbre on github.
  • I am egonelbre (https://keybase.io/egonelbre) on keybase.
  • I have a public key ASCPXCOftj5WHDwWk_kjkT7UzvIjJ_m5euWJ8wLoO4H6Fwo

To claim this, I am signing this object:

@egonelbre
egonelbre / architecture.md
Last active January 7, 2023 02:33
Gio architecture brain-dump
title
Architecture

Introduction

Gio implements an Immediate Mode User Interface.. This approach can be implemented in multiple ways, however the overarching similarity is that the program:

  1. listens for events such as mouse or keyboard input,
@egonelbre
egonelbre / gist:3437746
Created August 23, 2012 15:27
State Machine
function Machine(first, $){
var cur = {}, next = $[first];
var self = {
go : function(to){ next = next ? next : ($[to] || $.undefined); },
trigger : function(event){ var t = cur.tx && cur.tx[event]; t && self.go(t); }
};
return function(){
if(next){
cur.exit && cur.exit.call(self);
cur = next; next = undefined;
@egonelbre
egonelbre / gist:1755115
Last active March 24, 2022 15:26
Prolog Explanation
daytime.
clear_skies.
% I want to have empty tables (facts) `daytime` and `clear_skies`
round(earth).
round(ball).
small(mouse).
small(ball).
@egonelbre
egonelbre / index.html
Created November 16, 2021 14:51
Hooking up WebAudio Analyser
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/~watch.js"></script>
</head>
<body>
@egonelbre
egonelbre / go.mod
Last active October 17, 2021 17:26
Tool for rewriting import paths safely.
module rename-imports
go 1.13
require golang.org/x/tools v0.0.0-20191224055732-dd894d0a8a40