Skip to content

Instantly share code, notes, and snippets.

View antoniosmgatto's full-sized avatar
🏠
Working from home

Antonio Gatto antoniosmgatto

🏠
Working from home
View GitHub Profile
@antoniosmgatto
antoniosmgatto / mysql-backup.sh
Last active December 28, 2021 01:01
Mysql backup script
#!/bin/bash
# errexit -> exit when any command fails
set -o errexit
# will fails exit if an pipe command fails
set -o pipefail
# nounset -> exit when an unsed variable is used
set -o nounset
@antoniosmgatto
antoniosmgatto / postgres-bkp.sh
Created October 4, 2021 15:13
Postgres backup with gzip support and upload to S3/Digital Ocean Spaces
#!/bin/bash
WORKSPACE_DIR="/tmp/postgres_bkp"
DB_URL="$1"
BACKUP_FILENAME="$2"
S3_CMD=$(which s3cmd)
SPACES_BUCKET="your-bucket-here"
if [ -z "$DB_URL" ] || [ -z "$BACKUP_FILENAME" ]; then
echo "You must set database connection and output filename !!!";
@antoniosmgatto
antoniosmgatto / Capfile
Last active June 7, 2021 22:17
rails + postgres + sidekiq + capistrado
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/bundler"
require "capistrano/scm/git"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"
require "capistrano/data_migrate"
require "capistrano/rbenv"

String

In this introductory challenge, your task is to use each of the above three methods to return the text Hello World and others!

def single_quote
  # single quote string here
    'Hello World and others!'
end
\set PROMPT1 '%M:%[%033[1;31m%]%>%[%033[0m%] %n@%/%R%#%x '
\set ON_ERROR_ROLLBACK interactive
\set COMP_KEYWORD_CASE upper
\set HISTFILE ~/.psql/history- :DBNAME
\timing
\x auto
\pset pager off
\pset null '(null)'
@antoniosmgatto
antoniosmgatto / postgres.md
Last active October 25, 2021 13:11
postgres comands

Postgres tips

DML = Data Manipulation language (INSERT, UPDATE, DELETE and SELECT) DDL = Data definition Language (CREATE, ALTER, DROP)

smallserial, serial and bigserial columns are autoincrement

psql commands

Show roles: \du

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lor
# create a new express app
express clubeincentivo-api -v pug