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 / upgradeNextcloud.md
Last active April 2, 2023 13:58
upgrade Nextcloud using docker image

First Method

create your docker-compose file like this one:

version: '3'

volumes:
 nextcloud:
@moraisaugusto
moraisaugusto / git_visual_contribs.md
Created January 6, 2021 08:55
git timeline evolution
#!/bin/bash
gource -1800x1200 --title "My App" --hide progress --max-user-speed 500 --seconds-per-day 0.15 -e 0.005 --bloom-intensity 0.05 --hide filenames -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -crf 19 -threads 0 -bf 0 output.mp4
@moraisaugusto
moraisaugusto / externalHDDonLibreELEC.md
Created December 18, 2020 19:24
Add External HDD on LibreELEC

Mount the flash partition (not necessary but... )

mount -o remount,rw /flash

Normally the external HDD is automatically mounted by LibreELEC, so you just need to format is using ext4 partition datatype

umount /dev/sda2 # check which partition was mounted automatically - `df -h`
@moraisaugusto
moraisaugusto / how_to_create_a_timer.md
Last active December 7, 2020 20:12
systemctl/Timer

To make this answer a useful one, a minimal example for a daily automatic scheduled script at 01:30.

  1. Create two files, one service file and one timer file. Both names (.timer and .service) have to match. F.e.:
sudo vim /usr/lib/systemd/system/scheduledScript.service
sudo vim /usr/lib/systemd/system/scheduledScript.timer

(The folder /usr/lib/systemd/system/... is the default folder containing all .service files)

@moraisaugusto
moraisaugusto / wifi-wakeup.sh
Last active November 14, 2020 15:10
wake up wifi when sleep
#!/bin/bash
# this file will reconnect the wifi when you wake up you OS (tested on Arch)
# save this file /usr/lib/systemd/system-sleep
case $1 in
pre)
# unload the modules before going to sleep
;;
post)
sleep 2
systemctl restart wpa_supplicant.service
@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
@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 / 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 / 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_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.