This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from urllib import urlencode | |
| from urllib2 import Request, urlopen, HTTPError | |
| from json import loads as jsonsload | |
| dictionary_of_useful_things = { | |
| "client_id": "261777520064-etb9m51k800e6ucrcf767th54uc5nt7i.apps.googleusercontent.com", | |
| "client_secret": "{{ it's a secret. SSHHHhhh! }}", | |
| "redirect_uri": "urn:ietf:wg:oauth:2.0:oob", | |
| "grant_type": "authorization_code" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Simple bijective function | |
| # Basically encodes any integer into a base(n) string, | |
| # where n is ALPHABET.length. | |
| # Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047 | |
| ALPHABET = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") | |
| # make your own alphabet using: | |
| # (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join | |
| def bijective_encode(i): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import choice | |
| d = { | |
| 'foo1': 1, | |
| 'foo2': 5, | |
| 'foo3': 3 | |
| } | |
| choice([k for k in d for x in range(d[k])]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| sudo = "sudo -u xuser %s" | |
| instruction = "vlc 20100420-0343a.mp3" | |
| os.system(sudo % instruction) |
NewerOlder