Skip to content

Instantly share code, notes, and snippets.

View beatorizu's full-sized avatar
🤓
Focusing

beatorizu

🤓
Focusing
  • São José dos Campos, SP Brazil
  • 21:21 (UTC -03:00)
View GitHub Profile
@beatorizu
beatorizu / init.vim
Last active September 23, 2020 22:02
neovim config file
" Specify a directory for plugins
call plug#begin('~/.local/share/nvim/plugged')
" Colorizer A plugin to color colornames and codes
Plug 'chrisbra/Colorizer'
" vim-markdown-composer An asynchronous markdown preview plugin for Vim and Neovim
function! BuildComposer(info)
if a:info.status != 'unchanged' || a:info.force
if has('nvim')
@beatorizu
beatorizu / nan_if.py
Created August 31, 2018 18:43
Filtro para substituir o missing_value por nan
def nan_if(data, missing_value):
return np.where(data == missing_value, np.nan, data)
@beatorizu
beatorizu / .coveragerc
Created August 28, 2018 19:10
Configuração do Coverage
[run]
branch = True
[report]
exclude_lines=
if response.status_code == 404:
elif response.status_code == 503:
pragma: no cover
class ServiceUnavailable(Exception):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import facebook
class SimpleFacebook(object):
def __init__(self, oauth_token):
self.graph = facebook.GraphAPI(oauth_token)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from controller import simple_facebook
from unittest import mock, TestCase
class SimpleFacebookTestCase(TestCase):
@beatorizu
beatorizu / apply_format_df_columns.py
Created May 9, 2018 18:05
Aplicando formatos diferentes para cada coluna no DataFrame
# Aplicando formatos diferentes para cada coluna no DataFrame
df = DataFrame({'a':[7.7885], 'b': [1.989878968657576e-10]})
# out
# a b
# 0 7.7885 1.989879e-10
df.loc[:, 'b'] = df.loc[:, 'b'].map(lambda x: float('%.11f' % x))
df.loc[:, 'a'] = df.loc[:, 'a'].map(lambda x: float('%.2f' % x))
# out
@beatorizu
beatorizu / operacoes-eixo-intervalo.py
Last active June 10, 2018 21:27
Aplicar função de acordo com o eixo e cortes por intervalo
import numpy as np
data = np.random.rand(7, 3, 2)
op_dict = {'sum': np.sum, 'mean': np.mean, 'max': np.max, 'min': np.min}
def apply_function(func, data, step, axis=0, slice_=slice(None)):
sections = np.arange(step, data.shape[axis], step)
return np.array([func(d[slice_], axis=axis) for d in np.split(data, sections, axis=axis)])
# Para somar no eixo 1 de três em três
txprec[::3].sum(axis=1)
@beatorizu
beatorizu / find_git.py
Last active June 2, 2019 16:39
Python scripts with regex powers to find files XD
#!/opt/anaconda2/envs/py360/bin/python
from datetime import datetime
from json import dump
from os import walk
from os.path import join
import logging
import re
def search_dir(root, target='.git', pattern=re.compile(r'^\.git|[\w\d\s!@#$%^&*()_+\-=\[\]{};\':"\\|,<>\/?]+$'),
def find_nearest_point(latitude, longitude, l_latitude, l_longitude):
"""
This function find the index of the nearest value to the latitude and longitude values int the l_latitude and
l_longitude lists.
Parameters
----------
latitude: float
longitude: float
l_latitude: list