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 / 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 / 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 / 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 / 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 / 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 / git_squash.md
Last active June 4, 2020 16:24
Git squashing an old feature branch

Squashing an old feature branch

Sometimes you are working in a feature branch that was opened a long time ago and, you would like to reorganize all the commits from this feature branch.

This branch normally can be very confusing to read and there are some tips that you should know before doing a rebase (squashing).

how is organized the history?

The first thing that you should do is to understand how is organized your branch.

@moraisaugusto
moraisaugusto / sqlalchemy-add-enum.md
Created June 17, 2020 14:57
SQLAlchemy - Add Enumeration record

SQLAlchemy doesn't generate a CREATE/DROP script for an existing enumeration datatype in Postgresql. For that, you need to manually change your generated version script - versions/HASH_NUMBER.py and change the datatype manually.

versions/SHA.py

def upgrade():
    if not op.get_context().as_sql:
 connection = op.get_bind()
@moraisaugusto
moraisaugusto / git_prompt.md
Created July 22, 2020 15:17
bring back git prompt
$ git config --global --unset credential.helper 
$ git config --system --unset credential.helper
@moraisaugusto
moraisaugusto / enums.sql
Created August 13, 2020 15:57
Postgresql - ENUM values
-- Create enumetation
CREATE TYPE currency AS ENUM ('USD', 'BRL', 'USD');
-- Add value
ALTER TYPE currency ADD VALUE 'GBP';
-- Remove value
DELETE FROM pg_enum
WHERE enumlabel = 'GBP'
AND enumtypid = ( SELECT oid FROM pg_type WHERE typname = 'currency')
@moraisaugusto
moraisaugusto / nvidia_sleep.sh
Created September 29, 2020 09:17
reload nvidia driver after sleep mode
#!/usr/bin/env sh
# It seems to have some cuda issues with sleep/suspend
# I had this with pytorch
sudo rmmod nvidia_uvm
sudo modprobe nvidia_uvm