Skip to content

Instantly share code, notes, and snippets.

View canassa's full-sized avatar
🎯
Focusing

Cesar Canassa canassa

🎯
Focusing
View GitHub Profile
@canassa
canassa / pyproject.toml
Last active November 2, 2021 11:07
A handpicked pylint configuration for Django projects
[tool.pylint.master]
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
# Note: You have to experiment with this number, in noticed that starting too many
# jobs can slow down Pylint
jobs = 4
# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths.
ignore-paths = [".*/migrations", "src/config/settings"]
# Disable the message, report, category or checker with the given id(s).
@canassa
canassa / cnpj.py
Last active October 2, 2020 15:10
Python CNPJ validation
import re
from typing import Union
class InvalidCNPJ(Exception):
pass
def clean_cnpj(value: Union[int, str]) -> str:
"""
@canassa
canassa / instagram_messages.py
Created January 12, 2019 17:14
Converts the Instagram messages.json to text files
import json
from dateutil import parser
data = json.loads(open('messages.json').read())
for c in data:
with open("conversations/" + "-".join(c["participants"]) + ".txt", "w") as f:
for m in c["conversation"]:
created_at = parser.parse(m["created_at"]).strftime("%Y-%m-%d %H:%M")
@canassa
canassa / git.sh
Created April 16, 2018 10:07
Git cheatsheet
# Delete all branches that have been merged
git branch -r --merged | grep -v origin/master | sed 's/origin\///' | xargs git push origin --delete
# Get a list of git branches, ordered by most recent commit
git branch -r --sort=committerdate --format="%(refname:short) %(committerdate:short)"
@canassa
canassa / xmlrpc.py
Created January 17, 2018 13:59
A XMLRPC client that leverages the requests library
import functools
from xmlrpc.client import dumps, loads
from requests import session
class XMLRPC:
def __init__(self, url):
self.session = session(url)
@canassa
canassa / max_part.py
Created April 24, 2017 18:53
maxPart
import sys
import time
from array import array
A = array('d', range(3000))
n = len(A)
max_sum = -sys.maxsize
von = bis = 0
add = 0
@canassa
canassa / reinforced_stone.lua
Last active December 27, 2016 21:07
Automate Reinforced Stone creation using a ComputerCraft Turtle.
local POLLING = 2
local Sand = 'minecraft:sand'
local CFSpray = 'IC2:itemFoamSprayer'
local Scaffold = 'IC2:blockIronScaffold'
local Reinforced = 'IC2:blockAlloy'
local function SelectByName(name)
for i=1,16 do
local detail = turtle.getItemDetail(i)
if detail and detail.name == name then
local display = {
{1, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 1},
### Keybase proof
I hereby claim:
* I am canassa on github.
* I am canassa (https://keybase.io/canassa) on keybase.
* I have a public key whose fingerprint is 45B8 8E66 CE7F FB3D E5A2 531B 003D 4D74 F252 5084
To claim this, I am signing this object:
@canassa
canassa / fix_pytest.py
Last active December 8, 2015 08:59
Converts self.assertEquals to assert
"""
Replaces unittest style asserts (e.g.: self.assertEqual) with py.test style asserts
Usage:
from lib2to3.refactor import RefactoringTool
refactoring_tool = RefactoringTool(['fix_pytest'])
refactoring_tool.refactor(['input.py'], write=True)
"""