Skip to content

Instantly share code, notes, and snippets.

Josh Baker tidwall

Block or report user

Report or block tidwall

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tidwall / bench_test.go
Created Jan 29, 2020
Benchmark sjson vs Go for simples json updates
View bench_test.go
package bench
import (
var data = []byte(`{
tidwall / ints2bools.go
Last active Mar 26, 2019
@ints2bools gjson modifier
View ints2bools.go
package main
import ""
func init() {
// define the @ints2bools modifier once.
gjson.AddModifier("ints2bools", func(json, _ string) string {
res := gjson.Parse(json)
switch res.Type {
case gjson.Number:
tidwall / main.go
Created Mar 13, 2019
Go 1.12 network slowdown on Darwin
View main.go
package main
import (
tidwall / tile38-location-hist.lua
Created Jul 27, 2018
Tile38 save short history of the last 10 locations for a given point
View tile38-location-hist.lua
-- add the point"SET", ARGV[1], ARGV[2], "POINT", ARGV[3], ARGV[4])
-- get the previous history
local oldhist ="GET", ARGV[1] .. ":history", ARGV[2])
if oldhist == nil then
oldhist = ""
-- parse the last 9 lines
tidwall /
Created May 27, 2018
Go cover helper with html output
# add this to your ~/.bash_profile or whatnot
local r
if [[ $@ == "test -cover" ]]; then
r="$(command go test -coverprofile=/tmp/coverage.out)"
if [ "$r" != "" ]; then
printf "%s\n" "$r"
if [[ "$r" == *"100.0%"* ]]; then
tidwall /
Last active May 26, 2018
Pass custom var strings to gcc
gcc -DgitSHA="$(git rev-parse HEAD)" main.c
View evio_context.go
type myConn struct {
func main(){
var events Events
events.Opened = func(id int, info evio.Info) (out []byte, opts evio.Options, ctx interface{}, action evio.Action){
// create a new connection object that is specific to the new connection
// and assign to the context interface. this will be passed through other events.
conn := &myConn{}
ctx = conn
tidwall / evio.go
Created Apr 27, 2018
Multi-threaded Evio
View evio.go
package main
import (
func main() {
tidwall /
Created Mar 18, 2018


Using the reuseport branch of evio, you can now provide an SO_REUSEPORT address options from the Serve function.

evio.Serve(events, "tcp://")

This allows for multiple process/threads/goroutines to share the same address+port.

tidwall / tile38.geojson
Last active Mar 9, 2018
View tile38.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.