Skip to content

Instantly share code, notes, and snippets.

View marcelotournier's full-sized avatar
🎨

Marcelo Tournier marcelotournier

🎨
View GitHub Profile
@marcelotournier
marcelotournier / rust_jupyter_kernel.sh
Last active December 30, 2022 18:49
Adds Rust lang support in Jupyter notebooks:
#!/bin/bash
# Adds Rust lang support in Jupyter notebooks:
# Requirements : Jupyter already installed. If you need it, go to "https://www.anaconda.com/products/distribution"
# Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install notebook kernel:
# https://github.com/google/evcxr
@marcelotournier
marcelotournier / pytorch_tpu_gpu_setup.py
Last active October 3, 2022 14:40
Setup PyTorch to use TPU/GPU in Google Colab or Mx Macs. Paste this in the first cell of a Colab notebook & select GPU/TPU in the menu "Runtime > Change Runtime Type"
# MIT License
# Copyright (c) 2022 Marcelo Benedet Tournier
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
@marcelotournier
marcelotournier / requirements.txt
Created July 6, 2022 15:10
Conditional requirements in python
tensorflow-aarch64>=2.8.2; platform_machine == 'aarch64'
tensorflow>=2.8.2; platform_machine != 'aarch64'
@marcelotournier
marcelotournier / read_json_zip.py
Created April 8, 2022 15:52
How to read json zip files
import zipfile
def read_json_zip(path):
"""
Reads all json files inside of a zip file
and appends the result in a list of dictionaries.
"""
json_list = []
@marcelotournier
marcelotournier / jenkins_setup.sh
Last active February 15, 2022 17:50
Setup jenkins with HTTPS in a single script
# Jenkins https simple setup
#
# Shell script to install jenkins in a cloud machine, with https and ssl cert auto-renew
# Tested on ubuntu 20.04
#
# refs:
# - overall setup
# https://computingforgeeks.com/configure-jenkins-behind-nginx-reverse-proxy-and-lets-encrypt-ssl/
# - for changing jenkins conf file:
# https://www.digitalocean.com/community/tutorials/how-to-configure-jenkins-with-ssl-using-an-nginx-reverse-proxy-on-ubuntu-20-04
# Scripts em R para ajudar a abstrair algumas rotinas que rodo sempre.
# Para carregar: Cole em um arquivo `utils.R` e use `source("./utils.R")`
# no seu script.
library(data.table)
library(dplyr)
library(purrr)
# Read multiple files into a single Tibble
read_multiple_files <- function(directory, filetype="csv") {
u"""
tentar.py
autor: Marcelo Tournier
url: https://github.com/marcelotournier
objetivo: Minha abstração de um método "Try"
"""
from sys import exc_info
from datetime import datetime
@marcelotournier
marcelotournier / converter_csv_para_parquet.py
Created March 5, 2021 15:26
Convertendo arquivos csv em parquet
"""
# CSV => PARQUET
Converte um csv para parquet em uma pasta com o mesmo nome.
# DEPENDÊNCIAS:
Instale o pyspark:
pip install pyspark
# USO:
#!/bin/bash
# This script contains commands to install RStudio & Jupyter in ubuntu 18
# Add keys and CRAN repo for ubuntu 18
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/'
sudo apt update
# Install R + system dependencies for tidyverse