Skip to content

Instantly share code, notes, and snippets.

View dawranliou's full-sized avatar

Daw-Ran Liou dawranliou

View GitHub Profile
@dawranliou
dawranliou / yelp-api.py
Created September 21, 2016 07:27
Example to use Yelp Fusion API
import os
import requests
app_id = os.environ['APP_ID']
app_secret = os.environ['APP_SECRET']
data = {'grant_type': 'client_credentials',
'client_id': app_id,
'client_secret': app_secret}
token = requests.post('https://api.yelp.com/oauth2/token', data=data)
access_token = token.json()['access_token']
@dawranliou
dawranliou / takemehome.py
Created September 17, 2016 01:52
The program to check the traffic for my way home
#!python
import webbrowser
import os
destination = os.environ.get('HOME_ADDR')
destination = '+'.join(destination.split())
origin = os.environ.get('OFFICE_ADDR')
origin = '+'.join(origin.split())
url = 'https://www.google.com/maps/dir/%s/%s' % (origin, destination)
@dawranliou
dawranliou / mailprank.py
Created September 16, 2016 23:40
Office pranks
import smtplib
import email.utils
from email.mime.text import MIMEText
from collections import namedtuple
Prankee = namedtuple('Prankee', 'name id email')
colleague = Prankee('Colleague', 'colleague_id', '[email protected]')
subject = '[IT Information] %s we detect unauthorized actions from your account' % colleague.name
body = '''Dear user %s (%s),