Skip to content

Instantly share code, notes, and snippets.

View luizhenriquefbb's full-sized avatar

Luiz Henrique Freire Barros luizhenriquefbb

View GitHub Profile
@luizhenriquefbb
luizhenriquefbb / simple_python_cors.py
Last active March 3, 2020 21:49
Simple python working with cors
#!/usr/bin/env python3
# encoding: utf-8
"""Use instead of `python3 -m http.server` when you need CORS"""
from http.server import HTTPServer, SimpleHTTPRequestHandler
import sys
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
#!/usr/bin/python
# -*- coding: utf-8 -*-
import logging
import os
from logging.handlers import RotatingFileHandler
class LogManager:
def __init__(self, log_name,
@luizhenriquefbb
luizhenriquefbb / Readme.md
Last active March 16, 2020 18:40
[python] show a folder content in a JSON format

Linux / Mac Folder to JSON

Prints a folder in a JSON format

python main.py <path> > <output_file.json>
@luizhenriquefbb
luizhenriquefbb / argParser.py
Created March 7, 2019 11:54
exemplo de arg parse em python
import argparse
if __name__ == '__main__':
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=False,
help="Path to the image to be scanned")
args = vars(ap.parse_args())
if args["image"] == None:
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
import sys
# Print iterations progress
def printProgressBar(iteration, total, prefix='Progress', suffix='complete', decimals=1, length=30, fill='█'):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)