Skip to content

Instantly share code, notes, and snippets.

View prologic's full-sized avatar
👋
Principal SRE, Founder of Yarn.social and Salty.im

James Mills prologic

👋
Principal SRE, Founder of Yarn.social and Salty.im
View GitHub Profile
@prologic
prologic / tokenize.go
Last active November 21, 2019 05:46
Split a string into tokens with a given separator supporting escape sequences
package main
import (
"errors"
"fmt"
)
func tokenizeString(s string, sep, escape rune) (tokens []string, err error) {
var runes []rune
inEscape := false
@prologic
prologic / build.log
Created April 29, 2019 04:57
muesli/beehive build 2019-04-29
james@Jamess-MacBook-Pro
Mon Apr 29 14:55:34
~/Contributions
130
$ git clone muesli/beehive
Cloning into 'beehive'...
remote: Enumerating objects: 154, done.
remote: Counting objects: 100% (154/154), done.
remote: Compressing objects: 100% (96/96), done.
remote: Total 5218 (delta 77), reused 115 (delta 54), pack-reused 5064
@prologic
prologic / build.log
Created April 25, 2019 02:52
Beehive build error
prologic@Jamess-MacBook
Thu Apr 25 12:50:32
~/Contributions/beehive
(master) 0
$ go build
# github.com/huin/goserial
../../go/pkg/mod/github.com/huin/[email protected]/serial_posix.go:5:11: fatal error: 'termios.h' file not found
#include <termios.h>
^~~~~~~~~~~
1 error generated.
@prologic
prologic / op_get_self.diff
Created March 20, 2019 10:30 — forked from mrnugget/op_get_self.diff
Fix for recursive closures that are defined in other functions. These break in version 1.0 of "Writing A Compiler In Go". This fix adds another opcode, OpGetSelf, and emits it whenever there's a reference to the currently executed function.
diff --git a/ast/ast.go b/ast/ast.go
index 8db3b39..f0420f4 100644
--- a/ast/ast.go
+++ b/ast/ast.go
@@ -2,6 +2,7 @@ package ast
import (
"bytes"
+ "fmt"
"strings"
@prologic
prologic / monkey.diff
Created February 14, 2019 14:47
Object Model for Monkey
diff --git a/ast/ast.go b/ast/ast.go
index e67346c..ea3ab30 100644
--- a/ast/ast.go
+++ b/ast/ast.go
@@ -187,6 +187,19 @@ func (i *Identifier) TokenLiteral() string { return i.Token.Literal }
// String returns a stringified version of the AST for debugging
func (i *Identifier) String() string { return i.Value }
+// Object represents a object value
+type Object struct {
@prologic
prologic / bf.monkey
Created February 11, 2019 15:25
Brainfuck in Monkey Lang
#!./monkey-lang
let fill = fn(x, i) {
let xs = []
while (i > 0) {
xs = push(xs, x)
i = i - 1
}
return xs
}
@prologic
prologic / docker-volume-plugins.md
Last active January 15, 2019 12:43
Docker Volume Plugins
@prologic
prologic / consul.yml
Created January 14, 2019 05:36
Docker Stack for Consul
version: "3.4"
services:
seed:
image: consul:latest
environment:
- "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}"
- "CONSUL_BIND_INTERFACE=eth0"
entrypoint:
- timeout #this seed fires up the cluster after which it is no longer needed
$ zpool status
pool: backup
state: DEGRADED
status: One or more devices could not be opened. Sufficient replicas exist for
the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
see: http://zfsonlinux.org/msg/ZFS-8000-2Q
scan: scrub repaired 0 in 11h52m with 0 errors on Sun Sep 13 19:07:03 2015
config:
prologic@Jamess-MacBook
Sat Dec 23 15:46:59
~/go-projects/eris
(kzisme-43_HostMask) 2
$ go test -d -run TestUser_HostMask
DEBU[0000] accounts: map[admin:[74 68 74 104 74 68 65 48 74 71 116 85 85 49 74 86 99 49 74 79 85 121 57 68 98 69 104 49 87 69 100 118 89 86 108 77 100 71 86 110 99 108 112 54 89 110 65 51 78 68 66 79 90 71 89 49 87 85 90 104 100 84 90 116 82 122 86 109 98 49 86 75 100 88 81 53 99 107 90 68]]
INFO[0000] test listening on :6667
INFO[0000] metrics endpoint listening on :9314
DEBU[0000] test accept: [::1]:56401
2017/12/23 15:47:15 Connected to localhost:6667 ([::1]:6667)