This file contains 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
redis-cli KEYS "prefix:*" | xargs redis-cli DEL |
This file contains 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
mysqldump -u user_name -p password --no-data --add-drop-table database_name | grep ^DROP | mysql -u user_name -p password database_name |
This file contains 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.core.cache import cache | |
# Here, you can centralize sanitation of cache key. | |
# There was a python memcache bug were spaces in keys were generating exceptions, so we replace it | |
# You could add any other code to fix keys here | |
def sanitize_cache_key(cache_key): | |
key = cache_key | |
if key and len(key) >0: | |
key = key.replace(' ','%20') | |
return key |
This file contains 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
DISCARD = [ | |
'utm_source', | |
'utm_medium', | |
'utm_campaign', | |
'utm_term', | |
'utm_content', | |
] | |
def strip_url_tracking(url): | |
""" | |
Removes Google Analytics codes from URLs |
This file contains 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 checkout --theirs filename_path | |
git checkout --ours filename_path |
This file contains 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
mysqlslap --delimiter=";" --create-schema=my_db --user=root --query="SELECT * FROM app_table" --concurrency=100 --iterations=20 | |
# Ref: http://serverfault.com/questions/285547/how-can-artificially-create-a-slow-query-in-mysql | |
# Ref: http://dev.mysql.com/doc/refman/5.1/en/mysqlslap.html |
This file contains 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 | |
def get_string_logger(logger_name, level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", debug_db=False): | |
""" | |
Gets you what you need to log to a string. Returns a pair of StringIO, logger variables. | |
>>> output, logger = get_string_logger('my_app_logger', level=logging.DEBUG) | |
>>> call_stuff_to_debug_with_logger(logger=logger) | |
>>> print output.getvalue() | |
""" |