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
| """ | |
| This script converts Kippt json export to unmark json format. | |
| Lists in Kippt will be converted to tags. | |
| Bonus: lines in notes staring with 'Tags: ' will be imported as tags. | |
| Required packages: pytz, tzlocal, python-dateutil | |
| Usage: | |
| python kippt_to_unmark.py export_data.json > export.json |
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
| def unique_filename(path): | |
| """ | |
| Enforce unique upload file names. | |
| Usage: | |
| class MyModel(models.Model): | |
| file = ImageField(upload_to=unique_filename("path/to/upload/dir")) | |
| """ | |
| import os, base64, datetime |
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
| if previous_request: | |
| previous_request.delete() | |
| del(previous_request) | |
| previous_request = None |
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
| #!/usr/bin/env python | |
| # Example usage: | |
| # ls|each cd PARAM\;pwd | |
| import sys, subprocess | |
| command = " ".join(sys.argv[1:]) | |
| command = command.replace("PARAM", "%(p)s") | |
| i = 0 | |
| for parameter in sys.stdin.readlines(): |
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 __future__ import with_statement |
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
| def group_iterate(list = [], group_by = 1): | |
| """ | |
| Iterates over the elements of list grouping elements by the specified amount. | |
| Example usage: | |
| >>> for a in group_iterate(range(12), 3): | |
| ... print a | |
| ... | |
| (0, 1, 2) | |
| (3, 4, 5) |
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
| def test_shuffle(n, shuffle): | |
| """ | |
| Test a shuffle function. | |
| """ | |
| res = dict() | |
| for i in xrange(n): | |
| list = ['A', 'B', 'C'] | |
| shuffle(list) | |
| res[''.join(list)] = res.get(''.join(list), 0) + 1 | |
| print res |