Skip to content

Instantly share code, notes, and snippets.

View alswl's full-sized avatar

Jingchao Di alswl

View GitHub Profile
@alswl
alswl / gist:2478306
Created April 24, 2012 09:32
将 Gnome3 第二显示器桌面随工作区变化
gsettings set org.gnome.shell.overrides workspaces-only-on-primary false
@alswl
alswl / rss.xml
Created May 22, 2012 08:33
rss.xml for Octopress
---
layout: nil
---
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<description><![CDATA[{{ site.title }}]]></description>
<title><![CDATA[{{ site.title }}]]></title>
<link>{{ site.url }}/</link>
<pubDate>{{ site.time | date_to_xmlschema }}</pubDate>
@alswl
alswl / moin2txt.py
Created July 27, 2012 01:22
moin2txt
#!/usr/bin/env python2
# coding=utf-8
# convert MoinMoin wiki to text
# for moinmoin 1.9.x
# author: alswl
# update at: 2012-07-22
import sys
import os

layout: post title: "读《打造 Facebook》" date: 2013-02-25 00:51 comments: true categories: 学海无涯 tags:

  • 创业
  • 读书笔记
# coding=utf-8
"""Worker Scripts"""
import os
import sys
_root = os.path.dirname(os.path.abspath(__file__))
import cPickle as pickle
import logging
from tornado.options import options
@alswl
alswl / r15.R
Last active December 21, 2015 06:09
# 15. 等级丰度曲线
# 根据 name 返回 color, lty
get_line_type = function(name) {
if (length(grep('-1$', name)) > 0) {
color <- 1
} else if (length(grep('-2$', name)) > 0) {
color <- 2
} else if (length(grep('-3$', name)) > 0) {
@alswl
alswl / script.py
Last active December 29, 2015 12:49
run `python script.py`
# coding=utf-8
import csv
import codecs
import cStringIO
import sys
class UTF8Recoder:
"""
# coding=utf-8
import csv, codecs, cStringIO
class UTF8Recoder:
"""
Iterator that reads an encoded stream and reencodes the input to UTF-8
"""
def __init__(self, f, encoding):
self.reader = codecs.getreader(encoding)(f)
@alswl
alswl / read_sogou_bin.py
Created February 14, 2016 07:41
「鼠须管」导入搜狗 Bin 词库
# -*- coding: UTF-8 -*-
import sys
import struct
import codecs
PinYinDic = [
"a",
"ai",
"an",
"ang",
@alswl
alswl / convert_named_group_to_position_based_group.py
Created April 20, 2016 10:45
python convert_named_group_to_position_based_group
# coding=utf-8
from __future__ import print_function, unicode_literals
import re
def convert_named_group_to_position_based_group(regex, replacement):
position_based_regex = regex
position_based_replacement = replacement
named_groups = [x[3:-1] for x in re.findall(r'(\?P<[a-z_]+>)', regex)]