This file contains hidden or 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 wx | |
class Gui(wx.Frame): | |
def __init__(self): | |
wx.Frame.__init__(self, None, title="test", size=(800, 400)) | |
self.txt = wx.TextCtrl( self, -1, "Hello", style=wx.TE_MULTILINE ) | |
self.txt.Bind( wx.EVT_KEY_DOWN, self.onKeyDown ) | |
self.txt.Bind( wx.EVT_KEY_UP, self.onKeyUp ) | |
self.keylist = [] | |
self.timer = wx.Timer(self) |
This file contains hidden or 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 os | |
from collections.abc import Iterator | |
from reportlab.pdfgen import canvas | |
from reportlab.lib.pagesizes import LETTER, landscape | |
from reportlab.lib.units import inch | |
from reportlab.pdfbase import pdfmetrics | |
from reportlab.pdfbase.ttfonts import TTFont | |
# Usage: | |
# label = AveryLabels.AveryLabel(5160) |
This file contains hidden or 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 math | |
def polar_add( v1, v2 ): | |
dtheta = v2[1]-v1[1] | |
r = math.sqrt( v1[0]**2 + v2[0]**2 + 2*v1[0]*v2[0]* math.cos(dtheta) ) | |
theta = v1[1] + math.atan2( | |
v2[1] * math.sin(dtheta), | |
v1[1] + v2[1]*math.cos(dtheta) | |
) | |
return (r, theta ) |
This file contains hidden or 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 re | |
data = [ | |
'atr.i', | |
'atr i', | |
'ok', | |
'test', | |
'ro bn.', | |
'ro bn', | |
'talk 1', |
This file contains hidden or 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
// I seriously doubt this is your actual data structure. | |
const data = [ | |
[name = 'john doe', name2 = 'hello'], | |
[age = 23], | |
[hobby = [{ | |
name: 'mancing' | |
}]] | |
]; | |
data.map((item, key) => console.log(item, key)) |
This file contains hidden or 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 PIL import ImageDraw, Image, ImageFont | |
BLACK = (0,0,0) | |
WHITE = (255,255,255) | |
LTBLUE = (192,192,255) | |
fig = Image.new( "RGB", (320,320), WHITE ) | |
arial = ImageFont.truetype("../.fonts/arial.ttf", 32 ) | |
y = 100 |
This file contains hidden or 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
# OK, I ran the following Python to create the database: | |
import sqlite3 | |
import random | |
import os | |
os.remove( 'test.db' ) | |
db = sqlite3.connect( "test.db" ) | |
cursor = db.cursor() | |
cursor.execute( """\ |
This file contains hidden or 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 struct | |
# Return a RIFF file | |
class LIST: | |
def __init__(self, name, f): | |
# contains a type and a list of subchunks. | |
self.offset = f.tell() - 4 | |
self.name = name.decode() | |
size = struct.unpack('I', f.read(4))[0] |
This file contains hidden or 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
""" | |
This does what you are trying to do, but with all the extraneous code eliminated. | |
Notice that strings are iterables, just like lists. Any time you are making a list | |
of single characters, you should probably use a string. Also notice that we write | |
`'xxx'.upper()`, not `str.upper('xxx')`. Also note that it is silly to write ` | |
if result='N': pass`. Just test for what you want to know. | |
""" | |
import random | |
lower_case_letters = 'abcdefghijklmnopqrstuvwxyz' |
This file contains hidden or 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 physics(data): | |
block = [[int(i) for i in row.split(',')] for row in data.split(';')] | |
width = len(block[0]) | |
height = len(block) | |
water = block[0].index(1) | |
for row in range(1,height): | |
for possible in (-1,0,1): | |
if water+possible in range(width) and block[row][water+possible]: | |
water += possible |
OlderNewer