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
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://')
View Open-a-Visual-Studio-Solution-from-a-Git-Alias-And-Navigate-to-Directory
alias open-my-project='cd "full/path/to/MySolutionFolder/" && start MySolution.sln /D .'
#alias open-mp='cd "C:/Users/max.nunes/Projects/myproject/" && start myproject.sln /D .'
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