Skip to content

Instantly share code, notes, and snippets.

@mem
mem / get-proto-metrics
Created October 24, 2023 00:17
How to get a Prometheus endpoint to serve Probobuf instead of the text exposition format
curl \
--include \
-H 'Accept: application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=compact-text' \
$@
@mem
mem / gist:83f6c9bb82cf7ea2eeea5668d596068f
Created September 27, 2023 00:44
how to use go:linkname
package main
import (
"fmt"
_ "unsafe"
_ "github.com/prometheus/prometheus/model/textparse"
dto "github.com/prometheus/prometheus/prompb/io/prometheus/client"
)
@mem
mem / tools.yaml
Created November 25, 2022 22:38
my tools.yaml file
tools:
entgo.io/ent/cmd/ent:
github.com/766b/godox:
github.com/akavel/up:
github.com/caddyserver/caddy/v2/cmd/caddy:
github.com/cli/cli:
clone: true
build:
- make bin/gh
- cp bin/gh ${OUTDIR}
package main
import (
"bytes"
"fmt"
"regexp"
"strings"
"testing"
)
@startuml
autonumber
hide footbox
participant "wrapper\n(stage 2)" as wrapper
participant "stage 1" as stage_1
participant master
participant "rpc server" as rpc_server
@mem
mem / generic_mount_flow.plantuml
Created May 30, 2019 17:57
Description of generic mount flow
@startuml
autonumber
hide footbox
participant "wrapper\n(stage 2)" as wrapper
participant "stage 1" as stage_1
participant master
participant "rpc server" as rpc_server
### Keybase proof
I hereby claim:
* I am mem on github.
* I am mem (https://keybase.io/mem) on keybase.
* I have a public key ASC7tQYyimGItv9HXARDm-zuEZx7HZwV_Px4hRcsZbOxkgo
To claim this, I am signing this object:
@mem
mem / go
Created July 13, 2016 19:09
go wrapper to automatically set GOPATH
#!/bin/sh
get_inode() {
stat -c '%i' "$1"
}
find_go() {
self=`get_inode $(readlink -m "$1")`
local IFS=:
-- http://sylnsr.blogspot.com/2015/08/generate-golang-struct-model-from.html
WITH models AS (
WITH data AS (
SELECT
replace(initcap(table_name::text), '_', '') table_name,
replace(initcap(column_name::text), '_', '') column_name,
CASE data_type
WHEN 'timestamp without time zone' THEN 'time.Time'
WHEN 'timestamp with time zone' THEN 'time.Time'
WHEN 'boolean' THEN 'bool'
#!/bin/sh
#
# Given a package's import path, this script will list the Go sources (not in $GOROOT)
# used to build that pacakge.
go list -f '{{ join .Deps "\n" }}' "$@" |
xargs -r -d '\n' \
go list -f '{{ if not .Goroot }}{{ .ImportPath }}{{ end }}' 2> /dev/null |
xargs -r -d '\n' \
go list \