Skip to content

Instantly share code, notes, and snippets.

Avatar
🧙‍♂️
Working from Mars

Alex Unger refs

🧙‍♂️
Working from Mars
View GitHub Profile
@refs
refs / mem_bomb.go
Created Mar 25, 2021
golang memory bomb
View mem_bomb.go
package main
func main() {
a := make([]int, 2, 4)
for i := 0; i < cap(a); i++ {
a = append(a, i)
}
}
View main.go
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
)
View syncMutex.go
package mapConc
import (
"fmt"
"sync"
)
type db struct {
mutexes sync.Map
values sync.Map
View using-ocis-on-remote.md

Running OCIS on a remote host

  1. clone github.com/owncloud.ocis
  2. either make clean build or go run...
    1. if no support for mDNS set MICRO_REGISTRY=etcd and run etcd > etcd &
  3. edit environment to configure konnectd:
OCIS_BASE_URL=your.machine:9200
PROXY_HTTP_ADDR=0.0.0.0:9200
View RFC-and-reads.md
View fmt-ready-baked-recipes.md

Width + Precision (*.*)

width

fmt.Printf("%*v", 9, 42) // denoted by *

precision

@refs
refs / logger_middleware.go
Created Nov 4, 2020 — forked from blixt/logger_middleware.go
Logger middleware for Go HTTP servers which logs every request with response status code in the Apache format.
View logger_middleware.go
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"time"
)
View chi-changes.patch
diff --git a/go.mod b/go.mod
index bb61c09..d3a63d1 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,7 @@ require (
contrib.go.opencensus.io/exporter/jaeger v0.2.1
contrib.go.opencensus.io/exporter/ocagent v0.6.0
contrib.go.opencensus.io/exporter/zipkin v0.1.1
+ github.com/UnnoTed/fileb0x v1.1.4 // indirect
github.com/go-chi/chi v4.1.2+incompatible
View b63a9767dff808cd514d7a8675aa1b62.json
This file has been truncated, but you can view the full file.
{
"data": [
{
"traceID": "b63a9767dff808cd514d7a8675aa1b62",
"spans": [
{
"traceID": "b63a9767dff808cd514d7a8675aa1b62",
"spanID": "9e1b5b007424eb45",
"flags": 1,
View accounts-subcommand.diff
diff --git a/pkg/command/accounts.go b/pkg/command/accounts.go
index b449349..f3883eb 100644
--- a/pkg/command/accounts.go
+++ b/pkg/command/accounts.go
@@ -3,6 +3,8 @@
package command
import (
+ "fmt"
+