Skip to content

Instantly share code, notes, and snippets.

View GuiMarthe's full-sized avatar

Guilherme Marthe GuiMarthe

View GitHub Profile
FOR /f "tokens=*" %i IN ('docker ps -a -q') DO docker rm %i
@GuiMarthe
GuiMarthe / empirical_boot.R
Last active June 11, 2017 04:02
Um simples script que cria 300 variáveis normais de 100 pares de média e variância distintas e calcula suas médias e intervalos de confiança por meio do bootstrap e ainda calcula a proporção de vezes que a verdadeira média esta no intervalo
library(tidyverse)
### criando 300 váriáveis normais para 20 diferentes
### pares de média e variância distintos
set.seed(42)
df <- tibble(
grupo = purrr::map_chr(1:100, ~paste('grupo_', ., sep = '')),
true_mean = runif(100),
true_variance = runif(100),
@GuiMarthe
GuiMarthe / good_bash_template.sh
Last active June 14, 2017 17:59
This is a template for bash scripting I got from https://dev.to/thiht/shell-scripts-matter
#!/usr/bin/env bash
# This template comes from https://dev.to/thiht/shell-scripts-matter
{
set -euo pipefail
IFS=$'\n\t'
#/ Usage:
#/ Description:
#/ Examples:
@GuiMarthe
GuiMarthe / free_some_memory.sh
Last active August 19, 2021 22:00
This is a small one liner that I saw somewhere for freeing up some memory on linux systems.
free -m
echo 3 | sudo tee /proc/sys/vm/drop_caches
free -m
@GuiMarthe
GuiMarthe / apt_install_history.sh
Created June 14, 2017 19:48
(Beautiful) Commando to list all packages intentionally installed (not as dependencies) by apt commands
# stole from https://askubuntu.com/questions/17823/how-to-list-all-installed-packages
(zcat $(ls -tr /var/log/apt/history.log*.gz); cat /var/log/apt/history.log) 2>/dev/null |
egrep '^(Start-Date:|Commandline:)' |
grep -v aptdaemon |
egrep '^Commandline:'
@GuiMarthe
GuiMarthe / usefUlll_regex.py
Created June 22, 2017 22:23
A couple of decent regular expressions to find URLs and email addresses
#A couple of decent regular expressions to find URLs and email addresses
urlRe = re.compile(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+')
#See http://www.regular-expressions.info/email.html
emailRe = re.compile(r'[a-zA-Z0-9+_\-\.]+@[0-9a-zA-Z][.-0-9a-zA-Z]*\.[a-zA-Z]+')
someString = "Lorem ipsum dolor http://google.com/ consectetuer elit. Aliquam \
scelerisque felis. Nulla lacinia - info@subdomain.mah.se. Suspendisse elementum \
lacus. Suspendisse potenti. Etiam et id lorem congue aliquam. Aenean venenatis, \
elit commodo pretium aliquet, dolor webmaster@yahoo.com, ut iaculis est ante at \
@GuiMarthe
GuiMarthe / pure_purrr_boot.R
Created June 26, 2017 22:09
A small little idea on implementing bootstrap only using purrr, not dplyr based, after reading a google data science blog
## http://www.unofficialgoogledatascience.com/2015/08/an-introduction-to-poisson-bootstrap26.html
n <- 10000000
data <- rnorm(n, mean = 4, sd = 2)
matrix_col_as_vector <- . %>% as.list() %>% purrr::as_vector()
boot_delta_mean <- function(id, data){
mean_data <- mean(data)
indicator <-
@GuiMarthe
GuiMarthe / extract.sh
Created June 28, 2017 16:26
cute extract function I found on reddit
# https://www.reddit.com/r/linux/comments/1u0d8s/dtrx_a_versatile_tool_to_easily_extract_tar_zip/
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 && cd $(echo $1 | sed 's/.tar.bz2//') ;;
*.tar.gz) tar xvzf $1 && cd $(echo $1 | sed 's/.tar.gz//') ;;
*.bz2) bunzip2 $1 && cd $(echo $1 | sed 's/.bz2//') ;;
*.rar) unrar x $1 && cd $(echo $1 | sed 's/.rar//') ;;
*.gz) gunzip $1 && cd $(echo $1 | sed 's/.gz//') ;;
@GuiMarthe
GuiMarthe / log_odds_table.R
Last active October 24, 2017 21:31
quick log odds, odds, probability equivalence
library(dplyr)
tibble(
prob = seq(0, 1, 0.01),
complement = 1 - prob,
odds_ratio = prob/complement,
log_odds_ratio = log(odds_ratio)
) %>%
arrange(-abs(log_odds_ratio)) %>%
@GuiMarthe
GuiMarthe / cifra_cesar_pythonica.py
Created September 19, 2017 21:06
Implementando uma simples cifra de cesar mostrando compreensões de lista e dicionários + alguns métodos de string
import string
letras = string.ascii_lowercase
texto = input('Digite o seu texto: ').lower()
k = int(input('Digite a quantidade de vezes que o seu texto se deslocará: '))
chave = {letra:letras[(i + k) % len(letras)] for i, letra in enumerate(letras + ' ')}