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 / 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
View react-intl FormattedHTMLMessage
<FormattedHTMLMessage
id="news-publish.not-allowed.html"
values={{ emailSupport: support.email }}
defaultMessage={"Please contact <a href=\"mailto:{emailSupport}\">support</a>."} />
@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'
@maxcnunes
maxcnunes / get-npm-package-version
Last active Nov 29, 2015 — forked from yvele/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
View get-npm-package-version
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[ ",]//g')
echo $PACKAGE_VERSION
@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://')
@maxcnunes
maxcnunes / bash-commands.sh
Last active Aug 29, 2016
List of handful bash commands
View bash-commands.sh
#!/bin/bash
# signals bash to stop execution on any fail
set -e
# if variable not defined
if [[ -z "$BACKUP_FILE" ]]; then
...
fi
@maxcnunes
maxcnunes / docker-cleanup-volumes.sh
Created Jul 15, 2015
Script to remove orphaned docker volumes
View docker-cleanup-volumes.sh
#!/bin/bash
# Usage:
# - To only show the possbible volumes to be removed:
# ./docker-cleanup-volumes.sh
# - To remove orphaned docker volumes:
# ./docker-cleanup-volumes.sh clean
if [ "$1" == 'clean' ]; then
echo "cleaning..."
@maxcnunes
maxcnunes / ssh-tunnel.sh
Created Jun 17, 2015
ssh tunnel and multiple tunnels
View ssh-tunnel.sh
# single tunnel
ssh -L <local-ip-on-my-machine>:<local-port-on-my-machine>:\
<local-ip-on-server>:<local-port-on-server> \
-C -N <server-user>@<server-ip>
# EXMAPLES
# -------------
# SINGLE TUNNEL
ssh -L 0.0.0.0:27017:172.17.42.1:27017 -C -N core@192.168.0.100
# -------------
View docker-handy-commands.sh
# remove dangling images
docker rmi $(docker images -q -f dangling=true)
# remove dead containers
docker rm $(docker ps -aq)
You can’t perform that action at this time.