Skip to content

Instantly share code, notes, and snippets.

View Arthraim's full-sized avatar
💡
Padawan

Arthur Wang Arthraim

💡
Padawan
View GitHub Profile
@Arthraim
Arthraim / black_n_red.py
Created July 29, 2013 08:54
第一次做出广搜好吗!
#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])
@Arthraim
Arthraim / gist:5010034
Created February 22, 2013 01:22
A practice of quartz. Draw something like table -///-
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) {
@Arthraim
Arthraim / letterpress_king.rb
Created December 26, 2012 17:52
King of Letterpress
# 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)
@Arthraim
Arthraim / bottle_example.py
Created May 27, 2011 04:27
a python web framework bottle's example
#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():
@Arthraim
Arthraim / ping_text.php
Created April 21, 2011 09:12
a PHP popen demo
<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);
@Arthraim
Arthraim / getAvatars.py
Created December 17, 2010 02:36
get all avatars from renjian.com
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)
@Arthraim
Arthraim / csv_converter.py
Created September 25, 2010 15:51
transfer TianYu csv file to a nokia csv file
# 天宇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,'
@Arthraim
Arthraim / renjian_widget.js
Created May 15, 2010 06:27
renjian web widget
/*
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;
@Arthraim
Arthraim / HttpRequestDemo.cs
Created February 27, 2010 04:46
dotnet renjian api request example
using System;
using System.IO;
using System.Net;
namespace HttpRequest
{
class Program
{
static void Main(string[] args)
{
@Arthraim
Arthraim / ass2srt.awk
Created February 25, 2010 10:02
subtitle ass 2 srt
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])
}