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
@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)
<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 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 / get-npm-package-version
Last active November 29, 2015 16:20 — forked from yvele/get-npm-package-version.sh
Extract version from package.json (NPM) using bash / shell
# 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 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 / bash-commands.sh
Last active August 29, 2016 20:18
List of handful bash commands
#!/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 July 15, 2015 01:44
Script to remove orphaned docker volumes
#!/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 June 17, 2015 19:52
ssh tunnel and multiple tunnels
# 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
# -------------
# remove dangling images
docker rmi $(docker images -q -f dangling=true)
# remove dead containers
docker rm $(docker ps -aq)
for file in *.html; do; mv "$file" "${file%.html}.txt"; done