This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function get_title_via_url( $url ) | |
| { | |
| // 抓取前1024个字节 | |
| $context=array('http' => array ('header'=> 'Range: bytes=0-1024' )); | |
| $xcontext = stream_context_create($context); | |
| $content = strtolower( file_get_contents( $url , FALSE,$xcontext ) ); | |
| $reg = '/<title>(.+?)<\/title>/is'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IMPORTANT | |
| Please duplicate this radar for a Safari fix! | |
| This will clean up a 50-line workaround. | |
| rdar://22376037 (https://openradar.appspot.com/radar?id=4965070979203072) | |
| ////////////////////////////////////////////////////////////////////////////// | |
| (Now available as a standalone repo.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import numpy | |
| from pandas import DataFrame | |
| from sklearn.feature_extraction.text import CountVectorizer | |
| from sklearn.naive_bayes import MultinomialNB | |
| from sklearn.pipeline import Pipeline | |
| from sklearn.cross_validation import KFold | |
| from sklearn.metrics import confusion_matrix, f1_score | |
| NEWLINE = '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding=utf-8 | |
| """ | |
| Slugify for Chinese | |
| 没有优化多音字 | |
| 优化多音字的项目有: | |
| https://github.com/jiedan/chinese_pinyin | |
| """ | |
| import re | |
| import unidecode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- encoding: UTF-8 -*- | |
| import codecs | |
| import sys | |
| from math import log | |
| from collections import defaultdict | |
| class Trie (object): | |
| class TrieNode: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # git autodeploy script when it matches the string "[deploy]" | |
| # | |
| # @author cashlee | |
| # @link http://cashlee.info | |
| # @version 0.1 | |
| # | |
| # Usage: | |
| # 1. put this into the post-receive hook file itself below |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function StartTagToken(){ | |
| } | |
| function EndTagToken(){ | |
| } | |
| function Attribute(){ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ubuntu PHP mail | |
| # Ubuntu 12.04 LTS | |
| # IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh root@888.88.88.88 where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial ::: | |
| # Resources | |
| # https://help.ubuntu.com/12.04/serverguide/postfix.html | |
| # http://sourcelibrary.org/2011/08/29/how-to-set-up-the-php-mail-function-on-a-ubuntu-linux-lamp-server/ | |
| # http://stackoverflow.com/questions/12083025/xampp-on-ubuntu-server-12-04-with-pear-installed-returns-errors-when-trying-to-u | |
| # http://askubuntu.com/questions/47609/how-to-have-my-php-send-mail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| __author__ = 'Encore Hu, <huyoo353@126.com>' | |
| class Suffix(object): | |
| def __init__(self, start, end): | |
| self.start = start | |
| self.end = end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| analyse the user's chrome behavior. | |
| ''' | |
| import sqlite3 | |
| import urlparse | |
| class AnalyseChrome: | |
| ''' | |
| the user's chrome history log is writed by sqllite. and saved default in ~/.config/google-chrome/Default/History at ubuntu. | |
| ''' |