Skip to content

Instantly share code, notes, and snippets.

View maquinuz's full-sized avatar
:octocat:
Focusing

Alexandre Almeida maquinuz

:octocat:
Focusing
View GitHub Profile
scores = [54,67,48,99,27]
for i, score in enumerate(scores, 1):
print(i, score)
"""
1 54
2 67
3 48
4 99
5 27
"""
import pytest
@pytest.fixture
def A():
return 1
@pytest.fixture
def B():
return 1
@maquinuz
maquinuz / striter.py
Created May 8, 2020 16:42 — forked from anacrolix/striter.py
A Python IO class wrapping an iterable of strings.
import io
class StringIteratorIO(io.TextIOBase):
def __init__(self, iter):
self._iter = iter
self._left = ''
def readable(self):
return True
# https://hakibenita.com/fast-load-data-python-postgresql
from typing import Iterator, Dict, Any, Optional
from urllib.parse import urlencode
import datetime
#------------------------ Profile
import time
@maquinuz
maquinuz / MultiTenantFlask.py
Created March 1, 2020 21:27 — forked from TonyFrancis/MultiTenantFlask.py
Creating multi Tenant system with multiple Database. Switching between databases based on subdomain related to tenant
from functools import wraps
from flask import Flask, g, session, request, abort, jsonify
from flask_migrate import MigrateCommand, Migrate
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
flask_app = Flask(__name__, static_folder='./static')
db = SQLAlchemy()
migrate = Migrate()
@maquinuz
maquinuz / airflow-python3.sh
Created February 3, 2020 17:32 — forked from zacgx/airflow-python3.sh
Installing Airflow with CeleryExcuter, using PostgreSQL as metadata database and Redis for Celery message broker
# this script has been tested and worked in a freshly installed Ubuntu 16.04 and 16.10
# it assumes that you are running airflow in a private netowrk and no need to be worry about outside access
# if that's not the case, the lines for PostgreSQL and Redis in this script need to be updated accordingly
# run as root
sudo su
# initial system updates and installs
apt-get update && apt-get upgrade -y && apt-get autoremove && apt-get autoclean
apt-get -y install build-essential binutils gcc make git htop nethogs tmux
@maquinuz
maquinuz / postgres-cheatsheet.md
Created January 21, 2020 17:56 — 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)
Verifying my Blockstack ID is secured with the address 1KPSUCpkuZDKB9BcPnJJQ6tSotue7L7ysP https://explorer.blockstack.org/address/1KPSUCpkuZDKB9BcPnJJQ6tSotue7L7ysP
Verifying my Blockstack ID is secured with the address 1KPSUCpkuZDKB9BcPnJJQ6tSotue7L7ysP https://explorer.blockstack.org/address/1KPSUCpkuZDKB9BcPnJJQ6tSotue7L7ysP
@maquinuz
maquinuz / app.py
Created November 9, 2017 01:02 — forked from theskumar/app.py
Database diagram using sqlalchemy
# -*- coding: utf-8 -*-
''' Generates database schema graph from a relational database.
Usages:
Add database configuation in this file and then
python app.py
Note: You must have your latest database schema in the database
engine you are running against.
'''
from __future__ import unicode_literals, absolute_import