Skip to content

Instantly share code, notes, and snippets.

View erning's full-sized avatar
🌴
On vacation

Zhang Erning erning

🌴
On vacation
View GitHub Profile
@erning
erning / hz2py.md
Created November 4, 2011 05:51
汉字转拼音

汉字转拼音 (hz2py)

我们希望安居客的搜索引擎能够更好的做到同音字的容错,采用拼音容错是一个不错的方法。因此,需要一个将汉字转换为拼音的组件。同时,汉字转拼音组件还可以有多个用途,例如以拼音的首字母来检索小区名、人名等。

这样我们需要一个通用的将汉字转换为拼音的服务。

功能

基本功能就是中文拉丁化,输入一段中文文本,输出转变为汉语拼音的文本。

要求原文中的全角标点符号、空格等应该转为对应的半脚符号。原汉字与英文间如果没有空格分隔,转换为拼音后应该加入空格分隔。

@erning
erning / mms.md
Created November 28, 2011 09:36
多关键字的文本精确匹配搜索

多关键字的文本精确匹配搜索 (mss - Multi-String Search)

基本的要求是对给定的一个文本块进行关键字匹配,进行匹配的关键字是多个,而且可能非常多(成千上万),然后输出各个匹配到的关键字的位置。这可用用作关键字的高亮显示,当然也可用进行敏感词过滤。

参考linux命令行fgrep

功能

输入一段文本,输出匹配到的关键字在输入文本中的位置。

例如,关键词列表:

sudo write

:w !sudo tee %

link

@erning
erning / aps-spec.markdown
Created June 18, 2012 06:53
Anjuke PHP Service

Goal

我们的目标是为PHP应用程序搭建一个轻量、灵活、高性能的异步远过程调用(RPC)的解决方案。同时也希望能够方便隔离前端的应用程序和后端的服务进程,使得产品的开发和部署更加便捷。

轻量

  • 可以将服务进程与PHP应用服务部署在同一台物理服务器上
  • 一台应用服务器上能够部署多种服务进程
@erning
erning / sudoku.c
Created June 19, 2012 10:37
判断数独的棋盘是否符合规则
int validate(int *pieces) {
int sc[] = {0,0,0,0,0,0,0,0,0};
int sr[] = {0,0,0,0,0,0,0,0,0};
int sb[] = {0,0,0,0,0,0,0,0,0};
int n;
for (n = 0; n < 81; n++) {
int x = pieces[n];
if (x == 0) continue;
if (x < 1 || x > 9) return 0;
@erning
erning / path.go
Created December 17, 2012 08:26 — forked from sp3c73r2038/path.py
golang
/*
put this script in the path like
assumed /tmp (cwd)
/tmp/dir1/dir2/path.go
/tmp/dir3 symlinked to /tmp/dir1/dir2
and run with
gorun ../tmp/dir3/path.go
or build path.go and run with ../tmp/dir3/path
# bash_completion
complete -o bashdefault -o default -o nospace -c ve
zone "twitter.com" IN {
type forward;
forward only;
forwarders {
74.207.241.5;
74.207.242.5;
};
};
@erning
erning / README.md
Last active January 11, 2020 22:57
isolated ansible installation

still running from source

$ git clone git://github.com/ansible/ansible.git
$ cd ./ansible
$ virtualenv .virtualenv
$ source .virtualenv/bin/activate
$ pip install paramiko PyYAML jinja2
//
// $ gcc -std=c99 glowpz.c -o glowpz
//
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
const uint32_t ORIGIN = 0x0CCCC; // 0 1100 1100 1100 1100
const uint32_t TARGET = 0x05A5A; // 0 0101 1010 0101 1010