This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
values = 'pre', 'post', 'manual' | |
def pre_super(func): | |
func.auto_super = 'pre' | |
return func | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from math import sin, cos, radians | |
linefunc = pygame.draw.line | |
color = 255,255,255 | |
class Turtle: | |
def __init__(self, surf, pos=(0,0)): | |
self.surf = surf | |
self.x = pos[0]; self.y = pos[1] | |
self.drawing = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Custom JSON encoder and Decoder classes to work with general Python classes | |
Pass these as the `cls` argument to json.dump and json.load to enable | |
the serialization of most Python defined "well behaved" objects | |
directly as JSON. | |
Ref.: http://stackoverflow.com/questions/43092113/create-a-class-that-support-json-serialization-for-use-with-celery/43093361#43093361 | |
""" | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections.abc import MutableMapping | |
class DisjointSet(MutableMapping): | |
"""Working disjoint set implementatin in Python - | |
check https://en.wikipedia.org/wiki/Disjoint-set_data_structure | |
""" | |
def __init__(self, initial): | |
self.data = dict() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
W, H = 32, 24 | |
width, height = 800, 600 | |
def init(): | |
screen = pygame.display.set_mode((width, height)) | |
return screen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import cos, sin | |
import pygame | |
tela = pygame.display.set_mode((640, 480)) | |
CX, CY = 320, 240 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
LARG = 640 | |
ALT = 480 | |
# alterar os numeros para mudar a cor: | |
cor_da_nave = (0, 255, 0) | |
fundo = (0, 0, 0) | |
TAM = LARG / 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am jsbueno on github. | |
* I am jsbueno (https://keybase.io/jsbueno) on keybase. | |
* I have a public key ASAHhBRh4WxwCe7SxMl2eq3-6UnWO-bKv0R6U0J-msuDwQo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import pygame | |
WIDTH, HEIGHT = 800, 600 | |
class Ball(pygame.sprite.Sprite): | |
def __init__(self, diameter, color=None): | |
super().__init__() | |
self.diameter = diameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import sys | |
ANSI_SEQ = "\x1b[{}m" | |
FG_RGB = "38;2;{};{};{}" | |
BG_RGB = "48;2;{};{};{}" | |
RESET="0" | |
FRAMED="51" | |
ATTRS = {key:code for key, code in [line.strip().split() for line in """\ |