Skip to content

Instantly share code, notes, and snippets.

View JoaoFelipe's full-sized avatar

João Felipe N. Pimentel JoaoFelipe

View GitHub Profile
from collections import deque
def chess_to_tuple(chess_position):
"Converts chess position (eg., 'a1') to tuple (eg., (1, 1))"
first = ord(chess_position[0]) - ord('a') + 1
second = int(chess_position[1])
return (first , second)
from itertools import product, tee
template = ('D','D')
max_operations = 4
pairwise = lambda iterable: (lambda x: [next(x[1], None), zip(*x)])(tee(iterable))[-1]
REVERSED_TILES = set(map((lambda x: tuple(reversed(x))), BASIC_TILES))
[
answer
for i in range(1, max_operations + 1)
@JoaoFelipe
JoaoFelipe / bytecode.py
Created May 4, 2018 17:04
Bytecode change
import uncompyle6
import types
def change_bytecode(code, sub=False):
if not isinstance(code, types.CodeType):
return code
if sub:
# 0 LOAD_CONST 1 (0)
# 2 RETURN_VALUE
co_code = b'd\x01S\x00'
@JoaoFelipe
JoaoFelipe / transformer.py
Created May 4, 2018 16:31
AST Transformer
import ast
import astor
class Hitchhiker(ast.NodeTransformer):
def visit_FunctionDef(self, node):
node.body = [ast.parse('return 42')]
return node
expr='''
def resposta():
fo trol motzplnet hi
s="iet"cut=2lns=[]frxi ag(on)
o ,lte neueaes: lnsi%lnlns]apn(etro "
rn("ji(hi.rmieal(ie))rmietosipr i_ogs,can
drio
on
ie [ o nrnecut]fri etri nmrt()
ie[ e(ie).pedlte r")pit".oncanfo_trbelns)
@JoaoFelipe
JoaoFelipe / ComMatricula.ipynb
Last active June 16, 2017 16:53
Gerador de certificados PySE
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We couldn’t find that file to show.
function conta_sim_e_nao() {
    var comments = document.getElementsByClassName("UFICommentBody");
    var outros = [];
    var cont_sim = 0, cont_nao = 0;
    for (var i=0; i < comments.length; i++) {
import sys
import argparse
from getpass import getpass
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def navigate(card_number, user_name, passkey):
try:
browser = webdriver.Firefox()