Skip to content

Instantly share code, notes, and snippets.

@beatrizuezu
beatrizuezu / categorias-model.py
Last active August 6, 2017 17:21
De SQL para ORM Django / categorias/models.py
#categorias/model.py
class Categoria(models.Model):
nome = models.CharField('Nome', max_length=128)
@beatrizuezu
beatrizuezu / produtos-models.py
Last active July 5, 2021 21:20
De SQL para ORM Django / produtos/models.py
#produtos/models.py
class Produto(models.Model):
nome = models.CharField(
'Nome',
max_length=128
)
valor = models.DecimalField(
'Valor',
max_digits=10,
decimal_places=2,
@beatrizuezu
beatrizuezu / desc-categoria.sql
Created August 6, 2017 17:29
De SQL para ORM Django / desc categorias_categoria
mysql> desc categorias_categoria;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| nome | varchar(128) | NO | | NULL | |
+-------+--------------+------+-----+---------+----------------+
@beatrizuezu
beatrizuezu / desc-produto.sql
Created August 6, 2017 17:30
De SQL para ORM Django / desc produtos_produto
mysql> desc produtos_produto;
+--------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| nome | varchar(128) | NO | | NULL | |
| valor | decimal(10,2) | YES | | NULL | |
| categoria_id | int(11) | NO | MUL | NULL | |
+--------------+---------------+------+-----+---------+----------------+
@beatrizuezu
beatrizuezu / settings.py
Created August 7, 2017 02:37
De SQL para ORM Django / settings logger
...
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
@beatrizuezu
beatrizuezu / config virtualevwrapper
Created May 29, 2018 18:36
config virtualevwrapper on bashrc or zshrc
#set where virutal environments will live
export WORKON_HOME=$HOME/.Envs
# ensure all new environments are isolated from the site-packages directory
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
# use the same directory for virtualenvs as virtualenvwrapper
export PIP_VIRTUALENV_BASE=$WORKON_HOME
# makes pip detect an active virtualenv and install to it
export PIP_RESPECT_VIRTUALENV=true
if [[ -r /usr/local/bin/virtualenvwrapper.sh ]]; then
source /usr/local/bin/virtualenvwrapper.sh
# Dist .sh initial
sudo apt-get install curl build-essential openssl libreadline6 libreadline6-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
# get rvm
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
# install last ruby version
@beatrizuezu
beatrizuezu / atom-packages-python.txt
Last active April 5, 2021 01:46
Python Packages for Atom
https://atom.io/packages/file-icons
https://atom.io/packages/minimap
https://atom.io/packages/linter
https://atom.io/packages/busy-signal
https://atom.io/packages/highlight-selected
https://atom.io/packages/sublime-style-column-selection
https://atom.io/packages/terminus
https://atom.io/packages/rainbow-csv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
or these commands for Mac
brew update
brew install pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
@beatrizuezu
beatrizuezu / postgres-cheatsheet.md
Last active January 24, 2019 12:24 — 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)