Skip to content

Instantly share code, notes, and snippets.

mysql> pager less; # use less for paging
mysql> SELECT * FROM something \G #one field per line (good for wide tables)
@mbylstra
mbylstra / gist:7727307
Created December 1, 2013 00:57
kill those wayward uwsgi processes that don't want to die with just killall
killall -SIGKILL uwsgi
import traceback
try:
#some code
except Exception, e:
print ''.join(traceback.format_exception(*sys.exc_info()))
@mbylstra
mbylstra / gist:8050451
Created December 20, 2013 04:35
get a progress bar for large mysql imports and dumps
pv sqlfile.sql | mysql dbname
@mbylstra
mbylstra / log uncaught exceptions.py
Created May 7, 2014 01:11
log uncaught exceptions
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
@mbylstra
mbylstra / gist:803de31188705dc658b0
Last active August 29, 2015 14:05
git: tell me which commits are in branch_b but not branch_a
git log branch_a ^branch_b --no-merges
@mbylstra
mbylstra / gist:1409f46992c81b6f0e6e
Created August 22, 2014 07:57
recursively sort python files by number of lines of code
find . -name '*.py' | xargs wc -l | sort -k1 -rg | less
@mbylstra
mbylstra / gist:415501b38544d1e6db02
Created August 27, 2014 02:12
show me nginx access.log 500's with surrounding 10 lines.
awk '{ print $9, $7}' access.log | grep -C 10 '^500'
@mbylstra
mbylstra / gist:9412f80ffcaad3d76474
Created October 5, 2014 09:11
remove all .pyc files recursively
find . -name "*.pyc" -exec rm '{}' ';'
@mbylstra
mbylstra / django_manage_daemon.yml
Created October 8, 2014 12:37
An Ansible playbook for daemonising long running django manage.py commands using runit
---
- hosts: django
user: root
vars:
- runit_app_dir: /etc/sv
- runit_enabled_dir: /etc/service
- dj_manage_daemons:
- slug: "unique_name_slug_1"