Wednesday, December 19, 2007

and...

needing to send mail from within a batch file...(no 'mail' app like on nearly all unix) no, I don't want to mess with MS mail profiles etc...blat works well. I even managed to get it going as a non-administrator.

datestamps

hooray. I have a new job doing server/middleware support. Even better: a co-worker asked me to do something - convert a unix shell script to run on a Windows 2003 server. Aside from the lines dealing with an Oracle client - they want a datestamp in the reports:

from the familar unix one-liner:

now =`date +'%Y%m%d%M%S'`

to the following horror:

REM generate timestamp!

@for /F "tokens=2,3,4 delims=/ " %%A in ("%date%") do @(
set day=%%A
set month=%%B
set year=%%C
)
@for /F "tokens=1,2,3 delims=: " %%A in ("%time%") do @(
set hour=%%A
set minute=%%B
set sec=%%C
)
REM cleanup the seconds string
@for /F "tokens=1* delims=. " %%A in ('echo.%sec%') do @(
set sec=%%A
)

set timestamp=%year%%month%%day%%hour%%minute%%sec%

& of course, this will break if the locale is not Australian dates...yuk. Hope I'm not being naive in that. A solution might be to do more in VB (which I do know) or install Perl on everything.

Monday, December 17, 2007

age-old vi/vim question

how to make the arrow keys work in insert mode. Another one that I probably fix a few times per year & then forget how to do. Irrespective of whether this is a good idea or not: adding ":set nocompatible" to your .vimrc file fixes this. This appears to work on ubuntu & Red Hat Enterprise.

Sunday, October 28, 2007

mount

more notes to self:

to mount an ISO image:
mount -o loop -t iso9660 image.iso /path/to/mount/point

to remount a disk mounted read-only
mount -o remount rw file-system

good old: mount -a

Wednesday, October 24, 2007

sortable directories

Let's say that you have generated directories full of images from some app like Pure Data. This is pretty basic stuff but easy to forget.

Basically - files with names in a format like file001.jpg, file002.jpg...

In PD, simply provide an sprintf-style argument like: "/file/path/frame%03d.jpg" to the 'makefilename' object. Magic.

opendir DIR, $inPath or die "cannot access $inPath\n";
@imageFilenames = sort(grep{$_ ne '.' && $_ ne '..'} readdir DIR);
closedir DIR;

Without the sort function above, the order of filenames in @imageFilenames will be farily random. That's no good if you want to maybe run through a time series of image.

You may want to append the full path to each filename entry:

my ($i, $z) = (0,0);
foreach $z (@imageFilenames) {
$imageFilenames[$i] = join("", ($inPath, $z));
print "$imageFilenames[$i] \n";
$i++;
}

To shuffle this sorted array:

use List::Util 'shuffle'; # requires Perl 5.8 or later

my @shuffledFilenames = shuffle(@imageFilenames);

Or just omit the orginal sorting function perhaps.

Monday, October 1, 2007

bookmarklets

this is a little bookmarklet test

alta vista

how is this revolutionary? well, it's not in that simplistic form. The idea is in being able to launch more sophisticated stuff embedded in an URI

Search Alta Vista...

there's got to be more than just that of course. I was just curious