Skip to content

Instantly share code, notes, and snippets.

View samirfor's full-sized avatar

Samir C. Costa samirfor

  • Brazil
  • 04:50 (UTC -03:00)
View GitHub Profile
@samirfor
samirfor / revoke_pgsql_user.md
Last active January 19, 2024 13:16
Revoke a user on PostgreSQL
DBNAME=# \du
                                    List of roles
  Role name  |                         Attributes                         | Member of
-------------+------------------------------------------------------------+-----------
 user        |                                                            | {}
 postgres    | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 dbuser      |                                                            | {}

DBNAME=# REASSIGN OWNED BY dbuser TO postgres;
@samirfor
samirfor / zero_downtime_deploy.sh
Created September 1, 2023 22:28
Simple, zero-downtime deploys with nginx and docker-compose
#!/bin/bash
# Simple, zero-downtime deploys with nginx and docker-compose
# Thanks to Stephen O'Brien, Head of Product, Tines
# Source: https://www.tines.com/blog/simple-zero-downtime-deploys-with-nginx-and-docker-compose
set -e
set -x
compose_yml="${1:-docker-compose.yml}"
@samirfor
samirfor / README.md
Created January 5, 2023 13:52 — forked from syukronrm/README.md
Fish Shell function for sourcing standard .env files

envsource

I've been using Fish shell for years which is great and all, but one thing that has got me frustrated is using it with .env files.

When attempting to run source .env in a project, I usually encounter this problem:

.env (line 2): Unsupported use of '='. In fish, please use 'set KEY value'.
from sourcing file .env
source: Error while reading file '.env'
@samirfor
samirfor / inventario-agent-install.sh
Last active September 27, 2019 12:35
Instala o fusioninventory-agent no Ubuntu
#!/bin/bash
set -e
#############################################
# Instala o fusioninventory-agent no Ubuntu #
#############################################
HOST_GLPI="glpi.ifce.taua"
[ "$(whoami)" != "root" ] && echo "Precisa ser root" && exit 1
@samirfor
samirfor / func_retira_acentuacao.sql
Last active November 19, 2018 19:01
Uma funçãozinha para remover acentos de strings no PostgreSQL... Útil.
-- Uma funçãozinha para remover acentos de strings no PostgreSQL... Útil.
-- Créditos: papo sql
CREATE OR REPLACE FUNCTION retira_acentuacao(p_texto text) RETURNS text AS $BODY$
SELECT TRANSLATE($1,
'áàâãäåÁÀÂÃÄÅéèêẽëÉÈÊẼËíìîïÍÌÎÏóòôõöÓÒÔÕÖúùûüÚÙÛŨÜçÇñÑýÝ',
'aaaaaaAAAAAAeeeeeEEEEEiiiiIIIIoooooOOOOOuuuuUUUUUcCnNyY'
);
$BODY$ LANGUAGE SQL VOLATILE COST 100;
@samirfor
samirfor / pje.decode.captcha.sh
Created August 14, 2018 18:45
PJe Captcha Decoder
#!/bin/sh
# Dependencies: convert=ImageMagick and Tesseract
INPUT=$1
convert $1 -scale 200% -negate -morphology erode octagon:2 -negate -threshold 80% out.png
tesseract -psm 8 -c tessedit_char_whitelist=0123456789 out.png -
@samirfor
samirfor / m3u8-to-mp4.md
Created May 21, 2018 14:47 — forked from tzmartin/m3u8-to-mp4.md
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
@samirfor
samirfor / serpro.hod.ubuntu.sh
Last active May 7, 2018 21:14
Instalação Java + Palemoon para acesso ao HOD do Serpro no xUbuntu 16.04
#!/bin/bash
###########################################################
# Instalação Java + Palemoon para acesso ao HOD do Serpro #
# no xUbuntu 16.04 #
###########################################################
set -e # para a execução caso haja erro
set -x # debug, mostra os comandos
@samirfor
samirfor / gen.int.sh
Last active April 6, 2018 03:08
Gera 3 números distintos inteiros pares múltiplos de 3, entre 1 e 35.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int gerar()
{
int r = ((rand() % (35 / 2)) + 1) * 2;
while (r % 3)
{
r = ((rand() % (35 / 2)) + 1) * 2;
@samirfor
samirfor / palemoon.32b.install.on.manjaro.linux.64b.sh
Created February 27, 2018 13:10
Installing Palemoon 32 bits on Manjaro Linux 64 bits
#!/bin/sh
set -e
echo "== Installing Palemoon 32 bits on Manjaro Linux 64 bits =="
echo
echo "Installing deps (lib32) ..."
echo
yaourt -S --noconfirm lib32-gtk2 lib32-dbus-glib bin-jre7
echo