Skip to content

Instantly share code, notes, and snippets.

Avatar

Tzeng Yuxio tzengyuxio

View GitHub Profile
View gist:10574475
#!/usr/bin/python
#
# author: tzeng.yuxio@gmail.com
# usage: cat file.input | ./qround-problem-a.py > file.output
import sys
# 計算建完 n 個農場所需時間
def calc_time(c, f, n):
tt = 0.0
View gcj2014-qround-problem-d
#!/usr/bin/python
#
# author: tzeng.yuxio@gmail.com
# usage: cat file.input | ./qround-problem-d.py > file.output
import sys
def solve():
numblocks = (int)(sys.stdin.readline())
s = sys.stdin.readline()[:-1]
View gcj2014-qround-problem-b
#!/usr/bin/python
#
# author: tzeng.yuxio@gmail.com
# usage: cat file.input | ./qround-problem-a.py > file.output
import sys
def solve():
s = sys.stdin.readline()[:-1]
c, f, x = [float(x) for x in s.split()]
View gcj2014-qround-problem-a
#!/usr/bin/python
#
# author: tzeng.yuxio@gmail.com
# usage: cat file.input | ./qround-problem-a.py > file.output
import sys
def get_a_row():
a = (int)(sys.stdin.readline())
b = 5 - a
@tzengyuxio
tzengyuxio / gist:4284108
Created Dec 14, 2012
Fetch IMDb Top 250 into CSV file.
View gist:4284108
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2
import HTMLParser
import csv
import datetime
import codecs, cStringIO # for UnicodeWriter
response = urllib2.urlopen('http://www.imdb.com/chart/top')
@tzengyuxio
tzengyuxio / blogstats.sh
Created Apr 19, 2012
stats of octopress blogpost
View blogstats.sh
#!/bin/bash
# start year and end year
SYEAR=2005
EYEAR=`date "+%Y"`
POSTPATH=~/github/octopress/source/_posts/
echo
echo "YEAR File # Word Count"
@tzengyuxio
tzengyuxio / typo.py
Created Nov 30, 2011
Generate misspelling words...
View typo.py
#!/usr/bin/python
import sys
import random
def misspell(s):
# word and punctation
(w, p) = (s, '') if s[-1] not in [',', '.', ';', ':'] else (s[:-1], s[-1])
if len(w) <= 3:
return s
@tzengyuxio
tzengyuxio / kekkaishi01.py
Created Oct 12, 2011
kekkaishi manga fetcher
View kekkaishi01.py
import urllib
# http://mh.99770.cc/manhua/5264/
# http://mh.99770.cc/manhua/5264/42671.htm?s=3 (Book 1)
sServer="http://61.164.109.141:99/dm03/"
sFiles="/ok-comic00/j/jjs/vol_01/99770_001DD.jpg|/ok-comic00/j/jjs/vol_01/99770_002en.jpg|/ok-comic00/j/jjs/vol_01/99770_003zb.jpg|/ok-comic00/j/jjs/vol_01/99770_004va.jpg|/ok-comic00/j/jjs/vol_01/99770_005yQ.jpg|/ok-comic00/j/jjs/vol_01/99770_006cQ.jpg|/ok-comic00/j/jjs/vol_01/99770_007OI.jpg|/ok-comic00/j/jjs/vol_01/99770_008bY.jpg|/ok-comic00/j/jjs/vol_01/99770_009ue.jpg|/ok-comic00/j/jjs/vol_01/99770_010pv.jpg|/ok-comic00/j/jjs/vol_01/99770_011rC.jpg|/ok-comic00/j/jjs/vol_01/99770_012TU.jpg|/ok-comic00/j/jjs/vol_01/99770_013qr.jpg|/ok-comic00/j/jjs/vol_01/99770_014BY.jpg|/ok-comic00/j/jjs/vol_01/99770_015fI.jpg|/ok-comic00/j/jjs/vol_01/99770_016YE.jpg|/ok-comic00/j/jjs/vol_01/99770_017Le.jpg|/ok-comic00/j/jjs/vol_01/99770_018mb.jpg|/ok-comic00/j/jjs/vol_01/99770_019HC.jpg|/ok-comic00/j/jjs/vol_01/99770_020DB.jpg|/ok-comic00/j/jjs/vol_01/99770_021te.jpg|/ok-comic
@tzengyuxio
tzengyuxio / onimushi.py
Created Oct 12, 2011
fetch manga jpegs
View onimushi.py
import urllib
sFiles="iieye0001-23513.JPG|iieye0002-18220.JPG|iieye0003-10817.JPG|iieye0004-75058.JPG|iieye0005-80467.JPG|iieye0006-26063.JPG|iieye0007-94037.JPG|iieye0008-12816.JPG|iieye0009-14654.JPG|iieye0010-17029.JPG|iieye0011-20600.JPG|iieye0012-96905.JPG|iieye0013-91006.JPG|iieye0014-55435.JPG|iieye0015-10618.JPG|iieye0016-16298.JPG|iieye0017-19149.JPG|iieye0018-16392.JPG|iieye0019-20006.JPG|iieye0020-19246.JPG|iieye0021-79939.JPG|iieye0022-11035.JPG|iieye0023-13656.JPG|iieye0024-20087.JPG|iieye0025-91993.JPG|iieye0026-17052.JPG|iieye0027-14807.JPG|iieye0028-34208.JPG|iieye0029-19081.JPG|iieye0030-80558.JPG|iieye0031-76807.JPG|iieye0032-93202.JPG|iieye0033-14767.JPG|iieye0034-34961.JPG|iieye0035-14144.JPG|iieye0036-53597.JPG|iieye0037-41496.JPG|iieye0038-61202.JPG|iieye0039-95867.JPG|iieye0040-12868.JPG|iieye0041-20183.JPG|iieye0042-45299.JPG|iieye0043-92110.JPG|iieye0044-14851.JPG|iieye0045-41312.JPG|iieye0046-88416.JPG|iieye0047-70173.JPG|iieye0048-18556.JPG|iieye0049-30552.JPG|iieye0050-59343.JPG|i
@tzengyuxio
tzengyuxio / uitapgesturerecognizer.m
Created Jul 26, 2011
單點擊與雙點擊同時成立
View uitapgesturerecognizer.m
- (void)viewDidLoad {
// 單擊的 Recognizer
UITapGestureRecognizer* singleRecognizer;
singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTapFrom)];
singleTapRecognizer.numberOfTapsRequired = 1; // 單擊
[self.view addGestureRecognizer:singleRecognizer];
// 雙擊的 Recognizer
UITapGestureRecognizer* double;
doubleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTapFrom)];