Skip to content

Instantly share code, notes, and snippets.

View moraisaugusto's full-sized avatar
🎯
Focusing

Augusto Morais moraisaugusto

🎯
Focusing
View GitHub Profile
@moraisaugusto
moraisaugusto / git_ff_no-ff.md
Last active June 4, 2020 14:35
git fast forward vs no fast forward

Difference between a git fast forward and no fast forward

Initial Repository

Create an initial repository following the instructions below.

initial_repo.sh

#!/usr/bin/env sh
@moraisaugusto
moraisaugusto / vpn-company.sh
Created March 20, 2020 09:43
openvpn - handle dns entries
#!/usr/bin/env sh
# alternative to: openvpn-update-resolv-conf: aur package
# I don't want to install a openvpn script to just handle dns entries for a VPN connection
# So, I created this script to do it
if ps ax | grep "openvpn --config" | grep "OPENVPN_CONFIG_PROVIDED_BY_COMPANY.ovpn" > /dev/null
then
echo "VPN CONNECTED"
echo "restoring resolv.conf..."
sudo sed -i '/DNS_SERVER_IP/d' /etc/resolv.conf
@moraisaugusto
moraisaugusto / default_apps.sh
Created February 27, 2020 20:55
change default apps on i3wm
# case you dont have $BROWSER env. var defined
$ xdg-settings set default-web-browser firefox-developer-edition.desktop
$ xdg-mime default firefox-developer-edition.desktop x-scheme-handler/http
$ xdg-mime default firefox-developer-edition.desktop x-scheme-handler/http
@moraisaugusto
moraisaugusto / post_curl.sh
Last active January 27, 2020 11:29
Multidata POST using cURL
curl -i -X POST -H "Content-Type: multipart/form-data" \
-F "file=@/home/USERNAME/YOUR_FILE_HERE.xlsx \
-F "param1=4" \
-F "param2=CALCULATED" \
-F "period=1" \
-F "effective_date=2020-31-31" \
http://localhost:8080/entrypoint_x
@moraisaugusto
moraisaugusto / 10-udisk2.rules
Last active May 27, 2025 18:41
automount partitions using polkit-1 and udisk2 - used for external disks and usb drives
// See the polkit(8) man page for more information
// about configuring polkit.
// SAVE IT ON: /etc/polkit-1/rules.d/
// replace the ntfs-3g package: ntfs-3g-fuse
// Allow udisks2 to mount devices without authentication
// for users in the "wheel" group.
polkit.addRule(function(action, subject) {
if ((action.id == "org.freedesktop.udisks2.filesystem-mount-system" ||
action.id == "org.freedesktop.udisks2.filesystem-mount") &&
@moraisaugusto
moraisaugusto / timeout-postgres.md
Last active January 28, 2021 22:15
Dealing with idle connections in Azure Postgres
@moraisaugusto
moraisaugusto / psql_dump_restore.sh
Created November 26, 2019 13:56
Postgresql - Dump and Restore
# to perform a dump with only the Data, not the schema ( using SSL)
$ PGSSLMODE=allow pg_dump -v -Fc --data-only -h HOST -p 5432 -U USERNAME DB_NAME --exclude-table-data NOT_THIS_TABLE > testing-data-only.sql
# to restore the dump
$ pg_restore -h localhost -p 5432 -U USERNAME -d DB_NAME < testing-data-only.sql
@moraisaugusto
moraisaugusto / docker-compose.yaml
Last active November 5, 2019 16:14
debug python from docker container
# You should add the line
# `stdin_open: true` and
# `tty: true` on your docker-compose file.
# Then, just add the `__import__("ipdb").set_trace()` as
# usually you do in your python code.
version: "3"
services:
app_tests:
build: .
@moraisaugusto
moraisaugusto / env.py
Created August 6, 2019 15:32
SqlAlchemy + Alembic + DYNACONF +SSL enabled
from __future__ import with_statement
import sys,os
from logging.config import fileConfig
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
@moraisaugusto
moraisaugusto / drop_role.sql
Created August 1, 2019 08:09
Remove user/role from Postgres
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM username;
REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM username;
REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM username;
DROP USER username;
DROP ROLE username;