Skip to content

Instantly share code, notes, and snippets.

View selfboot's full-sized avatar
🎯
Focusing

selfboot selfboot

🎯
Focusing
View GitHub Profile
@selfboot
selfboot / 7A.R
Created November 8, 2015 07:50
Mining Massive Datasets Quiz Week7A Advanced.
# First, we index a string of length L on the symbols appearing in its prefix of length floor(0.2L+1). Thus, strings of length 5 and 6 are indexed on their first two symbols, while strings of length 4 are indexed on their first symbol only. Thus, the index for a consists of {s1, s2, s4, s8}; the index for b consists of {s1, s3, s5, s6}, the index for c consists of {s2, s3, s5, s7}, and no other symbol is indexed at all.
# For s1, we examine the indexes for a and b, which contains all strings but s7. Thus, s1 is compared with 6 other strings.
# For s3, we examine the indexes for b and c, which together contain s1, s2, s3, s5, s6, and s7. Thus, s3 is compared with five other strings.
# For s6, we examine only the index for b. Thus, s6 is compared only with the three other strings s1, s3, and s5.
@selfboot
selfboot / chardet_test.py
Last active December 15, 2015 17:39
python 编码检测示例程序.
>>> import requests
>>> r = requests.get('http://www.luoo.net/radio/radio2/mp3player.xml')
>>> r.status_code
200
>>> print r.content
锘??xml version="1.0" encoding="UTF-8"?>
<player showDisplay="yes" showPlaylist="yes" autoStart="yes">
<song path="http://ftp.luoo.net/radio/radio2/1.mp3" title="鏃呰€? />
<song path="http://ftp.luoo.net/radio/radio2/2.mp3" title="绱㈤潪浜? />
<song path="http://ftp.luoo.net/radio/radio2/3.mp3" title="涓夊嘲" />
@selfboot
selfboot / complete-dict
Created April 3, 2013 10:45 — forked from ntavish/complete-dict
python关键字自动补全字典
--- complete-dict - Created by Ryan Kulla using Python 2.6 on Ubuntu Linux 9.04 on July 23rd 2009 ---
--- Python Keywords (These were manually inputted) ---
and
del
for
is
raise
assert
elif
@selfboot
selfboot / redirect.c
Created April 13, 2013 07:36
判断stdout是否被重定向..
重定向:
zsh➜ $ ./file.o
before redirect...
zsh➜ $ cat demo
after redirect...
Redirected
@selfboot
selfboot / gist:5403358
Created April 17, 2013 10:45
mac wget 安装
下载Wget的源代码,下载地址:http://ftp.gnu.org/gnu/wget/
直接安装的话,会发生下面的错误。
checking for compress in -lz... yes
checking for gpg_err_init in -lgpg-error... no
checking for gcry_control in -lgcrypt... no
checking for libgnutls... no
configure: error: --with-ssl was given, but GNUTLS is not available.
解决:
@selfboot
selfboot / weather.py
Created April 18, 2013 09:52
weather.py: 获取天气信息,默认显示南阳新乡天气,可以在脚本后面加参数指定特定地点的天气。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import sys
CITY_RECORD = {
# 直辖市
"北京": "101010100", "上海": "101020100",
"天津": "101030100", "重庆": "101040100",
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
import eyed3
import re
import urllib
import os
@selfboot
selfboot / download_ted.py
Created May 19, 2013 15:28
TED 视频下载: 获取指定标签下的所有带英文字幕的视频的下载url,然后用`curl -L -C - -O url`下载视频。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import re
keywords_pattern = re.compile(r".*/([^.]+).mp4*")
subtitles_url_pattern = re.compile(r'<option value="en">English</option>')
base_url = "http://www.ted.com"
@selfboot
selfboot / v2ex_auto.py
Created May 21, 2013 11:35
V2EX 自动领取奖励脚本:延迟一秒领取奖励(服务器检测速度判定是否是程序领取奖励)
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import time
from bs4 import BeautifulSoup
signin_url = "http://www.v2ex.com/signin"
award_url = "http://www.v2ex.com/mission/daily"
main_url = "http://www.v2ex.com"
@selfboot
selfboot / install.sh
Created June 15, 2013 03:47
YouCompleteMe 安装问题
➜ YouCompleteMe git:(master) ✗ pwd
/Users/xuelang/.vim/bundle/YouCompleteMe
➜ YouCompleteMe git:(master) ✗ ls
CONTRIBUTING.md README.md cpp install.sh python
COPYING.txt autoload doc plugin style_format.sh
➜ YouCompleteMe git:(master) ✗ git submodule update --init --recursive