Skip to content

Instantly share code, notes, and snippets.

View tcvieira's full-sized avatar
👨‍💻
typing

Thiago Coelho Vieira tcvieira

👨‍💻
typing
View GitHub Profile
@tcvieira
tcvieira / git.migrate
Created January 3, 2023 02:34 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@tcvieira
tcvieira / reduce_memory_usage.py
Created December 12, 2021 01:12
Here is a handy but long function that casts floats and integers to their smallest subtype based on this table https://docs.scipy.org/doc/numpy-1.13.0/user/basics.types.html
def reduce_memory_usage(df, verbose=True):
numerics = ["int8", "int16", "int32", "int64", "float16", "float32", "float64"]
start_mem = df.memory_usage().sum() / 1024 ** 2
for col in df.columns:
col_type = df[col].dtypes
if col_type in numerics:
c_min = df[col].min()
c_max = df[col].max()
if str(col_type)[:3] == "int":
if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:
@tcvieira
tcvieira / add_datepart.ipynb
Created June 24, 2021 22:13
add_datepart.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tcvieira
tcvieira / hyperjs.md
Created February 25, 2021 05:11 — forked from raftheunis87/hyperjs.md
Hyper.js + Hyper.js Plugins + ZSH + Starship + Fira Code + Dark Theme - (macOS)

Hyper.js

@tcvieira
tcvieira / ludwig.ipynb
Created August 6, 2019 15:01
Ludwig Example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Acesso ao GCP e servidor Jupyter pela rede ISC

Solução para contornar o problema de tunelamento usando ssh para acessar o Jupyter notebook que é bloqueado pelo firewall da rede wifi do ISC, onde ocorrem os encontros presenciais do grupo de estudo em Deep Learning de Brasília.

A ideia é tornar o servidor jupyter executando no Google Cloud Platform (GCP) acessível para rede externa, diretamente por seu IP, sem a necessidade de tunelamento via ssh.

Alterando as configurações da instância na console GCP

https://console.cloud.google.com/networking/addresses/

Logado na console GCP, acessar o endereço acima e reservar um endereço IP estático: "Reserve Static Address".

Instalando ngrok no Google Cloud Shell

Para contornar o problema de tunelamento usando ssh para acessar o Jupyter notebook. A ideia é usar o ngrok para acessar o jupyter sem a necessidade de tunelamento via ssh.

Abrindo o Google Cloud Shell

https://console.cloud.google.com/compute/instances

Inicie a instância e abra o shell:

@tcvieira
tcvieira / display_closestwords_tsnescatterplot.ipynb
Created January 29, 2019 05:23 — forked from aneesha/display_closestwords_tsnescatterplot.ipynb
Use TSNE to only plot similar words using Word2Vec
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Computing correlation coefficients
x_cols = [col for col in data.columns if col not in ['output']]
for col in x_cols:
corr_coeffs = np.corrcoef(data[col].values, data.output.values)
# Get the number of missing values in each column / feature variable
data.isnull().sum()
# Drop a feature variable