Skip to content

Instantly share code, notes, and snippets.

View onhernandes's full-sized avatar
💭
just havin fun

Matheus onhernandes

💭
just havin fun
View GitHub Profile
@onhernandes
onhernandes / pg_sequences.sql
Created October 13, 2022 18:16
Nice sequence queries for PG
-- set as bigint
ALTER SEQUENCE transaction_id_seq AS BIGINT;
-- select sequences
SELECT * FROM information_schema.sequences ORDER BY sequence_name;
@onhernandes
onhernandes / list-tables-order-by-size.sql
Last active June 13, 2022 16:12
List tables ordering by their size on postgresql
-- copied from https://dataedo.com/kb/query/postgresql/list-of-tables-by-their-size
select schemaname as table_schema,
relname as table_name,
pg_size_pretty(pg_relation_size(relid)) as data_size
from pg_catalog.pg_statio_user_tables
order by pg_relation_size(relid) desc;
#!/usr/bin/python
hoteis = [
{
"nome" : "lakewood",
"classificacao" : 3,
"regular" : {
"dia_da_semana" : 110,
"fim_de_semana" : 90,
},
@onhernandes
onhernandes / spotify-shuffle.py
Last active August 8, 2018 20:09
Shuffle your Spotify's playlist!
# Shuffle your playlist songs!
# This script uses Spotify's API endpoint for *replacing* all songs
# within your playlist. So after shuffling, your songs will appear with a new added date
#
# You need to pass part of your playlist's name and a valid token
# Generate token here: https://developer.spotify.com/console/put-playlist-tracks/
#
# This script uses riffle shuffle 7 times
# https://stackoverflow.com/questions/19898138/how-can-we-riffle-shuffle-the-elements-of-a-list-in-python#19898430
#
@onhernandes
onhernandes / meetup-insights.py
Last active January 11, 2020 23:54
Know how your meetup.com group is growing through events!
# Know how your meetup.com group is growing through events!
# Get your API token here: https://secure.meetup.com/pt-BR/meetup_api/key/
# You don't need to install nothing! It's 100% pure python
# python meetup-insights.py <group-name> <your api token>
from urllib import request,parse
from functools import reduce
import datetime
import sys
import json
@onhernandes
onhernandes / main.py
Last active July 9, 2018 22:23
Criar transações fake no Organizze
# Não quero ter que exportar todo meu histórico das minhas contas bancárias
# e eu preciso controlar meu cartão a partir de certa data no Organizze
# então resolvi criar transações fake no Organizze,
# assim consigo controlar um pouco melhor meu cartão,
# sem ter que adicionar todo meu histórico novamente
# https://github.com/organizze/api-doc
import requests
API_BASE_URL = "https://api.organizze.com.br/rest/v2"
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@onhernandes
onhernandes / Count how much sentences of a word exists on a single file
Created November 9, 2017 18:33
Cool and maybe useful(or lazy) bash snippets
tr ' ' '\n' < LOG_FILE | grep WORD | wc -l