Skip to content

Instantly share code, notes, and snippets.

View staticor's full-sized avatar

SteveYagn staticor

View GitHub Profile
@vincentchu
vincentchu / boyer_moore.rb
Created February 12, 2012 04:46
Boyer Moore implemented in Ruby
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 )
@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."
@staticor
staticor / class_decorator.py
Created January 28, 2016 03:10 — forked from phith0n/class_decorator.py
class decorator
class Tx(object):
def __init__(self):
print("Tx:init")
self.something()
def something(self):
print("Tx:something")
def otherthing(self):
print("Tx:otherthing")
@staticor
staticor / get_data_mysql.sh
Created February 17, 2016 03:03
mysql retrieve data in Shell.
function run_Mysql()
{
mysql --default-character-set=utf8 \
-h 192.168.156.120 \
-u data -p'PIN239!@#$%^&8' \
-D optimus \
-e "
select platform, day
, SUM(bid) as bid , SUM(imp) as imp
@zhangw
zhangw / bankcard_check.js
Created November 8, 2013 06:18
银行卡号Luhm校验算法
//Description: 银行卡号Luhm校验算法
//Luhm校验规则:16位银行卡号(19位通用):
// 1.将未带校验位的 15(或18)位卡号从右依次编号 1 到 15(18),位于奇数位号上的数字乘以 2。
// 2.将奇位乘积的个十位全部相加,再加上所有偶数位上的数字。
// 3.将加法和加上校验位能被 10 整除。
  //bankno位银行卡号
function luhmCheck(bankno){
@staticor
staticor / findhao_rss_sources.xml
Created December 5, 2018 09:30 — forked from FindHao/findhao_rss_sources.xml
我的rss订阅源
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<opml version="1.0">
<head>
<title>
Subscriptions of find from Inoreader [https://www.inoreader.com]
</title>
</head>
<body>
<outline text="Blogs" title="Blogs">
<outline text="cgnail's weblog" title="cgnail's weblog" type="rss" xmlUrl="http://cgnail.github.io/atom.xml" htmlUrl="http://cgnail.github.io/"/>
@lotem
lotem / active.md
Created December 27, 2013 13:09 — forked from paulmillr/active.md

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Sat, 22 Dec 2012 23:34:58 GMT till Sun, 22 Dec 2013 23:34:58 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter((user) -&gt; user.followers &gt; 229)
@creeek
creeek / default.custom.yaml
Created April 20, 2015 06:30
Custom RIME
# ~/Library/Rime/default.custom.yaml
patch:
menu/page_size: 5
recognizer/patterns/yuncheng123: "^yuncheng[0-9]+$"
recognizer/patterns/yunchengime: "^yuncheng[-_.0-9]*$"
recognizer/patterns/xiang123: "^xiang[0-9]+$"
recognizer/patterns/xiangime: "^xiang[-_.0-9]*$"
recognizer/patterns/xuxiang123: "^xuxiang[0-9]+$"
recognizer/patterns/xuxiangime: "^xuxiang[-_.0-9]*$"
@NemoAlex
NemoAlex / gist:2879405
Created June 6, 2012 02:07
Squirrel 配色方案修改
更新:建议编辑 ~/Library/Rime/squirrel.custom.yaml 文件,而不要在 squirrel.yaml 上做改动
新版本加入了对边距宽高的订制,感谢作者
patch:
us_keyboard_layout: true
style/horizontal: false
style/font_face: "Helvetica Neue"
style/font_point: 21
style/corner_radius: 4
style/border_height: 4
@marcelcaraciolo
marcelcaraciolo / Apriori_rules.py
Created December 4, 2011 18:04
apriori_rules.py
def generateRules(L, support_data, min_confidence=0.7):
"""Create the association rules
L: list of frequent item sets
support_data: support data for those itemsets
min_confidence: minimum confidence threshold
"""
rules = []
for i in range(1, len(L)):
for freqSet in L[i]: