Skip to content

Instantly share code, notes, and snippets.

View maxcnunes's full-sized avatar
🏠
Working from home forever and ever

Max Claus Nunes maxcnunes

🏠
Working from home forever and ever
View GitHub Profile
@maxcnunes
maxcnunes / status_test.go
Last active March 9, 2019 13:10
Performance over different approaches to get a mask format from a HTTP status code (e.g. 201=2xx, 204=2xx, 405=4xx, 500=5xx)
package util_test
import (
"fmt"
"math"
"regexp"
"strconv"
"testing"
)
@maxcnunes
maxcnunes / .gitignore
Created September 25, 2013 20:03
Git keep empty folder: 1. Add a .gitkeep file inside the folder you want to keep 2. Then include this configuration in your .gitignore
path_your_folder/*
!path_your_folder/.gitkeep
@maxcnunes
maxcnunes / result
Created March 8, 2019 22:46
Performance and memory profiling Go concat vs fmt.Sprintf
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 / README.md
Last active November 7, 2018 09:48
Forwarding TCP-traffic to a UNIX socket

Base Command

socat -d -d TCP4-LISTEN:15432,fork UNIX-CONNECT:/srv/mongodb-27017.sock

Final Script

./forward-port-to-socket.sh 15432 /srv/mongodb-27017.sock
@maxcnunes
maxcnunes / update-coreos-cloud-config.sh
Created February 28, 2015 03:08
Update coreos cloud config
#!/bin/bash
SERVER_IP=<MY_SERVER_IP>
# copy cloud-config.yml to the server
scp cloud-config.yml core@$SERVER_IP:~/
# validate cloud-config file
ssh core@$SERVER_IP "coreos-cloudinit -validate --from-file ~/cloud-config.yml"
if [[ $? == "0" ]]; then
@maxcnunes
maxcnunes / pull_pr.sh
Last active December 25, 2017 12:26
Simple script to pull Git PRs
pull_pr() {
pr_num=$1
git fetch origin refs/pull/$pr_num/head:pr/$pr_num
}
<FormattedHTMLMessage
id="news-publish.not-allowed.html"
values={{ emailSupport: support.email }}
defaultMessage={"Please contact <a href=\"mailto:{emailSupport}\">support</a>."} />
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'
# setting a new alias
git config --global --add alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit --all"
# using the new alias
git lol
@maxcnunes
maxcnunes / remove-node_module-recursively-1.sh
Last active January 25, 2017 17:24
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.
# Simple version using only "find"
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +