Skip to content

Instantly share code, notes, and snippets.

@upsuper
upsuper / Makefile
Created March 21, 2012 10:54
中文C编程
CFLAGS=-fextended-identifiers -std=c99
objects=chinese.ucn.o
target=chinese
.PHONY: all clean
all: $(target)
$(target): $(objects)
$(CC) $< -o $@
@upsuper
upsuper / status.py
Created March 10, 2012 11:34
a python script to monitor account of twitter
#!/usr/bin/python
# - * - coding: UTF-8 - * -
import cgi
import json
import urllib
import httplib2
h = httplib2.Http()
query = urllib.urlencode({
@upsuper
upsuper / gae_proxies
Created November 16, 2011 13:57
nginx GAE反向代理配置
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_pass http://ghs.google.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#include <iostream>
#include <stddef.h>
namespace mozilla {
template<typename Iterator>
struct IteratorTraits
{
typedef typename Iterator::ValueType ValueType;
r=lambda s:s.replace("\\","\\\\").replace("\"","\\\"");a,b="r=lambda s:s.replace(\"\\\\\",\"\\\\\\\\\").replace(\"\\\"\",\"\\\\\\\"\");a,b=\"","\";print(a+r(a)+\"\\\",\\\"\"+r(b)+b)";print(a+r(a)+"\",\""+r(b)+b)
@upsuper
upsuper / tone-mark-positioning.html
Last active August 29, 2015 14:14
Tone mark positioning polyfill
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<title>Polyfill demo for tone mark positioning</title>
<style>
body {
-webkit-writing-mode: vertical-rl;
-ms-writing-mode: tb-rl;
writing-mode: vertical-rl;
@upsuper
upsuper / maketiles.py
Created December 25, 2014 03:36
Customize Firefox Tiles
#!/usr/bin/env python3
import sys as _sys
import json as _json
import base64 as _base64
import logging as _logging
import mimetypes as _mimetypes
import urllib.parse as _url
import configparser as _configparser
#include <iostream>
template<class T>
class Out
{
private:
T& mValue;
public:
explicit Out(T& aValue)
@upsuper
upsuper / gist:6f67f933fa583d3750ae
Created November 25, 2014 22:49
Clear left .orig & .rej in hg repo
#!/bin/sh
files=$(hg status | awk '$1 == "?" && $2 ~ /\.(orig|rej)$/ { print $2 }')
echo "$files"
read -r -p "Remove these files? [y/N]" resp
case $resp in
[yY][eE][sS]|[yY])
rm $files
;;
*)
@upsuper
upsuper / check_patch.py
Last active August 29, 2015 14:07
Check difference between local patches and submitted ones
#!/usr/bin/env python3
# - * - coding: UTF-8 - * -
import sys
import json
import concurrent.futures as futures
from pathlib import Path
from difflib import Differ
from urllib.request import urlopen