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 / test_stuff.md
Created October 9, 2018 20:35
migrate unittests to pytest in Flask

Migrate from python.unittest to pytest

Check http://flask.pocoo.org/docs/1.0/testing/

# test_stuff.py

class StuffTestCase(unittest.TestCase):
    def setUp(self):
        self.app = create_app('testing') # app factory
@diegoquintanav
diegoquintanav / rename_files.py
Last active March 25, 2020 09:25
rename files using python
# basic renaming of files, to enforce a minimum consistency
from pathlib import Path
for ix, file in enumerate(sorted(Path.cwd().glob('*'))):
new_filename = f'{ix:02}_' + file.name.lower().replace(' ','_')
print(f'{file.name} > {new_filename}')
file.rename(new_filename)
@diegoquintanav
diegoquintanav / .gitconfig
Last active March 26, 2020 15:04
git config file
[user]
email = daquintanav@gmail.com
name = Diego Quintana
[alias]
a = add
co = checkout
st = status
ci = commit
br = branch
unstage = reset HEAD --
@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')

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 / 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
@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,
@diegoquintanav
diegoquintanav / mssql_pyodbc_sqlalchemy_flask.py
Last active March 25, 2020 09:24
Build connection string of MSSQL Azure Databases
from flask_sqlalchemy import make_url
from urllib.parse import quote_plus
def build_connection_string(**params):
"""
Return the url for MSSQL Azure DB Instances
"""
connection_string = quote_plus(
("DRIVER={driver};"
@diegoquintanav
diegoquintanav / metaclasses.md
Last active March 25, 2020 09:26
metaclasses

Some examples of metaclasses definitions

Raw, implicit definition

class MetaClass(type): 

    def get_foo(self):
        return self._foo
    
@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