A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| <?xml version="1.0" encoding="UTF-8"?> | |
| <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> | |
| <CORSRule> | |
| <AllowedOrigin>*</AllowedOrigin> | |
| <AllowedMethod>GET</AllowedMethod> | |
| <MaxAgeSeconds>3000</MaxAgeSeconds> | |
| <AllowedHeader>Authorization</AllowedHeader> | |
| <AllowedHeader>Content-*</AllowedHeader> | |
| <AllowedHeader>Host</AllowedHeader> | |
| </CORSRule> |
| <? | |
| // Session may not be started on this script, if not init session | |
| if (!session_id()) { | |
| session_start(); | |
| } | |
| // double check, once for the key, again that the result is an int larger than 0 (as WP will follow the AI rule in the DB) | |
| if (array_key_exists('some_custom_var', $_SESSION) and $_SESSION['some_custom_var'] > 0){ | |
| echo 'User is valid with id:'.$_SESSION['some_custom_var']; | |
| }else{ |
| import requests | |
| import time | |
| import json | |
| token = '' | |
| #Delete files older than this: | |
| ts_to = int(time.time()) - 30 * 24 * 60 * 60 | |
| def list_files(): |
| Cobra CM-2204/28 Multirotor Motor, Kv=2300 | |
| Cobra C-2202/70 Brushless Motor, Kv=1530 | |
| Cobra C-2203/28 Brushless Motor, Kv=2800, E36-F1S | |
| Cobra C-2203/34 Brushless Motor, Kv=2300 | |
| Cobra C-2203/46 Brushless Motor, Kv=1720 |
| # source http://www.bestwordlist.com/5letterwords.txt | |
| WORDS = [ | |
| 'AAHED', 'AALII', 'AARGH', 'AARTI', 'ABACA', 'ABACI', 'ABACK', 'ABACS', 'ABAFT', 'ABAKA', 'ABAMP', | |
| 'ABAND', 'ABASE', 'ABASH', 'ABASK', 'ABATE', 'ABAYA', 'ABBAS', 'ABBED', 'ABBES', 'ABBEY', 'ABBOT', | |
| 'ABCEE', 'ABEAM', 'ABEAR', 'ABELE', 'ABETS', 'ABHOR', 'ABIDE', 'ABIES', 'ABLED', 'ABLER', 'ABLES', | |
| 'ABLET', 'ABLOW', 'ABMHO', 'ABODE', 'ABOHM', 'ABOIL', 'ABOMA', 'ABOON', 'ABORD', 'ABORE', 'ABORT', | |
| 'ABOUT', 'ABOVE', 'ABRAM', 'ABRAY', 'ABRIM', 'ABRIN', 'ABRIS', 'ABSEY', 'ABSIT', 'ABUNA', 'ABUNE', | |
| 'ABUSE', 'ABUTS', 'ABUZZ', 'ABYES', 'ABYSM', 'ABYSS', 'ACAIS', 'ACARI', 'ACCAS', 'ACCOY', 'ACERB', | |
| 'ACERS', 'ACETA', 'ACHED', 'ACHES', 'ACHOO', 'ACIDS', 'ACIDY', 'ACING', 'ACINI', 'ACKEE', 'ACKER', | |
| 'ACMES', 'ACMIC', 'ACNED', 'ACNES', 'ACOCK', 'ACOLD', 'ACORN', 'ACRED', 'ACRES', 'ACRID', 'ACTED', |
| def prepare_for_api(str_json): | |
| """ | |
| Prepare a json string API use by escaping double quotes and removing \n new line breaks | |
| :param str_json: string | |
| :return: string | |
| Note: Use pattern is to wrap data at the last possible moment to avoid extra escaping. | |
| """ | |
| str_json = re.sub(' +', ' ', str_json) # kills multi whitespace | |
| str_json = str_json.replace('\n', '') # kill new line breaks caused by triple quoted raw strings | |
| str_json = str_json.replace('"', '\\"') # address double quotes |
| t = [ | |
| ('a', 'b'), | |
| ('c', 'd') | |
| ] | |
| if len([item[1] for item in t if item[0] == 'a']): | |
| print 'yes' | |
| else: | |
| print 'no' | |
| # yes | |
| if len([item[1] for item in t if item[0] == 'e']): |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """Encrypt/decrypt files with symmetric AES cipher-block chaining (CBC) mode. | |
| Usage: | |
| File Encryption: | |
| aescrypt.py [-f] infile [outfile] |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |