Skip to content

Instantly share code, notes, and snippets.

View maurobaraldi's full-sized avatar

Mauro Navarro Baraldi maurobaraldi

View GitHub Profile
@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
@maurobaraldi
maurobaraldi / bovespa_dados_historicos.py
Created October 2, 2020 18:50
Download de dados historicos da Boevspa de 1986 a 2019
import urllib.request
for year in range(1986,2019):
file = "COTAHIST_A%i.zip" % year
url = 'http://bvmf.bmfbovespa.com.br/InstDados/SerHist/%s' % file
urllib.request.urlretrieve(url, "/home/username/Dowloads/%s" % file )
@maurobaraldi
maurobaraldi / socket_redis_v1.py
Created June 18, 2020 22:03 — forked from fundon/socket_redis_v1.py
Simple use socket connect redis
#!/usr/bin/env python
import socket, time
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', 6379))
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
time.sleep(2)
sock.sendall('PING\r\n')
print repr(sock.recv(4096))
time.sleep(2)
@maurobaraldi
maurobaraldi / README.md
Created June 11, 2020 20:23 — forked from DocX/README.md
Connect to bash inside running ECS container by cluster and service name
@maurobaraldi
maurobaraldi / profiler.py
Last active May 7, 2020 21:59
Profiler for small pieces of code.
import logging
import time
filename="/tmp/profile.log"
class timer():
def __init__(self, context=""):
'''
Profiler for small pieces of code.
@maurobaraldi
maurobaraldi / dolar.py
Created March 2, 2020 18:58
Cotação do Dolar Comercial e Euro via API do UOL economia.
#!/usr/bin/env python3
from datetime import datetime
from json import loads
from urllib.request import urlopen
request = urlopen('https://api.cotacoes.uol.com/currency/intraday/list?currency=1&fields=bidvalue,date').read()
price = loads(request)['docs'][0]
price['date'] = datetime.strptime(price['date'], '%Y%m%d%H%M%S').strftime('%d/%m/%Y às %H:%M:%S')
if __name__ == '__main__':