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/kivy | |
import kivy | |
#kivy.require('1.0.6') | |
from kivy.app import App | |
from kivy.uix.floatlayout import FloatLayout | |
from kivy.uix.label import Label | |
from kivy.graphics import Color, Rectangle, Point, GraphicException | |
from kivy.clock import Clock | |
from kivy.logger import Logger |
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 | |
def put(x): | |
sys.stdout.write(x) | |
sys.stdout.flush() | |
from time import sleep | |
while 1: | |
put('\r O_-') | |
sleep(0.1) | |
put('\r -_O') |
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 Image | |
import os | |
import shutil | |
import math | |
def half(size): | |
return int(math.ceil(size / 2.0)) | |
class Candidate(str): | |
SUFFIX = '@2x.png' |
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 Image | |
import sys | |
def concat(images, wfn, hfn, xm, ym): | |
width = wfn(im.size[0] for im in images) | |
height = hfn(im.size[1] for im in images) | |
result = Image.new(images[0].mode, (width, height)) | |
x = y = 0 | |
for im in images: | |
print im.size |
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 os, sys, Image | |
# Usage $0 image width-for-new-file | |
filename = sys.argv[1] #'tv_main_bar_bg.png' | |
filename2 = '_fadeout'.join(os.path.splitext(filename)) | |
width = int(sys.argv[2]) | |
maxx = width - 1 | |
im = Image.open(filename) | |
assert im.size[0] == 1 |
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 csv | |
import re | |
import datetime | |
import itertools | |
def iter_prices(filename): | |
PATTERN_DIGIT = re.compile(r'\d+') | |
with open(filename) as f: # HTS-exported data | |
reader = csv.reader(f) | |
next(reader) |
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 | |
def simul1(): | |
rooms = [0, 0, 1] | |
random.shuffle(rooms) | |
i = random.randrange(3) # initial | |
while True: | |
j = random.randrange(3) # goat | |
if j != i and rooms[j] == 0: |
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 win32api | |
import win32con | |
from time import sleep | |
import Image | |
import pywinauto | |
app = pywinauto.Application.start('mspaint') | |
win = app.top_window_() | |
win.MoveWindow(0,0) |
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 Tkinter import * | |
class LineFactory: | |
def __init__(self): | |
self.line = None | |
def text(self, p): | |
canvas.create_text(p.x, p.y-10, | |
text='{0.x}, {0.y}'.format(p)) | |
def arrow(self, e): | |
return canvas.create_line(self.start.x, self.start.y, |
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
#include <assert.h> | |
int frame_score(int *rolls) | |
{ | |
int total = 0; | |
for (int frames = 10; frames--; rolls += 1 + (*rolls < 10)) { | |
int score = rolls[0] + rolls[1]; | |
if (score >= 10) | |
score += rolls[2]; |
OlderNewer