Skip to content

Instantly share code, notes, and snippets.

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

Lindemberg Barbosa bergpb

🏠
Working from home
View GitHub Profile
@bergpb
bergpb / postgres-cheatsheet.md
Created March 29, 2022 17:14 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@bergpb
bergpb / install.md
Created March 20, 2022 15:43 — forked from Ryanb58/install.md
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
@bergpb
bergpb / youtube_clean_watch_later_videos.js
Last active May 26, 2021 16:07 — forked from qoomon/youtube_clean_watch_later_videos.js
Clean YouTube Watch Later Videos
// This script will remove all videos from watch later list
//
// Usage
//
// #1 go to https://www.youtube.com/playlist?list=WL
// #2 run following script
// adjust REMOVE_BUTTON_TEXT_MAP if your language is missing
(async function() {
const REMOVE_BUTTON_TEXT_MAP = {
@bergpb
bergpb / SessionTimeout.php
Created February 24, 2021 22:27 — forked from rcaneppele/SessionTimeout.php
Configurando Session-Timeout no PHP
session_start();
$timeout = 600; // Tempo da sessao em segundos
// Verifica se existe o parametro timeout
if(isset($_SESSION['timeout'])) {
// Calcula o tempo que ja se passou desde a cricao da sessao
$duracao = time() - (int) $_SESSION['timeout'];
// Verifica se ja expirou o tempo da sessao
if($duracao > $timeout) {
@bergpb
bergpb / Transfer repository
Created February 16, 2021 16:53 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@bergpb
bergpb / git-ftp.sh
Created February 16, 2021 16:44
Uso do git-ftp
# Realiza a sincronização do repositório
git ftp push -b main -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST -v
# Realiza o envio apenas dos arquivos alterados
git ftp push -b main -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST -v
@bergpb
bergpb / revisao-commit.md
Created February 15, 2021 12:35 — forked from pedrosancao/revisao-commit.md
Manual de Revisão de Commit

Manual de Revisão de Commit

O uso de repositórios GIT tem diversos benefícios: trabalho em equipe, desenvolvimento de recursos separadamente, histórico das alterações, etc. Mas para disponibilizar todo o potencial é preciso um pouco de dedicação no momento do commit.

Não é preciso uma vasta experiência para já ter passado por situações como conflito de arquivos onde a mensagem não traz nenhuma informações relevante e é preciso inverstigar o que a outra pessoa estava desenvolvendo ou após

@bergpb
bergpb / openweather_emoji.py
Created January 18, 2021 00:06
Uses the OpenWeatherMap to get an emoji based on the current weather // OpenWeaterMap emoji matcher in python.
# Based on ruby version: https://gist.github.com/michels/90327b8d284646a238e6
import requests
OPENWEATHER_APIKEY = "" # TODO add your apikey here
CITY = "Fortaleza"
def get_weather_emoji(weather_id):
# Openweathermap Weather codes and corressponding emojis
thunderstorm = "💨" # Code: 200's Thunderstorm
drizzle = "💧" # Code: 300's Drizzle
@bergpb
bergpb / ansible-github.yml
Created January 11, 2021 14:12 — forked from devynspencer/ansible-github.yml
Example playbook for cloning a private git repository with Ansible.
---
hosts: all
tasks:
- name: add github ssh key
copy: >
src=files/id_rsa.github
dest=/root/.ssh/id_rsa.github
owner=root
group=root
@bergpb
bergpb / semantic-commit-messages.md
Created January 10, 2021 16:28 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example