If you would like to scroll horizontally with the cursor following the screen, you can use the following commands to scroll left and right.
zl - move the view [count] characters right
zh - move the view [count] characters left
Friday, August 29, 2008
Count Words
If you would like to count the number of words in the current Vim buffer, you can simply issue the following command: g CTRL-G (no space between g and CTRL-G).
Thursday, August 28, 2008
Nautilus MP3 Column Display
There have been a few instances when I've felt it would be useful to have Nautilus, Gnome's file browser, display MP3 metadata info. It's particularly nice when organizing large volumes of files by directory. KDE has had this functionality for a while, but it's been suspiciously absent from Gnome. I found a quick hack, which allows you to add metadata columns at will.
Nautilus MP3 Column Display
Nautilus MP3 Column Display
Daily Vim Song of the Week
I can't get enough of this song.
The Reigning Sound - Find Me Now
If anybody else has a song of the week, post it here ;-).
The Reigning Sound - Find Me Now
If anybody else has a song of the week, post it here ;-).
Uppercase, Lowercse, Swapcase
In Vim, you can use the following motions to modify the case of an entity.
Examples:
gum - lowercase text operated on by motion
gUm - uppercase text operated on by motion
g~m - switch case operated on by motion
~ - if notildeop is set (default), switch case under cursor
~ - if tildeop is set, switch case of {motion} text
Examples:
guw - lowercase current word
gU$ - uppercase to end of line
g~w - swapcase current word
v$~ - swapcase to end of line (if notildeop is set)
~w - swapcase of word (if tiildeop is set)
mk-table-checksum and Columns
UPDATE: I submitted a patch to the Maatkit developers, and the column bug mentioned below if fixed in SVN.
At work, we've been struggling with MySQL replication losing synchronization for the last few months. It's usually something like a few timestamps being off here and there, but we've also seen primary keys with artificially high values on the slave, certain replication events just not happening, and other weirdness. One toolset that has been very helpful in figuring out when problems occur is Maatkit. It a suite of tools written in Perl, which allow you to do things like run checksums on the master and slave for a given table, compare, and see if they're out of sync.
Unfortunately, some of the documentation is very sparse, which leads me to this blog entry. Google had nothing useful regarding how to use the columns feature, which allows the checksum to be calculated only on specific columns. I post this here in hopes it will help somebody.
We had been trying to use mk-table-checksum in the following way:
mk-table-checksum 127.0.0.1 -usomeuser -p'password' -tmydb.TableOne --replicate=maint.checksum --columns=UserID,TSAdded
Unforunately, running it this way would give a warning:
Use of uninitialized value in concatenation (.) or string at /usr/bin/mk-table-checksum line 431.
and produce no results. I finally got annoyed enough that I fired up the Perl debugger and stepped through what was going on. As it turns out, the data stored internally in $table->{cols} is all lowercase. If you pass in your column list camel-capped, or uppercase, it simply won't work.
The following invocation would produce useful results:
mk-table-checksum 127.0.0.1 -usomeuser -p'password' -tmydb.TableOne --replicate=maint.checksum --columns=userid,tsadded
Stupidly simple, but not necessarily obvious.
At work, we've been struggling with MySQL replication losing synchronization for the last few months. It's usually something like a few timestamps being off here and there, but we've also seen primary keys with artificially high values on the slave, certain replication events just not happening, and other weirdness. One toolset that has been very helpful in figuring out when problems occur is Maatkit. It a suite of tools written in Perl, which allow you to do things like run checksums on the master and slave for a given table, compare, and see if they're out of sync.
Unfortunately, some of the documentation is very sparse, which leads me to this blog entry. Google had nothing useful regarding how to use the columns feature, which allows the checksum to be calculated only on specific columns. I post this here in hopes it will help somebody.
We had been trying to use mk-table-checksum in the following way:
mk-table-checksum 127.0.0.1 -usomeuser -p'password' -tmydb.TableOne --replicate=maint.checksum --columns=UserID,TSAdded
Unforunately, running it this way would give a warning:
Use of uninitialized value in concatenation (.) or string at /usr/bin/mk-table-checksum line 431.
and produce no results. I finally got annoyed enough that I fired up the Perl debugger and stepped through what was going on. As it turns out, the data stored internally in $table->{cols} is all lowercase. If you pass in your column list camel-capped, or uppercase, it simply won't work.
The following invocation would produce useful results:
mk-table-checksum 127.0.0.1 -usomeuser -p'password' -tmydb.TableOne --replicate=maint.checksum --columns=userid,tsadded
Stupidly simple, but not necessarily obvious.
Labels:
analysis,
column,
maatkit,
mk-table-checksum
Wednesday, August 27, 2008
Bash, Re-writing a Line
There are instances when writing a shell script that you want to write to the same line over and over. This is mainly used for progress meters that update the same screen position over and over. Most languages represent a carriage return without newline as the \r escape sequence. In shell, it's no different, but there is one small caveat. The echo command requires two arguments.
The -n argument to echo tells it to suppress the implicit newline that it usually includes. The -e argument tells it to respect escape sequences such as \r.
#!/bin/bash
# simplest progress meter
items=100000
for ((i=0; i<$items; i+=1)); do
echo -n -e "Processed $i/$items\r"
done
The -n argument to echo tells it to suppress the implicit newline that it usually includes. The -e argument tells it to respect escape sequences such as \r.
Subscribe to:
Posts (Atom)