Skip to content

Instantly share code, notes, and snippets.

View diegoquintanav's full-sized avatar
🐢
Working from home

Diego Quintana diegoquintanav

🐢
Working from home
View GitHub Profile
@diegoquintanav
diegoquintanav / flask-context-shell.md
Created January 25, 2018 16:00
get Flask context
>>> from hello import app
>>> from flask import current_app
>>> app_ctx = app.app_context()
>>> app_ctx.push()
>>> current_app.name
>>> app_ctx.pop()
@diegoquintanav
diegoquintanav / sqla_cheatsheet.md
Last active March 16, 2018 20:31
SQLAlchemy gotchas (and headaches) I've dealt with

Define local model class from remote table

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/database1.db'
app.config['SQLALCHEMY_BINDS'] = {'remote': 'sqlite:////tmp/database1.db'}

@diegoquintanav
diegoquintanav / docker-gists.md
Last active March 31, 2018 19:42
Docker gists

List the container port address

$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

where container_name_or_id can be a map of other docker methods, such as

$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -q)
@diegoquintanav
diegoquintanav / unixpermissions.md
Last active March 31, 2018 19:50
About UNIX permissions

The command $ ls -l, for example, can return a list of the type

total 24
drwxrwxr-x 2 diego diego 4096 feb  2 11:16 logs
drwxrwxr-x 2 diego diego 4096 feb  5 13:42 __pycache__
-rw-rw-r-- 1 diego diego  185 feb  5 13:40 app.py
drwxrwxr-x 2 diego diego 4096 feb  5 13:34 templates
drwxrwxr-x 6 diego diego 4096 feb  2 10:55 venv
-rw-rw-r-- 1 diego diego   64 feb  5 13:41 wsgi.py
@diegoquintanav
diegoquintanav / ccze_timestamp.md
Created April 5, 2018 20:31
Add time stamps and colors to logs

Appending a timestamp

$ tail -n 10 -f outputfile | xargs -IL date +"%Y%m%d_%H%M%S:L"

Using ccze

$ (tail -n 10 -f outputfile | xargs -IL date +"%Y%m%d_%H%M%S:L") | ccze
@diegoquintanav
diegoquintanav / .vimrc
Created April 7, 2018 17:39
miscellaneous configuration files
set nocompatible " required
filetype off " required
"allow for external clipboard buffers
set clipboard=unnamed
" set numbers on
set nu
@diegoquintanav
diegoquintanav / comparacion_resultados.md
Created June 2, 2018 18:40
comparacion resultados json

ejemplo de arica para allData_ddl_legend.json

 {
    "agno": 2016,
     "cod_com_alu": 15102,
     "cod_com_rbd": 15101,
     "cod_reg": 15,
     "flow": 64,
     "lat_com_alu": -19.155567,
     "lat_com_rbd": -18.47895865,

Docker aliases

# Show the ip address of the container
alias dip="docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'"

# Show the ID of the last container used
alias dlq="docker ps -lq"
@diegoquintanav
diegoquintanav / .vimrc
Last active June 29, 2018 20:04
vimrc file
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
" check https://github.com/VundleVim/Vundle.vim for details
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@diegoquintanav
diegoquintanav / after-install.md
Last active July 4, 2018 01:50
fresh install
  1. Fresh install bionic beaver
    1. Update dependencies
    2. sudo apt-get install -y git curl tmux weechat net-tools
  2. Install pyenv
    1. Install build dependencies as stated in https://github.com/pyenv/pyenv/wiki sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev
    2. Install pyenv
    3. env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.0 or whatever version you like. --enable-shared is needed for other packages to work properly, like vundle.
  3. install docker-ce
  4. Follow post installation tasks for Ubuntu