Skip to content

Instantly share code, notes, and snippets.

View antonioj-mattos's full-sized avatar

Antonio Jr. Mattos antonioj-mattos

View GitHub Profile
@antonioj-mattos
antonioj-mattos / models.py
Created May 11, 2017 15:59 — forked from kyle-eshares/models.py
Strict ForeignKeys
from __future__ import unicode_literals
from django.db import models
from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor # noqa
class RelationNotLoaded(Exception):
pass
@antonioj-mattos
antonioj-mattos / .pylint.py
Created May 15, 2017 15:31 — forked from IBestuzhev/.pylint.py
Pylint for remote projects
#!/usr/bin/env python3
import subprocess
import sys
path = sys.argv[-1]
if path.startswith('/path/to/my/local/source/folder/'):
path = path.replace('/path/to/my/local/source/folder/', '/app/folder/')
subprocess.run(['docker-compose', 'exec', '-T', 'cross', 'sh', '-c',
@antonioj-mattos
antonioj-mattos / lista-de-nacionalidade.txt
Last active April 19, 2018 16:33 — forked from lpirola/lista-de-nacionalidade.txt
Lista de países em português com suas respectivas nacionalidades
Afeganistão - Afegã
África do Sul - Sul-africana
Albânia - Albanês
Alemanha - Alemã
Andorra - Andorrana
Angola - Angolana
Anguilla - Anguilana
Antárctida -
Antígua e Barbuda - Antiguana
Antilhas Holandesas - Antilhana
@antonioj-mattos
antonioj-mattos / migration_manifest.py
Created July 28, 2017 01:46 — forked from alvinchow86/migration_manifest.py
django-tips-blog-migration-manifest
def handle(self, *app_labels, **options):
# Generate a migrations manifest with latest migration on each app
super(Command, self).handle(*app_labels, **options)
loader = MigrationLoader(None, ignore_no_migrations=True)
apps = sorted(loader.migrated_apps)
graph = loader.graph
with open('latest_migrations.manifest', 'w') as f:
for app_name in apps:
@antonioj-mattos
antonioj-mattos / postgres_queries_and_commands.sql
Created October 11, 2017 03:27 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@antonioj-mattos
antonioj-mattos / Flexible Dockerized Phoenix Deployments.md
Created February 23, 2018 22:27 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

class DatabaseWrapper(BaseDatabaseWrapper):
SEARCH_PAGE_SIZE=999
def __init__(self, *args, **kwargs):
super(DatabaseWrapper, self).__init__(*args, **kwargs)
self.charset = "utf-8"
self.creation = DatabaseCreation(self)
self.features = DatabaseFeatures(self)
if django.VERSION > (1, 4):
self.ops = DatabaseOperations(self)
@antonioj-mattos
antonioj-mattos / advanced-psql-examples.sql
Created May 10, 2019 03:24 — forked from marko-asplund/advanced-psql-examples.sql
Advanced PostgreSQL feature examples. Includes table DDL, example data and queries.
--
-- ** setting up example tables and data **
--
--
CREATE TABLE task (
id BIGSERIAL ,
name TEXT,
parent_id BIGINT REFERENCES task(id),
PRIMARY KEY (id)
@antonioj-mattos
antonioj-mattos / debian.nix
Created June 9, 2019 19:07 — forked from andir/debian.nix
debian stretch
{ pkgs ? import <nixpkgs> {}}:
let
lib = pkgs.lib;
makeImageFromDebDist =
{ name, fullName, size ? 4096, urlPrefix
, packagesList ? "", packagesLists ? [packagesList]
, packages, extraPackages ? [], postInstall ? ""
, extraDebs ? []
, QEMU_OPTS ? "", memSize ? 512
, createRootFS }:
@antonioj-mattos
antonioj-mattos / UNPHAT-principle-pt_BR.md
Last active August 1, 2019 00:08 — forked from rponte/UNPHAT-principle.md
Before choosing an architecture, follow UNPHAT principle

Tecnologia legal? UNPHAT.

Da próxima vez que você se encontrar pesquisando alguma nova tecnologia interessante para (re)construir sua arquitetura, peço que você pare e siga UNPHAT:

  1. Não comece a considerar soluções até entender o problema. Seu objetivo deve ser "resolver" o problema principalmente dentro do domínio do problema, não no domínio da solução.
  2. eNumere várias soluções candidatas. Não comece a cutucar seu favorito!
  3. Considere uma solução candidata e leia o Paper, se houver.
  4. Determine o Contexto Histórico no qual a solução candidata foi projetada ou desenvolvida.
  5. Pese Vantagens contra desvantagens. Determine o que foi de-priorizado para alcançar o que foi priorizado.
  6. Pense! Pondere sobriamente e humildemente quão bem esta solução se adapta ao seu problema. Que fato precisaria ser diferente para você mudar de ideia? Por exemplo, quanto menores os dados precisam ser antes de você optar por não usar o Hadoop?