quiet software blog http://blog.quiet.sh Short notes from a busy programmer posterous.com Fri, 26 Aug 2011 07:11:50 -0700 Commands and keys for a 3-way merge in vim / vimdiff http://blog.quiet.sh/commands-and-keys-for-a-3-way-merge-in-vim-vi http://blog.quiet.sh/commands-and-keys-for-a-3-way-merge-in-vim-vi
Keep forgetting these and all the sites mentioning vimdiff tend to be focussed on comparing 2 files.

Buffers are numbered 1,2,3

Move to the next window: <c>+w <c>+w
Get diff from window 2 :diffget 2
Put diff into window 3 :diffput 3
Update all windows (it sometimes gets a bit out of sync) :diffupdate

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Sat, 09 Jul 2011 03:50:00 -0700 Getting to the middle of a large file http://blog.quiet.sh/getting-to-the-middle-of-a-large-file http://blog.quiet.sh/getting-to-the-middle-of-a-large-file

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>

Then I started a sort of binary search, starting with:
mid 200000 20 logfile.log
and visually checking if the information I wanted was there, this worked ok because I was looking for a specific date range, if I was looking for strings I'd have used
grep -ni "search-terms" logfile.log
-n prints line numbers for every match.
Once I'd found the section I was looking for
mid 453000 4000 logfile.log > logsection.log
Got me a new file that a text editor can handle.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Fri, 28 Jan 2011 02:28:53 -0800 Drop down terminals http://blog.quiet.sh/drop-down-terminals http://blog.quiet.sh/drop-down-terminals
I have an awful habit of opening new terminals every 2 minutes because I've left something running on the open one or I've left it behind a window on another screen.

As a way to keep them all in once place I've started using a lovely drop down terminal called Guake on Ubuntu. Named after the classic drop down terminal in the game Quake it has tabs, a fullscreen mode, and it toggles on F12.

$ sudo apt-get install guake

My Mac-wielding office cohorts seem to think that Visor is a decent alternative for that platform so if you're stuck using one of those pretty shiny things give it a go.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Tue, 28 Dec 2010 04:33:00 -0800 Emacs - browsing the kill ring http://blog.quiet.sh/emacs-browsing-the-kill-ring http://blog.quiet.sh/emacs-browsing-the-kill-ring

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))

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Wed, 24 Nov 2010 15:09:28 -0800 TIL http://blog.quiet.sh/til http://blog.quiet.sh/til In Ubuntu super + left or right arrow will switch between TTY sessions after you've broken out of the main X session with ctrl+alt+F1.

p.s. On most computers "super" is the windows key.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Thu, 11 Nov 2010 06:04:00 -0800 Emacs replace with newline http://blog.quiet.sh/emacs-replace-with-newline http://blog.quiet.sh/emacs-replace-with-newline

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

M-shift-%
><
>C-q C-j<

We're effectively just putting a line break between the > and  < so 

<xml_tag attr="random_stuff"><more_xml /></xml_tag>

becomes

<xml_tag attr="random_stuff">
<more_xml />
</xml_tag>

Not clever but it makes large bodies on text easier to break up sometimes.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Thu, 11 Nov 2010 02:08:00 -0800 Piping django commands into mysql http://blog.quiet.sh/piping-django-commands-into-mysql http://blog.quiet.sh/piping-django-commands-into-mysql

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.

Being a lazy sort I rarely feel like copying and pasting things about so here's how to pipe sqlclear straight into mysql:

python manage.py sqlclear [list of app names] | mysql -u [username] -p[password] -D [database name]

sqlflush doesn't take any arguments so:

python manage.py sqlflush [list of app names] | mysql -u [username] -p[password] -D [database name]

So, now we've sorted out how to get round what the Django guys were trying to stop please don't delete any of your data, and if you do tell your wife, kids or dog about it rather than me.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Wed, 16 Jun 2010 17:47:00 -0700 Delete svn and pyc files on linux http://blog.quiet.sh/delete-svn-and-pyc-files-on-linux http://blog.quiet.sh/delete-svn-and-pyc-files-on-linux

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 '{}' \;

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Tue, 15 Jun 2010 03:16:00 -0700 Converting an SVN repo to Mercurial http://blog.quiet.sh/converting-an-svn-repo-to-mercurial http://blog.quiet.sh/converting-an-svn-repo-to-mercurial

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)

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George
Wed, 28 Apr 2010 16:10:26 -0700 The plan http://blog.quiet.sh/the-plan-84 http://blog.quiet.sh/the-plan-84 Hi, if you're reading this I probably don't know you. I'm a programmer and this is the beginnings of my blog.

Quiet Software aims to write quality applications to help small businesses become a bit more efficient. I'll post bits of the internet up here that interest me, things I've learned, and news about projects in the pipeline.

Check back soon for more.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1278935/profile.jpg http://posterous.com/users/5AAXhK0FnXXj Ian George quietsoftware Ian George