Skip to content

Instantly share code, notes, and snippets.

View maurobaraldi's full-sized avatar

Mauro Navarro Baraldi maurobaraldi

View GitHub Profile
@maurobaraldi
maurobaraldi / advent_of_code_2022.py
Last active December 5, 2022 22:03
Advent of Code 2022
#!/usr/bin/env python
# Solutions for Advent of Code 2022
# Problem 1.1
with open('./input.txt') as f:
elves_kal = [list(map(int, i.split())) for i in f.read().split('\n\n')]
print(max(sum(k) for k in elves_kal))
# Problem 1.2
@maurobaraldi
maurobaraldi / systemd.py
Last active July 8, 2022 01:10
Self healing systemd services if it is in failed status.
#!/usr/bin/env python3
from subprocess import (
Popen,
PIPE
)
class Service(object):
def __init__(self, service_name):
@maurobaraldi
maurobaraldi / install-docker.sh
Created June 22, 2022 06:36 — forked from roberson-miguel/install-docker.sh
Script para instalar Docker e Dependências, que já teste com imagem do Hello World.
#!/usr/bin/env bash
#Salve esse conteudo em um arquivo com o nome "install-docker.sh" ou outro de sua preferencia, e execute em um terminal
#usando "sh install-docker.sh"
executa_imagem=$()
echo "Removendo versões antigas do Docker...\n"
sudo apt-get remove -y docker docker-engine docker.io containerd runc > /dev/null
@maurobaraldi
maurobaraldi / xrp_history_mercado_bitcoin.csv
Last active October 21, 2021 18:06
Histórico diário do XRP a partir do Mercado Bitcoin, desde 10/10/2018 (quando o XRP começou lá).
date opening closing lowest highest volume quantity amount avg_price
2018-10-10 1.5 1.65796 1.5 3.99 801301.09566204 433794.72838648 2552 1.84718956
2018-10-11 1.65794 1.55901 1.46 1.7474 983668.51610792 613071.13758692 2116 1.60449327
2018-10-12 1.55 1.62999 1.523 1.7 223158.52971305 136410.13539226 736 1.63593804
2018-10-13 1.63 1.61995 1.6 1.7 158644.91389793 96865.23944556 527 1.63778993
2018-10-14 1.61989 1.56 1.55 1.68 199750.14166781 123145.50911021 623 1.62206598
2018-10-15 1.598 1.686 1.51 1.75 503712.90168951 303882.55315445 1473 1.65759072
2018-10-16 1.66005 1.8299 1.64795 1.99998 564935.82582822 322736.91790896 1639 1.75045306
2018-10-17 1.78105 1.77901 1.73 1.875 301418.01795127 169484.65835049 1274 1.77843836
2018-10-18 1.779 1.73999 1.6999 1.805 257539.85030187 148232.1956103 947 1.73740832
@maurobaraldi
maurobaraldi / naturais.py
Created August 3, 2021 01:50
Exercícios com números naturais
from random import randint, choice
def plus_minus_expressions(quantity: int = 30) -> None:
for i in range(quantity):
n = lambda: choice([1,-1])*randint(0, 10)
oper = choice(['-', '+'])
print(f'{n()} {oper} {n()} {oper} {n()} = ')
def division_times_expressions(quantity: int = 30) -> None:
for i in range(quantity):
@maurobaraldi
maurobaraldi / web-servers.md
Created May 13, 2021 18:57 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@maurobaraldi
maurobaraldi / harden.sh
Created April 6, 2021 13:53 — forked from jumanjiman/harden.sh
hardening script for an alpine docker container
#!/bin/sh
# Copyright 2020 Paul Morgan
# License: GPLv2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
set -x
set -e
#
# Docker build calls this script to harden the image during build.
#
# NOTE: To build on CircleCI, you must take care to keep the `find`
# command out of the /proc filesystem to avoid errors like:
@maurobaraldi
maurobaraldi / StockCandleMatrixBS4.py
Created February 3, 2021 12:37
Yahoo Finance Stock Price Scraper - Mosaic of 40 Brazilian stocks
# -*- coding: utf-8 -*-
from mpl_finance import candlestick_ohlc
import numpy as np
from matplotlib import pyplot
import pandas as pd
from bs4 import BeautifulSoup
import urllib.request
import re
@maurobaraldi
maurobaraldi / acceptgzipped.py
Created November 4, 2020 01:46 — forked from Manouchehri/acceptgzipped.py
Allowing gzip encoding with urllib
__author__ = 'David Manouchehri'
from bs4 import BeautifulSoup
import urllib.request
import gzip
import io
url = 'http://yoururlgoesherehopefullythisisntavalidurl.com/pages.html'
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
AF 0132 AFEGANISTÃO
AL 0175 ALBÂNIA, REPÚBLICA DA
DE 0230 ALEMANHA
BF 0310 BURKINA FASO
AD 0370 ANDORRA
AO 0400 ANGOLA
AI 0418 ANGUILLA
AG 0434 ANTIGUA E BARBUDA
0477 ANTILHAS HOLANDESAS
SA 0531 ARÁBIA SAUDITA