Skip to content

Instantly share code, notes, and snippets.

View t0mst0ne's full-sized avatar

ChenChang Shih t0mst0ne

View GitHub Profile
import json
import os
import time
import requests
from PIL import Image
from StringIO import StringIO
from requests.exceptions import ConnectionError
def go(query, path):
"""Download full size images from Google image search.
@t0mst0ne
t0mst0ne / Elastic1.5.sh
Created April 10, 2015 14:00
Elasticsearch 1.5 on Ubuntu
wget -qO - https://packages.elasticsearch.org/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb http://packages.elasticsearch.org/elasticsearch/1.5/debian stable main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update && sudo apt-get install elasticsearch
sudo service elasticsearch restart
@t0mst0ne
t0mst0ne / Get book rent status.py
Last active August 29, 2015 14:19
parse book name and check library rent status
import requests
import pandas as pd
import re
import urllib
import time
url = 'http://www.family977.com.tw/News_look.asp?NewsID=724'
webpac = 'http://book.tpml.edu.tw/webpac/webpacIndex.jsp'
r = requests.get(url)

##TUNING##

Configuration

System: set file descriptors to 32K or 64K

vim /etc/security/limit.conf

@t0mst0ne
t0mst0ne / install_elastic.sh
Last active September 20, 2023 11:55
Install 1.5.2 elasticsearch on Ubuntu
# install Elasticsearch
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java8-installer
wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | sudo apt-key add -
echo 'deb http://packages.elasticsearch.org/elasticsearch/1.5/debian stable main' | sudo tee /etc/apt/sources.list.d/ela
sticsearch.list
sudo apt-get update
sudo apt-get -y install elasticsearch=1.5.2
"""Tools for searching Pubmed for a list of PMIDs.
The goal here is to search for many PMIDs at once, since searching
sequentially can take a long time. Using the the BioPython Entrez module
is super convenient to this end.
The results results are returned in a simple dictionary format.
"""
@t0mst0ne
t0mst0ne / Pharmacy.Callback.py
Last active August 29, 2015 14:23
TW pharmacy callback lists ( 1998 - 2015 )
import pandas as pd
import requests
df = pd.DataFrame()
for year in range(97,105):
print year
URL = 'https://consumer.fda.gov.tw/GMPList/ashx/getGMPProductResult.ashx?_=1435042152201&__VIEWSTATE=%2FwEPDwULLTEwMDUyNjYzMjhkZIn1wjY4ydi7MXvvO17IM6jcyCzE&__VIEWSTATEGENERATOR=E48A775B&fullkeyword=&selectGroup=1&loginusername=&loginpwd=&start=0&pageNo=1000&location=1&gmp_sort=%244%24-1&gmp_field=&year=%24year%3A' + str(year)
r = requests.get(URL,verify=False)
r.json()
df_year = pd.DataFrame(r.json()['GMPProduct'])
@t0mst0ne
t0mst0ne / reader.py
Last active August 29, 2015 14:25
Get mp3 list from 閱讀推手
# 閱讀推手 MP3
import re
import requests
import subprocess
URL = 'http://crdo.in/program/3c1k8Kj19g'
requests.get(URL)
r = requests.get(URL)
find =re.findall('"/episode/(.+?)"' , r.text)
#coding:UTF-8
import requests
import pandas as pd
import re
import urllib
import time
url = 'http://www.family977.com.tw/News_look.asp?NewsID=724'
webpac = 'http://book.tpml.edu.tw/webpac/webpacIndex.jsp'
# Ref http://ubuntuserverguide.com/2014/01/how-to-test-internet-connection-speed-using-speedtest-cli-on-ubuntu-server.html
sudo apt-get install python-pip
sudo pip install speedtest-cli
sudo wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
sudo chmod a+rx speedtest_cli.py
./speedtest-cli