Skip to content

Instantly share code, notes, and snippets.

View meunomemauricio's full-sized avatar
😶

Mauricio Freitas meunomemauricio

😶
View GitHub Profile
@meunomemauricio
meunomemauricio / fixed_pendulum.py
Last active October 27, 2022 15:30
Simple Pendulum simulation using Pyglet + PyMunk
"""Fixed Pendulum Simulation using PyMunk and Pyglet."""
import pymunk
import pyglet
from pyglet.window import key
from pymunk import Vec2d
from pymunk.pyglet_util import DrawOptions
class Pendulum:
@meunomemauricio
meunomemauricio / pulley.scad
Created March 17, 2022 01:19
Simple Pulley SCAD Design.
/* Simple Pulley. */
$fa = 1;
$fs = .4;
// Disk Dimensions
disk_r = 15;
disk_d = 10;
torus_center_r = disk_r + 4;
torus_tube_r = disk_d/2 + 2;
@meunomemauricio
meunomemauricio / xmlrpc_transfer_client.py
Created November 2, 2016 19:20
How to transfer files through XMLRPC
#! /usr/bin/python
"""Example XMLRPC Client which will receive the file."""
import xmlrpclib
import zlib
class CheckSumError(RuntimeError):
"""CheckSum does not match."""
@meunomemauricio
meunomemauricio / detect_input.md
Created November 2, 2016 19:15
Detects audio level of the selected input device and displays a tray icon with the status.

Detect Audio Input

Detects audio level of the selected input device and displays a tray icon with the status.

Dependencies

PyAudio

@meunomemauricio
meunomemauricio / sodexo_exporter.md
Last active January 25, 2017 14:37
Webscrapes Sodexo website and export it as a CSV file.

Sodexo Exporter

Sodexo is a company that provides Meal Allowance for other companies employees, here in Brazil.

This tool scrapes the Sodexo website and provides the account transaction history in a CSV file.

The captcha is not bypassed. The image is displayed throgh ImageMagick and the user has to type the text.

Dependencies

@meunomemauricio
meunomemauricio / singleton_class.py
Last active November 2, 2016 15:40
Demo on how to define Singleton Classes on Python
#! /usr/bin/python
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
@meunomemauricio
meunomemauricio / in_memory_db.py
Created November 2, 2016 15:34
Demonstration on how to set an In Memory database using SQLite3
#! /usr/bin/python
import sys
import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
# Create table
@meunomemauricio
meunomemauricio / multicast_ip_to_multicast_mac.py
Last active May 10, 2022 19:51
Calculates the Multicast MAC Address from the Multicast IP
#! /usr/bin/python
import re
import sys
import socket
def convert_multicast_ip_to_mac(ip_address):
"""Convert the Multicast IP to it's equivalent Multicast MAC.
Source info: https://technet.microsoft.com/en-us/library/cc957928.aspx
@meunomemauricio
meunomemauricio / mst_digest.py
Last active December 3, 2018 17:36
Function to calculate the MST Digest from the MST instances and VLANs protected.
#! /usr/bin/python
import re
import hmac
import base64
# Key specified by 802.1Q-2011, table 13-1
# Key is encoded in Base64
MAGIC_KEY = 'E6wGpi5H/VH5XSuiQ80DRg=='
@meunomemauricio
meunomemauricio / sro_scraper.py
Last active January 25, 2017 14:23
A small web scraper to track packages from the Correios - SRO (Sistema de Rastreamento de Objetos) Website.
#! /usr/bin/python3
"""Scrape the correios website for package tracking."""
import argparse
import http.client
import logging
import re
import requests
import sys