Skip to content

Instantly share code, notes, and snippets.

View falsetru's full-sized avatar

이정민(Jeong-Min Lee) / SWAT falsetru

View GitHub Profile
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)
@falsetru
falsetru / make-fadeout-image.py
Created March 9, 2011 15:09
generate fadeout image
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
@falsetru
falsetru / conat-images.py
Created March 9, 2011 09:42
concat images
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
@falsetru
falsetru / png-reduce.py
Created March 9, 2011 09:37
make half-size version of images. (a.png -> a.png(/2), a@2x.png(original))
import Image
import os
import shutil
import math
def half(size):
return int(math.ceil(size / 2.0))
class Candidate(str):
SUFFIX = '@2x.png'
@falsetru
falsetru / 3d.py
Created January 17, 2011 15:13
3D without glasses
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')