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
| #coding: utf-8 | |
| # http://acm.hdu.edu.cn/showproblem.php?pid=1312 | |
| while True: | |
| queue = [] | |
| #input W and H | |
| WnH = raw_input() | |
| width = int(WnH.split(' ')[0]) | |
| height = int(WnH.split(' ')[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
| CGContextRef context = UIGraphicsGetCurrentContext(); | |
| CGContextSetRGBStrokeColor (context, 0, 0, 0, 1); | |
| CGContextSetLineWidth(context, 1); | |
| CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0)); | |
| int hours = 0; | |
| float gap = self.height / 24; | |
| for (float y = gap; y < self.height + gap / 2; y += gap) { | |
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
| # find words in letters | |
| words = ["abc", "def"] # you need a biiiiiiiiiiig word list here | |
| letters = "pfwbsubarciesgqwjfornotyl" | |
| results = [] | |
| words.each do |w| | |
| dict = letters.split // | |
| flag = true | |
| (w.split //).each do |l| | |
| #p dict | |
| if (dict.include? l) |
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
| #coding: utf-8 | |
| from bottle import route, error, post, get, run, static_file, abort, redirect, response, request, template | |
| @route('/') | |
| @route('/index.html') | |
| def index(): | |
| return '<a href="/hello">Go to Hello World page</a>' | |
| @route('/hello') | |
| def hello(): |
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
| <html> | |
| <head> | |
| <title>ping</title> | |
| </head> | |
| <body> | |
| <?php | |
| echo "<h1>ping</h1>"; | |
| $file_handle = popen("ping artori.us", "r"); | |
| while (!feof($file_handle)) { | |
| $line = fgets($file_handle); |
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 urllib | |
| import simplejson | |
| i = 0 | |
| breaki = 0 | |
| while i >= 0: | |
| i = i + 1 | |
| print '' | |
| rnjn_url = 'http://api.renjian.com/' | |
| user_url = rnjn_url + 'users/show.json?id=' + unicode(i) |
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
| # 天宇csv -> nokia csv | |
| # Arthur Wang | |
| # REGEX: "(\w+|[^@#:\s,,,.。;;:;]+)" * | |
| import re | |
| p = re.compile('"(\\w+|[^@#:\\s,,,.。;;:;]+)" *') | |
| p.sub(r"\1,", '"abc" "12312312"', 0); | |
| # OUTPUT: 'abc,12312312,' |
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
| /* | |
| Author: Arthur Wang | |
| Version: 0.5 | |
| Update: 2010/5/15 | |
| Author URI: http://arthraim.cn/ | |
| */ | |
| function renjianCallback(statuss) { | |
| var sData = [], sHtml = "", j = 1; | |
| for (var i=0; i < statuss.length; i++){ | |
| if (statuss[i].in_reply_to_user_id != null) continue; |
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
| using System; | |
| using System.IO; | |
| using System.Net; | |
| namespace HttpRequest | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { |
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
| function remove_space(A,i) | |
| { | |
| # strip spaces on each side of A[i] | |
| sub("^[ \t]*","",A[i]) | |
| sub("[ \t]*$","",A[i]) | |
| # remove '^M' '\n' character | |
| gsub("[ | |
| \n]","",A[i]) | |
| } |
NewerOlder