Skip to content

Instantly share code, notes, and snippets.

View Martins6's full-sized avatar
🚀
per aspera ad astra!

Adriel Martins Martins6

🚀
per aspera ad astra!
View GitHub Profile
@Martins6
Martins6 / vscode_settings.json
Created April 12, 2024 15:20
VsCode settings using Ruff and using colour lines for max-length.
{
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.fixAll": "explicit",
"notebook.source.organizeImports": "explicit"
},
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
@Martins6
Martins6 / fire.zsh-theme
Last active April 3, 2024 21:35
Modification of "cloud" theme for oh-my-zsh
if [[ -z $ZSH_THEME_CLOUD_PREFIX ]]; then
ZSH_THEME_CLOUD_PREFIX='🔥' #⚡'
fi
PROMPT='%{$fg_bold[cyan]%}$ZSH_THEME_CLOUD_PREFIX%{$fg_bold[green]%} %{$fg[green]%}%c %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}] %{$fg[yellow]%}'%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}]"
@Martins6
Martins6 / nvidia_pytorch_ubuntu.dockerfile
Created July 13, 2023 20:30
Dockerfile for building Ubuntu containers with NVIDIA drivers with Pytorch, transformes and other packages from the HuggingFace ecosystem installed (bitsandbytes included)
FROM nvidia/cuda:12.1.1-devel-ubuntu20.04
ARG DEBIAN_FRONTEND=noninteractive
# install git, python3.10 and pip
RUN apt-get update && apt-get install -y \
git \
curl \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt install -y python3.10 \
&& rm -rf /var/lib/apt/lists/* \
@Martins6
Martins6 / zsh_plugins.txt
Created May 13, 2023 19:40
Oh-my-zsh plugins
plugins=(
git
zsh-autosuggestions
alias-finder
dotenv
poetry
python
macos
gitignore
web-search
@Martins6
Martins6 / M2_Mac_Docker_RStudio.sh
Last active September 2, 2023 14:01
Shell script to run RStudio on Docker on a M2 Mac.
# Three main sources for this script:
# https://github.com/rocker-org/rocker-versioned2/issues/144
# https://jsta.github.io/r-docker-tutorial/02-Launching-Docker.html
# https://stackoverflow.com/questions/65456814/docker-apple-silicon-m1-preview-mysql-no-matching-manifest-for-linux-arm64-v8
# After running the script, access the RStudio on the address http://localhost:8787/
docker run --rm \
--platform linux/x86_64 \
-p 8787:8787 \
@Martins6
Martins6 / multinomial_goodness_of_fit.py
Created November 18, 2022 13:09
Calculate the multinomial goodness of fit through Log Likelihood Ratio test statistic with the null distribution calculated via Monte Carlo simulation.
def multinomial_goodness_of_fit(
f_obs,
p_exp=None,
b=1000,
delta=0
) -> list:
"""
Calculate the multinomial goodness of fit through Log Likelihood Ratio test statistic with the
null distribution calculated via Monte Carlo simulation.
@Martins6
Martins6 / regex_cleaning_email_and_telephone_prestodb.sql
Last active June 21, 2021 17:02
Cleaning or validating emails and telephones numbers with RegEx with SQL in Presto DB. (Portuguese Version)
SELECT *,
CASE
WHEN e.email like '%_@_%_.__%'
AND NOT regexp_like(coalesce(trim(regexp_extract(e.email, '.+?(?=@)')), '$'),
'[^a-zA-Z0-9\._-\ã\õ\ẽ\é\ó\ú]')
THEN lower(e.email)
ELSE 'N/A'
END
) AS email,
CASE
@Martins6
Martins6 / .update_upgrade.sh
Created May 13, 2021 20:33
To update, upgrade and log all the packages for your Debian-based distribution.
#!/bin/bash
file_path=/home/adriel_martins/.update_upgrade.log
echo "** TURN ** : $(date +%d-%m-%Y)" >> $file_path
apt update >> $file_path
apt upgrade -y >> $file_path
@Martins6
Martins6 / settings.json
Created April 19, 2021 15:35
VSCode settings created by @marpontes.
{
"python.pythonPath": "path/to/python",
"python.formatting.provider": "autopep8",
"python.formatting.blackPath": "venv/bin/black",
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.formatting.autopep8Args": [
"--max-line-length",
"80",
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import wavfile
samplerate, data = wavfile.read('Data/microphone-results.wav')
n = np.arange(len(data))
N = len(n)
fhat = np.fft.fft(data, N)
PSD = fhat * np.conj(fhat) / N