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
# coding: utf-8 | |
import pygame | |
import random | |
rr = random.randrange | |
SIZE = 800, 600 | |
cellsize = 20 | |
try: |
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
#!/usr/bin/env python | |
from __future__ import print_function | |
version = __version__ = '1.1' | |
# Author- Ross Tucker | |
# Thanks to Marc Majcher for his project, Piet.pl | |
from PIL import Image # Python Imaging Library | |
from operator import itemgetter |
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
"fixed up" Python Piet interpreter - | |
Piet is an esoteric programing language, which defines a programatic behavior to raster images and a fixed set of colors. | |
It is mostly defined and demonstrated at http://www.dangermouse.net/esoteric/piet | |
On that site, on the "resources" page there is a link to a piet interpreter written in Python - | |
this is that code, with some fixes to Python in 2016, and able to take an image file name as | |
a parameter from the command line (which the original interpreter didn't do). | |
There is no attempt to optmize or restile the code besides fixes to run it in Python2.7 and Python 3.4. |
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 sys, random, time | |
def h(): | |
positions = "\\o| \\o/ |o/ /o/ |o| \\o\\".split() | |
x=10 | |
for i in range(50): | |
print (" " * x + positions[i % len(positions)] + " ", end="") | |
sys.stdout.flush() | |
time.sleep(0.2) | |
print("\b" * 80, end="") |
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
#! /usr/bin/env python3 | |
from urllib.request import urlopen | |
import re | |
import unicodedata | |
def fetch(): | |
data = urlopen("https://www.w3.org/TR/MathML2/double-struck.html").read() | |
dcontent = re.findall(r"<td.*?>\s*?(.*?)</td", data.decode("utf-8")) |
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
%! PS | |
(Sans Bold) findfont 40 scalefont setfont 350 350 translate /i 0 def /step 360 12 div neg def 12 {step rotate 0 200 moveto i 1 add ( ) cvs dup stringwidth pop 2 div neg 0 rmoveto show /i i 1 add def } repeat 0 0 moveto 5 setlinewidth 0 150 rlineto stroke 0 0 moveto 10 setlinewidth 255 0 0 setrgbcolor 100 0 rlineto stroke showpage |
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 turtle import Turtle | |
""" | |
Python Turtle with logging and replay capabilities | |
Author: João S. O. Bueno <gwidion@gmail.com> | |
License: LGPL 3.0+ | |
This implements HistoryTurtle - a subclass of | |
Python's turtle.Turtle wich features a simple |
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
# coding: utf-8 | |
import pygame | |
import random | |
# jsobueno@gmail.com | |
TAMANHO = (640, 480) | |
T = 640 / 32 | |
TX = 640 / T | |
TY = 480 / T |
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
class Immutable: | |
__slots__ = () | |
def __hash__(self): | |
return hash(tuple(getattr(self, v) for v in self.__slots__)) | |
def __setattr__(self, attr, value): | |
raise TypeError('Attributes here are imutable') | |
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
def pre_super(func): | |
values = {} | |
try: | |
class Mutant: | |
def wrapper(*args, **kw): | |
getattr(__class__, func.__name__)(*args, **kw) | |
return func(*args, **kw) | |
values["w"] = wrapper | |
raise ValueError # Abort the filling up of wrapper's __class__ cell | |
except ValueError: |