Skip to content

Instantly share code, notes, and snippets.

@Linusp
Linusp / .bashrc
Last active August 29, 2015 14:05
Show git branch by PS1
CC_RESET='[00m'
CC_WHITE='[1;37m'
CC_LIGHT_BLUE='[1;34m'
CC_LIGHT_GREEN='[1;32m'
CC_LIGHT_RED='[1;31m'
function get_git_repos_branch()
{
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
}
@Linusp
Linusp / pereceptron_dual_form.py
Last active August 29, 2015 14:06
perceptron_dual_form
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Author : Linusp
Date : 2014/08/30
Description: Simple Perceptron Training
"""
import numpy as np
import matplotlib.pyplot as plt
@Linusp
Linusp / perceptron_origin.py
Created September 8, 2014 02:12
perceptron_origin
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Author : Linusp
Date : 2014/08/30
Description: Simple Perceptron Training
"""
import numpy as np
import matplotlib.pyplot as plt
@Linusp
Linusp / linear_regression.py
Created September 8, 2014 02:14
linear regression
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Author : Linusp
Date : 2014/08/30
Description: Linear Regression
"""
import numpy as np
import matplotlib as mpl
@Linusp
Linusp / 词性标记.md
Created December 21, 2015 07:46 — forked from luw2007/词性标记.md
词性标记: 包含 ICTPOS3.0词性标记集、ICTCLAS 汉语词性标注集、jieba 字典中出现的词性、simhash 中可以忽略的部分词性

词的分类

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

ICTPOS3.0词性标记集

n 名词

nr 人名

@Linusp
Linusp / useful_pandas_snippets.py
Created January 28, 2017 14:03 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@Linusp
Linusp / org-mode-reference-in.org
Created January 29, 2017 04:04 — forked from drj42/org-mode-reference-in.org
This is a cheat sheet for Emacs org-mode... in org-mode format!
import re
import pickle
from math import sqrt
from operator import itemgetter
from collections import defaultdict, Counter
import click
// ==UserScript==
// @name Weiboda Redirection
// @name:zh-CN 微博档案真实链接地址重定向
// @description 获取微博档案中的原始链接地址
// @grant none
// @run-at document-start
// @include *//weibo.wbdacdn.com/url/*
// ==/UserScript==
from elasticsearch import Elasticsearch
from elasticsearch.helpers import scan
index = 'some-index'
doctype = 'some-doctype'
client = Elasticsearch(hosts=['localhost:9200'])
for item in scan(client, index=index, doc_type=doctype, preserve_order=True):
print(item['_source'])