Skip to content

Instantly share code, notes, and snippets.

Working from home forever and ever

Max Claus Nunes maxcnunes

Working from home forever and ever
Block or report user

Report or block maxcnunes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
maxcnunes /
Created Nov 24, 2015
Curl - Get status code and response body
# store the whole response with the status at the and
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST $URL)
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
maxcnunes /
Last active Sep 15, 2019
Aliases for docker-compose
alias c='docker-compose'
alias cb='docker-compose build'
alias cup='docker-compose up'
alias cr='docker-compose run --service-ports --rm'
alias crl='docker-compose run --service-ports --rm local'
alias crd='docker-compose run --service-ports --rm develop'
alias crt='docker-compose run --rm test'
alias crp='docker-compose run --rm provision'
alias crci='docker-compose run --rm ci'
alias crwt='docker-compose run --rm watchtest'
View libxmljs-finding-xml-elements-with-namespaces-using-xpath.js
var libxmljs = require("libxmljs");
var xml = [
'<?xml version="1.0" encoding="utf-8"?>',
'<soap:Envelope xmlns:soap="" xmlns:xsd="">',
' <soap:Body>',
' <Response xmlns="">',
' <Result>',
' <client xmlns="">',
' <msg>SEARCH OK.</msg>',
' <code>0</code>',
maxcnunes / dump-request.go
Created Jun 6, 2019
Dump http request in Go
View dump-request.go
// Save a copy of this request for debugging.
requestDump, err := httputil.DumpRequest(r, true)
if err != nil {
fmt.Println("--->DEBUG ERROR", r.URL, err)
fmt.Println("--->DEBUG BODY", r.URL, string(requestDump))
maxcnunes / Debug-Knockout-JS.html
Last active Apr 26, 2019
Simple way to debug viewmodel data bind with knockout
View Debug-Knockout-JS.html
<pre data-bind="text: ko.toJSON($data, null, 2)"></pre>
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
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 / 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 (
maxcnunes / .gitignore
Created Sep 25, 2013
Git keep empty folder: 1. Add a .gitkeep file inside the folder you want to keep 2. Then include this configuration in your .gitignore
View .gitignore
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
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
You can’t perform that action at this time.