Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home forever and ever

Max Claus Nunes maxcnunes

🏠
Working from home forever and ever
View GitHub Profile
@maxcnunes
maxcnunes / curl-get-status-code-and-response-body.sh
Created Nov 24, 2015
Curl - Get status code and response body
View curl-get-status-code-and-response-body.sh
URL="http://stackoverflow.com/"
# 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 .'
#example:
#alias open-mp='cd "C:/Users/max.nunes/Projects/myproject/" && start myproject.sln /D .'
@maxcnunes
maxcnunes / alias-docker-compose.sh
Last active Sep 15, 2019
Aliases for docker-compose
View alias-docker-compose.sh
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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">',
' <soap:Body>',
' <Response xmlns="http://tempuri.org/">',
' <Result>',
' <client xmlns="">',
' <msg>SEARCH OK.</msg>',
' <code>0</code>',
@maxcnunes
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
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
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
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 / .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
path_your_folder/*
!path_your_folder/.gitkeep
You can’t perform that action at this time.