Skip to content

Instantly share code, notes, and snippets.

View henvic's full-sized avatar

Henrique Vicente henvic

View GitHub Profile
cheat() {
curl "https://cheat.sh/$1"
}
export GH_EDITOR="code"
export FZF_DEFAULT_COMMAND='ag -g ""'
ZSH_THEME="steeef"
@henvic
henvic / middleware.go
Created November 22, 2021 07:33
httpretty logger middleware
// HTTPLogger for https://github.com/henvic/httpretty
// to provide useful debugging info when running:
// $ DEBUG=api go run github.com/henvic/pgxtutorial/cmd/pgxtutorial
func HTTPLogger() func(http.Handler) http.Handler {
if !strings.Contains(os.Getenv("DEBUG"), "api") {
return nil
}
_, noColor := os.LookupEnv("NO_COLOR") // See https://no-color.org/
if !noColor {
if fileInfo, _ := os.Stdout.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
@henvic
henvic / searchtest.go
Created October 15, 2021 08:31
search test infrastructure with Replica still using testing.TB (to be replaced)
// Package searchtest can be used to write integration tests with OpenSearch and search-replica.
//
// You can set the following environment variables to control logging:
// VERBOSE_OPENSEARCH=true to enable logging of requests and responses made with the OpenSearch client.
// VERBOSE_SEARCH_REPLICA=true to print verbose output from the search-replica process.
//
// Use If search-replica isn't on your $PATH or to run a different command, you can set the environment variable:
// SEARCH_REPLICA_COMMAND=search-replica
//
// search-replica works subscribing to a PostgreSQL publication using logical replication.
@henvic
henvic / pgxinterface.go
Last active October 24, 2021 11:24
Interface containing a subset of the API from *pgx.Conn and *pgxpool.Pool
package postgres
import (
"context"
"github.com/jackc/pgconn"
"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v4/pgxpool"
)
func new11RandomID() string {
const (
alphabet = "123456789ABCDEFGHJKLMNPQRSTUWVXYZabcdefghijkmnopqrstuwvxyz" // base58
size = 11
)
var id = make([]byte, size)
if _, err := rand.Read(id); err != nil {
panic(err)
}
@henvic
henvic / description
Last active August 12, 2020 21:01
picel failure on newer go 1.15
go tests are failing on the latest version of Go.
Still need to investigate. Using -race flag didn't detect any race condition, and this failure is happening with Mutual TLS.
@henvic
henvic / market.sh
Created July 17, 2020 22:39
market server example
$ ./market
Usage: market <command> [flags] [arguments]
Commands:
serve run the market server
check-config check and print configuration
users manage users
Flags:
-config (string) configuration path (default "market.ini")
@henvic
henvic / .vimrc
Created May 8, 2020 14:19
.vimrc
set backspace=indent,eol,start
nnoremap <BS> X
if version >= 703
set undofile
set undodir=$HOME/.vim/undo
set undolevels=1000
set undoreload=10000
endif
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>trustList</key>
<dict>
<key>027268293E5F5D17AAA4B3C3E6361E1F92575EAA</key>
<dict>
<key>issuerName</key>
<data>
@henvic
henvic / cl-test.log
Last active April 15, 2020 08:29
TestSystemRoots results in
$ GO111MODULE=on go get golang.org/dl/gotip@latest
$ gotip download 227037
$ GODEBUG=x509roots=1 gotip test crypto/x509 -v -run TestSystemRoots
=== RUN TestSystemRoots
crypto/x509: trust settings for CN=Blue Coat Public Services Intermediate CA,OU=Symantec Trust Network,O=Blue Coat Systems\, Inc.,C=US: SecTrustSettingsCopyTrustSettings error: -25262
crypto/x509: trust settings for CN=CINRADIUS2.windows.cin.ufpe.br: 4
crypto/x509: trust settings for CN=windows-CINRADIUS2-CA: 1
crypto/x509: trust settings for CN=CINRADIUS2.windows.cin.ufpe.br: 4
crypto/x509: trust settings for CN=Charles Proxy Custom Root Certificate (built on henvic-mp.local\, 19 Oct 2015),OU=http://charlesproxy.com/ssl,O=XK72 Ltd,L=Auckland,ST=Auckland,C=NZ: 1
crypto/x509: trust settings for CN=localhost.localdomain,OU=VMware ESX Server Default Certificate,O=VMware\, Inc,L=Palo Alto,ST=California,C=US: 4