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
| git log branch_a ^branch_b --no-merges |
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 logging | |
| logger = logging.getLogger('some_logger') | |
| def log_uncaught_exceptions(*exc_info): | |
| logger.critical('Unhandled Exception:', exc_info=exc_info) | |
| sys.excepthook = log_uncaught_exceptions |
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
| pv sqlfile.sql | mysql dbname |
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 traceback | |
| try: | |
| #some code | |
| except Exception, e: | |
| print ''.join(traceback.format_exception(*sys.exc_info())) |
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
| killall -SIGKILL uwsgi |
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
| mysql> pager less; # use less for paging | |
| mysql> SELECT * FROM something \G #one field per line (good for wide tables) |
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
| CREATE DATABASE some_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; |
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
| SET foreign_key_checks = 0; | |
| DELETE FROM users where id > 45; | |
| SET foreign_key_checks = 1; |
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 django.db import connection | |
| from django.db.backends.mysql.base import DatabaseOperations | |
| def py_datetime_to_mysql(d): | |
| db_ops = DatabaseOperations(connection) | |
| return db_ops.value_to_db_datetime(d) | |
| #eg: | |
| from django.db import connection | |
| py_datetime_to_mysql(datetime.now()) |
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
| #modified version off http://code.activestate.com/recipes/576602-safe-print/ | |
| def sprint(*args, **kwargs): | |
| """Safely print the given string. | |
| If you want to see the code points for unprintable characters then you | |
| can use `errors="xmlcharrefreplace"`. | |
| """ | |
| errors = kwargs.get('errors', 'replace') |