Skip to content

Instantly share code, notes, and snippets.

@xiaq
xiaq / xml2jade.py
Created December 2, 2012 14:56
xml2jade
#!/usr/bin/python2
from itertools import takewhile, dropwhile
from bs4 import BeautifulSoup, Tag, NavigableString, Comment, Doctype
from sys import stdin, stdout
import json
import codecs
SINGLE_LINE_COMMENT_THRESHOLD = 1
STRIP_WRAPPING_EMPTY_LINES = True
`
// vim: nowrap
// ==UserScript==
// @name renren-markdown
// @namespace http://github.com/smilekzs
// @version 0.4.7
// @description write well-formatted blogs on renren.com with markdown
// @include *blog.renren.com/blog/*Blog*
// @include *blog.renren.com/*Entry*
// ==/UserScript==
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0120)http://oars.tsinghua.edu.cn/zgg/91398.nsf/3a6d726707df21a648256b440029539d/aa4e47935c8f96f7c82575f4000e59c7?OpenDocument -->
<HTML><HEAD><TITLE>通知</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>TD {
FONT-SIZE: 9pt; FONT-FAMILY: "宋体", "Verdana", "Arial", "Helvetica", "sans-serif"
}
.p {
FONT-SIZE: 12px; LINE-HEIGHT: 150%
}
@xiaq
xiaq / nederlande-list.md
Last active August 29, 2015 14:04
留学物品清单

目的地:荷兰 Eindhoven

书包内装:

  • 护照
  • 笔记本和其它电子产品
  • 文具:计算器、订书机、笔
  • 航空行程单
  • 到校后所需文件:毕业证&学位证、成绩单、办理居留许可的双认证文件
  • 飞机上看的书
@xiaq
xiaq / tmux.conf
Created September 22, 2014 08:48
set -g base-index 1
set -s escape-time 20
set -g repeat-time 360
set -g display-time 1000
set -g repeat-time 300
set -g history-limit 65536
set -g default-terminal screen
set -g visual-bell off
set -g set-titles on
import sys
COL = 2
acc = 0
with open(sys.argv[1]) as f:
for line in f:
acc += int(line.split('\t')[COL])
@xiaq
xiaq / rocks-research.md
Last active August 29, 2015 14:24
Research on popular rocks on luarocks.org

This is a report on the latest non-development rockspecs of all popular rocks on luarocks.org.

Remarks

  • Many rockspecs contain build.copy_directories = {}. Does this lead to different behavior than simply omitting build.copy_directories?
  • Many rockspecs have "test" in build.copy_directories. They can benefit from an addon that automatically runs these tests (luarocks-addon-test can be extended to do this).
  • Some rocks contain a lot of modules and the build.modules table contains a
Language 1B (ASCII) 2B (BMP) 4B (Unicode) Variable-length
go \xff \777 \uffff \Uffffffff
@xiaq
xiaq / dankobot.go
Last active January 21, 2016 13:05
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
"net/url"
"strings"
@xiaq
xiaq / cdnav.zsh
Last active January 22, 2016 00:00
typeset -gA cdnav
cdnav=(histno 1 listing 0 maxlist 5)
typeset -ga cdnav_hist
cdnav_hist=( "$PWD" )
cdnav::index() {
print -- "$cdnav_hist[$1]"
}
cdnav::push() {