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
#!/usr/bin/env python | |
import sys | |
import os | |
import re | |
def gather(path): | |
result = [] | |
def f(arg, dirname, names): | |
for name in names: |
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
#!/usr/bin/env python | |
import sys | |
import time | |
if __name__ == '__main__': | |
N = 100 | |
for i in range(N): | |
time.sleep(1) | |
# http://en.wikipedia.org/wiki/ANSI_escape_code |
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
# c.f. http://en.wikipedia.org/wiki/Marzullo%27s_algorithm | |
def marzullo_algorithm(ranges): | |
table = [] | |
for l,r in ranges: | |
table.append((l,-1)) | |
table.append((r,+1)) | |
def my_cmp(x, y): | |
result = cmp(x[0], y[0]) | |
if result == 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
import Image | |
def bandswap(pr,pg,pb): | |
im = Image.open('Lenna.png') | |
b = im.split() | |
im = Image.merge('RGB', (b[pr], b[pg], b[pb])) | |
im.save('Lenna_%d%d%d.png'%(pr,pg,pb)); | |
if __name__ == '__main__': | |
bandswap(0,1,2) |
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
#!/usr/bin/env python | |
import sys | |
import os | |
import Image | |
def resize(src_dir, dest_dir, num, den): | |
if not os.path.exists(dest_dir): | |
os.makedirs(dest_dir) | |
files = os.listdir(src_dir) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
void * | |
thread_func(void *p) | |
{ | |
for(;;); | |
return NULL; | |
} |
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 Image | |
import math | |
def hsv_to_rgb(h, s, v): | |
if s * v == 0: | |
r, g, b = v, v, v | |
else: | |
hi = int(math.floor(3 * h / math.pi)) % 6 | |
f = 3 * h / math.pi - hi; | |
p = v * (1.0 - s) |
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 sys | |
import os | |
import math | |
import Image | |
def make_filter_kernel(size, sigma_sq): | |
s = 0.0 | |
half = size / 2 | |
f_min = -(size / 2) | |
f_ub = size / 2 + 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
import sys | |
import os | |
import math | |
import Image | |
def make_filter_kernel(size, sigma_sq): | |
s = 0.0 | |
half = size / 2 | |
f_min = -(size / 2) | |
f_ub = size / 2 + 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
import sys | |
import os | |
import math | |
import Image | |
def create_shadow_image(image_size, shadow_size): | |
mergin = (shadow_size, shadow_size) | |
new_size = map(sum, zip(image_size, mergin, mergin)) | |
im = Image.new('RGBA', new_size, 0xFFFFFFFF) | |
buf = im.load() |