Skip to content

Instantly share code, notes, and snippets.

@davidyen1124
davidyen1124 / fb_like_photos.py
Created Feb 7, 2014
Get the photos you liked in facebook.
View fb_like_photos.py
import facebook
token = '<TOKEN_HERE>'
graph = facebook.GraphAPI(token)
query = {'objects': 'SELECT object_id FROM like WHERE user_id = me() AND object_type = "photo"',
'likes': 'SELECT owner, src_big, link, created FROM photo WHERE object_id IN (SELECT object_id from #objects)'}
likes = graph.fql(query)[1]['fql_result_set']
with open('test.html', 'w') as f:
f.write('<html><body>')
View kgi.py
import requests
import re
url = "https://www.kgieworld.com.tw/stock/stock_2_7.aspx?findex=1"
def main():
session = requests.session()
response = session.get(url)
content = response.content
View taipei_bus.py
# -*- encoding: utf-8 -*-
import requests
import bs4
def ebus(rid):
# use rid to form the url
url = 'http://e-bus.tpc.gov.tw/pda/online.php?rid=%s' % rid
# there are two arrays which are go and back
go_route = []
@davidyen1124
davidyen1124 / movie.py
Last active Aug 29, 2015
clone https://github.com/richardasaurus/imdb-pie, then put this script into the folder.
View movie.py
import re
import os
from itertools import groupby
from imdbpie import Imdb
import threading
import Queue
queue = Queue.Queue()
out_queue = Queue.Queue()
results = []
@davidyen1124
davidyen1124 / date_handler.py
Created Apr 7, 2014
Date handler for JSON dumps if the error is JSON can't serializable
View date_handler.py
# convert datetime object to ISO format, so json.dumps() works
def date_handler(obj):
return obj.isoformat() if hasattr(obj, 'isoformat') else obj
View sf.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View bus.py
# -*- encoding: utf-8 -*-
import requests
import bs4
def ebus(rid):
# use rid to form the url
url = 'http://e-bus.tpc.gov.tw/pda/online.php?rid=%s' % rid
# there are two arrays which are go and back
@davidyen1124
davidyen1124 / friend.py
Created May 21, 2014
Facebook mining script
View friend.py
import facebook
import json
import settings
g = facebook.GraphAPI('TOKEN')
# get all your friend's id and name
friends = g.get_connections('me', 'friends')['data']
# save every id in friends.json
View avatar.py
# -*-encoding: utf-8 -*-
import argparse
import sys
from hashlib import md5
from PIL import Image, ImageDraw
def main():
# hash the input text until enough length we want
@davidyen1124
davidyen1124 / resize.py
Created Jul 13, 2013
Resize the images with SIPS in Mac OS X. Usage: python resize.py <height> <width> <path to the directory>
View resize.py
#!/usr/bin/python
import os
import sys
import commands
def getHeightWidth(file):
widthstr = commands.getstatusoutput('sips -g pixelWidth {0}'.format(file))[1]
heightstr = commands.getstatusoutput('sips -g pixelHeight {0}'.format(file))[1]
You can’t perform that action at this time.