Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home forever and ever

Max Claus Nunes maxcnunes

View GitHub Profile
@maxcnunes
maxcnunes / gist:3e64a3422564f88b5629da5a0ccd4fc1
Created Mar 18, 2019
Docker - list all containers' ip and find container by ip
View gist:3e64a3422564f88b5629da5a0ccd4fc1
for i in $(docker ps -aq); do docker inspect -f '{{.Name}}: IP={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$i"; done | grep <ip-here>
@maxcnunes
maxcnunes / status_test.go
Last active Mar 9, 2019
Performance over different approaches to get a mask format from a HTTP status code (e.g. 201=2xx, 204=2xx, 405=4xx, 500=5xx)
View status_test.go
package util_test
import (
"fmt"
"math"
"regexp"
"strconv"
"testing"
)
@maxcnunes
maxcnunes / result
Created Mar 8, 2019
Performance and memory profiling Go concat vs fmt.Sprintf
View result
go test -bench=. -memprofile=mem0.out -benchmem -benchtime=5s
goos: darwin
goarch: amd64
pkg: github.com/InVisionApp/craft-api/util
BenchmarkHello/concat-8 300000000 19.8 ns/op 0 B/op 0 allocs/op
BenchmarkHello/sprintf-8 50000000 119 ns/op 19 B/op 2 allocs/op
PASS
@maxcnunes
maxcnunes / pull_pr.sh
Last active Dec 25, 2017
Simple script to pull Git PRs
View pull_pr.sh
pull_pr() {
pr_num=$1
git fetch origin refs/pull/$pr_num/head:pr/$pr_num
}
@maxcnunes
maxcnunes / remove-node_module-recursively-1.sh
Last active Jan 25, 2017
Remove all node_module folders recursively. Useful to free up disk space by removing the node_module from those projects you have not used for a while.
View remove-node_module-recursively-1.sh
# Simple version using only "find"
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
View v8-profile-cpu-100-usage.txt
Code move event for unknown code: 0x3c010c699080
Code move event for unknown code: 0x3c010c69b9c0
Code move event for unknown code: 0x3c010c5729a0
Code move event for unknown code: 0x3c010c57daa0
Code move event for unknown code: 0x3c010c5c8f00
Code move event for unknown code: 0x3c010c5d90a0
Statistical profiling result from v8.log, (22371 ticks, 0 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
View sqlectron-npm-run-dist.log
μ sqlectron/sqlectron-gui master ❯ npm run dist
> @ dist /Users/maxcnunes/Development/sqlectron/sqlectron-gui
> npm run compile && build --arch all
> @ compile /Users/maxcnunes/Development/sqlectron/sqlectron-gui
> rimraf app/out && cross-env NODE_ENV=production babel-node scripts/compile.js -v
> cleaning old distribution files
View dnsmasq-osx.sh
brew install dnsmasq
mkdir -pv $(brew --prefix)/etc/
echo 'address=/.dev/127.0.0.1' > $(brew --prefix)/etc/dnsmasq.conf
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'
@maxcnunes
maxcnunes / load-connection-uri-from-env-config.go
Created Apr 12, 2016
Load connection URI from ENV config
View load-connection-uri-from-env-config.go
func connectionURIFromEnvConfig() string {
errMsg := "no valid connection string provided"
connConfig, err := url.Parse(os.Getenv("DB_PORT"))
if err != nil {
log.Fatalln(errMsg)
}
dbHost, dbPort, err := net.SplitHostPort(connConfig.Host)
if err != nil {
@maxcnunes
maxcnunes / postgres-dblink.sql
Created Apr 11, 2016
Example using dblink to execute a SELECT query between different databases. (PG 9.4)
View postgres-dblink.sql
You can’t perform that action at this time.