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
from flask import Flask, render_template, redirect, url_for
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
# Basic Routes #
@maxcnunes
maxcnunes / alias-docker-compose.sh
Last active August 27, 2023 15:11
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'
@maxcnunes
maxcnunes / curl-get-status-code-and-response-body.sh
Created November 24, 2015 17:52
Curl - Get status code and response body
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://')
@maxcnunes
maxcnunes / example.js
Created December 24, 2013 12:55
Wait mongo connection before test express controller/route with supertest
var request = require('supertest'),
mongoose = require('mongoose'),
app = require('../../../../server');
describe('GET /api/transactions/import', function(){
before(function (done) {
mongoose.connection.on('open', done);
});
it('respond with json', function(done){
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 .'
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 June 6, 2019 21:35
Dump http request in 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 April 26, 2019 11:07
Simple way to debug viewmodel data bind with knockout
<pre data-bind="text: ko.toJSON($data, null, 2)"></pre>
@maxcnunes
maxcnunes / postgres-dblink.sql
Created April 11, 2016 11:36
Example using dblink to execute a SELECT query between different databases. (PG 9.4)
@maxcnunes
maxcnunes / gist:3e64a3422564f88b5629da5a0ccd4fc1
Created March 18, 2019 21:11
Docker - list all containers' ip and find container by ip
for i in $(docker ps -aq); do docker inspect -f '{{.Name}}: IP={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$i"; done | grep <ip-here>