Skip to content

Instantly share code, notes, and snippets.

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

Thiago Coelho Vieira tcvieira

👨‍💻
typing
View GitHub Profile

Configurando dois dataSources com Spring Boot e Spring Data JPA

Primeiro é necessário preencher as configurações dos DataSources no arquivo de configuração. No nosso caso utilizamos no formato YML (application.yml), para criar dois DataSources, um para o banco de dados chamado "usuarios" e outro para "mensagens":

spring:
  datasource.mensagens:
    username: root
    url: jdbc:mysql://localhost:3306/awmensagens?createDatabaseIfNotExist=true&serverTimezone=UTC
@rponte
rponte / using-uuid-as-pk.md
Last active May 2, 2024 11:01
Não use UUID como PK nas tabelas do seu banco de dados

Pretende usar UUID como PK em vez de Int/BigInt no seu banco de dados? Pense novamente...

TL;TD

Não use UUID como PK nas tabelas do seu banco de dados.

Um pouco mais de detalhes

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".

# Formattinng data
data['state'] = data['state'].str.upper() # Capitalize the whole thing
data['state'] = data['state'].replace( # Changing the format of the string
to_replace=["CA", "C.A", "CALI"],
value=["CALIFORNIA", "CALIFORNIA", "CALIFORNIA"])
# Dates and times are quite common in large datasets
# Converting all strings to datetime objects is good standardisation practice
# Here, the data["time"] strings will look like "2019-01-15", which is exactly
# how we set the "format" variable below
# Filling in NaN values of a particular feature variable
avg_height = 67 # Maybe this is a good number
data["height"] = data["height"].fillna(avg_height)
# Filling in NaN values with a calculated one
avg_height = data["height"].median() # This is probably more accurate
data["height"] = data["height"].fillna(avg_height)
# Dropping rows with missing values
# Here we check which rows of "height" aren't null
# 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
@Eveler
Eveler / wsdl_messages_xop.py.patch
Created October 15, 2018 07:22
URL-encoded attachment id resolve patch
Index: zeep/wsdl/messages/xop.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- zeep/wsdl/messages/xop.py (date 1539132819497)
+++ zeep/wsdl/messages/xop.py (date 1539132819497)
@@ -1,4 +1,5 @@
import base64
+from urllib.parse import unquote
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hbredin
hbredin / Estimating the learning rate bounds for the "1cycle policy".ipynb
Last active May 30, 2018 01:04
Estimating the learning rate bounds for the "1cycle policy"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amberjrivera
amberjrivera / Pipeline-guide.md
Created January 26, 2018 05:02
Quick tutorial on Sklearn's Pipeline constructor for machine learning

If You've Never Used Sklearn's Pipeline Constructor...You're Doing It Wrong

How To Use sklearn Pipelines, FeatureUnions, and GridSearchCV With Your Own Transformers

By Emily Gill and Amber Rivera

What's a Pipeline and Why Use One?

The Pipeline constructor from sklearn allows you to chain transformers and estimators together into a sequence that functions as one cohesive unit. For example, if your model involves feature selection, standardization, and then regression, those three steps, each as it's own class, could be encapsulated together via Pipeline.

Benefits: readability, reusability and easier experimentation.