Skip to content

Instantly share code, notes, and snippets.

@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]
@davidyen1124
davidyen1124 / print_people.py
Created Jul 13, 2013
Print a triangle of '人'.
View print_people.py
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import sys
def main(args):
if len(args) == 1:
counter = int(args[0]) + 1
@davidyen1124
davidyen1124 / accuradio_button.py
Created Jul 13, 2013
Use Splinter to interact with chrome. And makes some buttons to play, pause and skip this song in AccuRadio.
View accuradio_button.py
#!/usr/bin/python
# -*- encoding: utf-8 -*-
from splinter.browser import Browser
import Tkinter
import sys
class Radio():
def __init__(self):
@davidyen1124
davidyen1124 / attack_on_titan.py
Created Jul 13, 2013
This is a parser to check if there is a new episode of Attack On Titan, and it will notify the user by email.
View attack_on_titan.py
#!/usr/bin/python
import urllib2
import re
import os
import sys
import send
import time
View GetCaptcha.py
#!/usr/bin/python
import urllib2
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36'
base_url = 'https://isafe.moe.edu.tw/check_number2.php?time=1375012321&number={0}'
def getCaptcha(number):
@davidyen1124
davidyen1124 / wifly.py
Created Aug 1, 2013
Get wifly API, and use "pygmaps" to show all the hotspot in Google Maps.
View wifly.py
#!/usr/bin/python
import urllib2
import json
import pygmaps
url = 'http://60.199.253.136/api/action/datastore_search?resource_id=d7a1b4c2-cad0-44f2-958a-a9d7a9330c95&limit=10000'
def main():
content = urllib2.urlopen(url).read()
@davidyen1124
davidyen1124 / wifly.py
Last active Dec 20, 2015
Get WiFly API, and use "pygmaps" to show all the hotspot in Google Maps.
View wifly.py
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import urllib2
import json
import pygmaps
url = 'http://60.199.253.136/api/action/datastore_search?resource_id=d7a1b4c2-cad0-44f2-958a-a9d7a9330c95&limit=100000'
@davidyen1124
davidyen1124 / toilet.py
Created Aug 1, 2013
Get public toilet API, and show them on Google Maps by "pygmaps".
View toilet.py
#!/usr/bin/python
import urllib2
import json
import pygmaps
url = 'http://data.taipei.gov.tw/opendata/apply/query/NTQ4QTg2RjMtQjg0NC00REIxLUFCMUMtMzBGNTE5RTdCRUY3?$format=json'
def main():
@davidyen1124
davidyen1124 / parking.py
Created Aug 1, 2013
Get parking lot API, and retrieve the address. After getting the address, I use pygeocoder to look for a rough coordinates. Finally I can use latitude and longitude to show all the parking lots on Google Maps by pygmaps.
View parking.py
#!/usr/bin/pyhton
# -*- encoding: utf-8 -*-
import urllib2
import json
import pygmaps
from pygeocoder import Geocoder, GeocoderError
url = 'http://data.taipei.gov.tw/opendata/apply/query/QzhBMEJFOTctMEEzRC00M0Q2LThDNDktNDVCNDc3NDNDRDBC?$format=json'
@davidyen1124
davidyen1124 / monkeyrunner_browser.py
Last active Dec 22, 2015 — forked from AaronMT/gist:3172633
Use Android Monkey Runner to open Browser application on every attached device.
View monkeyrunner_browser.py
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import os
devices = os.popen('adb devices').read().strip().split('\n')[1:]
package = 'com.android.browser'
activity = 'com.android.browser.BrowserActivity'
for serial in devices:
You can’t perform that action at this time.