Skip to content

Instantly share code, notes, and snippets.

from sqlalchemy import Table, MetaData, create_engine
from sqlalchemy.engine import reflection
# Configurações de conexão abstraídas em variáveis de ambiente setadas num arquivo .env
DB_USER = os.getenv('DB_USER')
DB_PASS = os.getenv('DB_PASS')
DB_HOST = os.getenv('DB_HOST')
DB_NAME = os.getenv('DB_NAME')
SQLALCHEMY_DATABASE_URL = f"postgresql+psycopg2://{DB_USER}:{DB_PASS}@{DB_HOST}:5432/{DB_NAME}"
@hilam
hilam / database_to_parquet.py
Created January 13, 2022 20:38 — forked from rvaidya/database_to_parquet.py
Dump database table to parquet file using sqlalchemy and fastparquet. Useful for loading large tables into pandas / Dask, since read_sql_table will hammer the server with queries if the # of partitions/chunks is high. Using this you write a temp parquet file, then use read_parquet to get the data into a DataFrame
import pandas as pd
import numpy as np
import fastparquet
from sqlalchemy import create_engine, schema, Table
# Copied from pandas with modifications
def __get_dtype(column, sqltype):
import sqlalchemy.dialects as sqld
@hilam
hilam / blink.rpy
Created December 28, 2021 10:59 — forked from RuolinZheng08/blink.rpy
[RENPY] Dynamic Blink
@hilam
hilam / clean_snap.sh
Created March 29, 2021 04:35
Limpar cache de snap, aplicações desabilitadas
#!/bin/bash
#Removes old revisions of snaps
#CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@hilam
hilam / sampleREADME.md
Created January 24, 2020 23:24 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.

FVCproductions

INSERT GRAPHIC HERE (include hyperlink in image)

Repository Title Goes Here

Subtitle or Short Description Goes Here

@hilam
hilam / profile_and_stats.py
Created July 9, 2019 12:45
Profile And Stats Of Your Code
import cProfile, pstats, StringIO
pr = cProfile.Profile()
pr.enable()
# ... do something ...
pr.disable()
s = StringIO.StringIO()
ps = pstats.Stats(pr, stream=s).sort_stats(‘cumulative’)
ps.print_stats()
@hilam
hilam / spreadsheet.py
Created January 6, 2018 13:45 — forked from alchemyst/spreadsheet.py
Spreadsheet in 100 lines of Python
#!/usr/bin/env python
import tkinter as tk
import math
import re
from collections import ChainMap
Nrows = 5
Ncols = 5
@hilam
hilam / git-update-fork.sh
Created November 26, 2017 15:15 — forked from rdeavila/git-update-fork.sh
Git: como atualizar um fork com as mudanças do original?
#!/bin/bash
# Adicione um novo remote; pode chamá-lo de "upstream":
git remote add upstream https://github.com/usuario/projeto.git
# Obtenha todos os branches deste novo remote,
# como o upstream/master por exemplo:
git fetch upstream
@hilam
hilam / how-to-split-a-file-into-smaller-chunks.md
Created March 9, 2017 10:24 — forked from nepsilon/how-to-split-a-file-into-smaller-chunks.md
How to split a file into smaller chunks? — First published in fullweb.io issue #90

How to split a file into smaller chunks?

You may want to upload a 100GB file over an unstable network, or feed your scripts smaller inputs to load in RAM. In both cases, just splitting your file into smaller chunks is an easy solution.

Great news is Unix/Linux systems have the split utility already installed. And using it is simple as pie:

Cut a binary file into chunks of X bytes:

split -b X bigfile.avi
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
fi
# some more ls aliases
alias ll='ls -la -h'