Skip to content

Instantly share code, notes, and snippets.

View staticor's full-sized avatar

SteveYagn staticor

View GitHub Profile
class BoyerMoore
attr_accessor :text
attr_reader :pattern, :matches
def initialize( opts )
@text = opts[:text]
end
def search( pattern_str )
@pattern = Pattern.new( pattern_str )
using System;
using System.Linq;
using System.Collections.Generic;
 
// http://acm.timus.ru/problem.aspx?space=1&num=1727
static class Timus
{
  static void Main()
  {
    var n = int.Parse(Console.ReadLine());
@staticor
staticor / 0717acm
Created July 17, 2013 11:58
acm everyday
0177
@staticor
staticor / python-1
Created July 24, 2013 05:21
data clean job.
test python.
fro deata clean
# -*- coding=utf-8 -*-
import collections
 
# Usage:
# 我的做法是把WordsDetector.py里的结果输出到文件,
# 然后把文件名放到下面的names列表中,运行本程序。
 
names = ['name0',
'name1',
'name2',
# -*- coding=utf-8 -*-
import feedparser
import re
import collections
import math
 
def info_entropy(words):
result = 0
total = sum([val for _, val in words.iteritems()])
for word, cnt in words.iteritems():
@staticor
staticor / python.sublime-snippet
Created August 15, 2013 03:40
python snippet in sublime text 2 or 3
<snippet>
<content><![CDATA[
#!/usr/bin/env python
#-*- coding:utf -8-*-
'''
#Author: Staticor
#Company: EverString
#File:
#Description: this program
#Revision: //2013
@staticor
staticor / key-binding. sublime text
Created August 15, 2013 03:51
key binding in sublime text
[
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser"} },
{ "keys": ["enter"],
"command": "move",
"args": {"by": "characters", "forward": true},
"context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)\\]\\>\\'\\\"]", "match_all": true },
]
@staticor
staticor / countdown_days.rb
Created August 18, 2013 14:21
ruby_ count down special days __ to come
#!/usr/bin/ruby
# Calculate the countdown for the special day.
require 'Date'
days = (DateTime.new(2013,10,20) - DateTime.now).ceil
puts "Maybe #{days} days left."
@Test
public void testDemo() {
JiebaSegmenter segmenter = new JiebaSegmenter();
String[] sentences =
new String[] {"这是一个伸手不见五指的黑夜。我叫孙悟空,我爱北京,我爱Python和C++。", "我不喜欢日本和服。", "雷猴回归人间。",
"工信处女干事每月经过下属科室都要亲口交代24口交换机等技术性器件的安装工作", "结果婚的和尚未结过婚的"};
for (String sentence : sentences) {
System.out.println(segmenter.process(sentence, SegMode.INDEX).toString());
}
}