Skip to content

Instantly share code, notes, and snippets.

View staticor's full-sized avatar

SteveYagn staticor

View GitHub Profile
@staticor
staticor / gcd_and_lcm.py
Created March 24, 2016 02:25 — forked from endolith/gcd_and_lcm.py
GCD and LCM functions in Python
# Greatest common divisor of more than 2 numbers. Am I terrible for doing it this way?
def gcd(*numbers):
"""Return the greatest common divisor of the given integers"""
from fractions import gcd
return reduce(gcd, numbers)
# Least common multiple is not in standard libraries? It's in gmpy, but this is simple enough:
def lcm(*numbers):
@staticor
staticor / Apriori.py
Created July 15, 2016 05:51 — forked from marcelcaraciolo/Apriori.py
Apriori.py
#-*- coding:utf-8 - *-
def load_dataset():
"Load the sample dataset."
return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]
def createC1(dataset):
"Create a list of candidate item sets of size one."
@staticor
staticor / Apriori_rules.py
Created July 15, 2016 06:51 — forked from marcelcaraciolo/Apriori_rules.py
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]:
@staticor
staticor / alternative.yaml
Created July 28, 2016 08:46 — forked from lotem/alternative.yaml
Rime 別樣設定,使用西文標點、[ ] 鍵換頁
# Rime alternative settings
# encoding: utf-8
#
# difference from default settings:
# 1. ascii-style punctuation in half-shape mode
# 2. [ ] as paging keys
#
# save this file as:
# (Linux) ~/.config/ibus/rime/alternative.yaml
# (Mac OS) ~/Library/Rime/alternative.yaml
# -*- coding: utf-8 -*-
""" Small script that shows hot to do one hot encoding
of categorical columns in a pandas DataFrame.
See:
http://scikit-learn.org/dev/modules/generated/sklearn.preprocessing.OneHotEncoder.html#sklearn.preprocessing.OneHotEncoder
http://scikit-learn.org/dev/modules/generated/sklearn.feature_extraction.DictVectorizer.html
"""
import pandas
import random
@staticor
staticor / basecommand_emacs
Last active August 13, 2017 11:58 — forked from shijinkui/basecommand_emacs
Emacs常用基本快捷键
/************************************/
基本命令
C-x C-f 打开/新建文件 C-x C-s 保存当前缓冲区
C-x C-w 当前缓冲区另存为
C-x i 光标处插入文件
C-x b 切换Buffer C-x C-b 显示Buffer列表
C-x k 关闭当前Buffer C-x C-c 关闭Emacs
@staticor
staticor / tmux常用命令
Last active November 11, 2016 04:00 — forked from xionglikarl/tmux常用命令
tmux常用命令
#  自己习惯用 C-x 作为prefix
## 系统操作(session)
s list all sessions
$ rename
## 窗口操作
c create
, rename
<Num>  switch
&  close
@staticor
staticor / punctuation.js
Created February 23, 2017 14:51 — forked from CarlLee/punctuation.js
Match punctuation in English/Chinese sentenses
var re = /([\[\]\,.?"\(\)+_*\/\\&\$#^@!%~`<>:;\{\}?,。·!¥……()+{}【】、|《》]|(?!\s)'\s+|\s+'(?!\s))/ig;
content.replace(re, '');
@staticor
staticor / 词性标记.md
Created April 1, 2017 09:50 — forked from luw2007/词性标记.md
词性标记: 包含 ICTPOS3.0词性标记集、ICTCLAS 汉语词性标注集、jieba 字典中出现的词性、simhash 中可以忽略的部分词性

词的分类

  • 实词:名词、动词、形容词、状态词、区别词、数词、量词、代词
  • 虚词:副词、介词、连词、助词、拟声词、叹词。

ICTPOS3.0词性标记集

n 名词

nr 人名

@staticor
staticor / bankcard_check.js
Created June 30, 2017 02:27 — forked from zhangw/bankcard_check.js
银行卡号Luhm校验算法
//Description: 银行卡号Luhm校验算法
//Luhm校验规则:16位银行卡号(19位通用):
// 1.将未带校验位的 15(或18)位卡号从右依次编号 1 到 15(18),位于奇数位号上的数字乘以 2。
// 2.将奇位乘积的个十位全部相加,再加上所有偶数位上的数字。
// 3.将加法和加上校验位能被 10 整除。
  //bankno位银行卡号
function luhmCheck(bankno){