Skip to content

Instantly share code, notes, and snippets.

View skydark's full-sized avatar

Skydark Chen skydark

View GitHub Profile
@skydark
skydark / raskell.rb
Created May 24, 2013 13:11 — forked from andkerosine/raskell.rb
list comprehension in ruby, see also: https://gist.github.com/freakhill/5564328 #ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@skydark
skydark / wawammseg.py
Created August 23, 2012 09:47 — forked from onlytiancai/wawammseg.py
写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码 #python
# -*- coding:utf-8 -*-
'写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码'
'搜狗词库下载地址:http://vdisk.weibo.com/s/7RlE5'
import string
__dict = {}
def load_dict(dict_file='words.dic'):
'加载词库,把词库加载成一个key为首字符,value为相关词的列表的字典'
@skydark
skydark / prime_sieve.go
Created August 15, 2012 15:37 — forked from lyricat/prime_sieve.go
A concurrent prime sieve #go
// A concurrent prime sieve
// via: http://golang.org/doc/play/sieve.go
package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch chan<- int) {
for i := 2; ; i++ {
ch <- i // Send 'i' to channel 'ch'.
}