brew install redis
Set up launchctl to auto start redis
$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)
| # -> (i + k) % len(nums) | |
| # A -> List | |
| # k -> number of postion | |
| def rotate(A, k): | |
| k %= len(A) | |
| A[k:], A[:k] = A[:-k], A[-k:] | |
| return A |
| countries = [ | |
| {'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'}, | |
| {'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'}, | |
| {'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"}, | |
| {'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'}, | |
| {'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'}, | |
| {'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'}, | |
| {'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai |
| """XLS -> json converter | |
| first: | |
| $ pip install xlrd | |
| then: | |
| $ cat in.xls | |
| date, temp, pressure | |
| Jan 1, 73, 455 | |
| Jan 3, 72, 344 |
| Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF | |
| Professional: KBJFW-NXHK6-W4WJM-CRMQB-G3CDH | |
| Keys are generic ones. These are the same from MSDN account. | |
| Product Key : -6Q8QF | |
| Validity : Valid | |
| Product ID : 00369-90000-00000-AA703 | |
| Advanced ID : XXXXX-03699-000-000000-00-1032-9200.0000-0672017 |
| # smtplib module send mail | |
| import smtplib | |
| TO = '[email protected]' | |
| SUBJECT = 'TEST MAIL' | |
| TEXT = 'Here is a message from python.' | |
| # Gmail Sign In | |
| gmail_sender = '[email protected]' |
| import smtplib | |
| from string import Template | |
| from email.mime.multipart import MIMEMultipart | |
| from email.mime.text import MIMEText | |
| MY_ADDRESS = '[email protected]' | |
| PASSWORD = 'mypassword' |
| # import necessary packages | |
| from email.mime.multipart import MIMEMultipart | |
| from email.mime.text import MIMEText | |
| # For each contact, send the email: | |
| for name, email in zip(names, emails): | |
| msg = MIMEMultipart() # create a message | |
| # add in the actual person name to the message template | |
| message = message_template.substitute(PERSON_NAME=name.title()) |
| <html> | |
| <head> | |
| <title>jsonp test</title> | |
| <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script> | |
| <script type="text/javascript"> | |
| $(function(){ | |
| $('#select_link').click(function(e){ | |
| e.preventDefault(); | |
| console.log('select_link clicked'); | |
| from flask import Flask, send_from_directory | |
| app = Flask(__name__) | |
| @app.route('/base/<path:filename>') | |
| def base_static(filename): | |
| return send_from_directory(app.root_path + '/../static/', filename) |