I've been dealing with some fairly big log files recently, most of them over 100mb and text editors don't really like loading up files that large. Fortunately from I found a way to move forward from http://www.fastechws.com/tricks/unix/head_tail_mid_files.php I created a script called mid:
</div> <div>#!/bin/sh</div> <div>if test $# -lt 2; then</div> <div> echo "$0: insufficient arguments on the command line." >&2</div> <div> echo "usage: $0 startlinenum numlines [filename]" >&2</div> <div> exit 1</div> <div>fi</div> <div>tail -n +$1 $3 | head -n $2</div> <div>exit $?</div> <div>
mid 200000 20 logfile.log
grep -ni "search-terms" logfile.log
mid 453000 4000 logfile.log > logsection.log
The browse-kill-ring in debian/ubuntu emacs-goodies can be set to run when you use M-y without having yanked anything first. It displays a list of everything in the kill ring in an extra buffer allowing you to choose what to yank from a list rather than yank something then cycle through the rest with M-y.
Great if you have a bad memory like me. Set it up with:
sudo apt-get install emacs-goodies-el
Then stick this in your .emacs
(when (require 'browse-kill-ring nil 'noerror) (browse-kill-ring-default-keybindings))
I've always had trouble replacing things in emacs with newlines, for example here's how to spread out an xml file with no whitespace
Some of the management commands in Django (sqlflush and sqlclear spring to mind) rather understandably don't act straight on the database as they delete large amounts of data. They instead print out the sql commands for you to use at your leisure.
python manage.py sqlclear [list of app names] | mysql -u [username] -p[password] -D [database name]
python manage.py sqlflush [list of app names] | mysql -u [username] -p[password] -D [database name]
Just a quick note so I've stored this somewhere - keep forgetting it.
find . -name ".pyc" -exec rm -rf '{}' \;find . -name ".svn" -exec rm -rf '{}' \;Had the need to convert an SVN repository to Mercurial last night. Here's how the magic went down.
easy_install hgsvn
/usr/local/bin/hgimportsvn http://repository.url/folder
cd folder
hgpullsvn
find . -name ".svn" -exec rm -rf '{}' \;
hg push [repo url]
That was it. Dead easy. Hope that helps someone (or me next time I need it)