Tuesday, June 26, 2007

vmware networking - wireless bridge, nat problems

I was setting up a vmware image of Ubuntu Feisty the other night and I had a heck of a time with the networking. I went through and tried bridged, nat and host-only. I couldn't get bridged or nat to even talk to the host computer. host-only could talk to the host, I could even get it to NAT to the wifi-router, but I couldn't get it to go past that.

I wiped that image and redid the work and now I've got it working. The first basic problems was that I didn't look in dmesg. On ubuntu, it's necessary to use vmware-any-any to get vmware to work with the Ubuntu kernels (or something, in any case, something doesn't work, maybe compiler issues, and it's necessary to patch with vmware-any-any so that the vmware modules will compile).

After I finally looked in dmesg, there was a section that said that vmware bridge over a wifi device doesn't work with vmware-any-any. OK, next up was nat.

That didn't work either. It wasn't until I rebuilt the image (in fact, uninstalled and reinstalled free vmware-server) last night that I finally got nat working. Previously I had used vmware-config.pl to edit the networking settings (using the editor) and I had decided to always use vmnet0 for the bridge, and then later the nat, and later host-only and then, in the vmware client, chosen BRIDGE, NAT, HOST-ONLY as appropriate. That doesn't always work because apparently vmware has some sort of mapping for the vmnet numbers. Choosing NAT but having manually edited it at vmnet0 makes it not work because NAT starts at around vmnet8.

The trick, I found last night, was to select CUSTOM and then select the correct /dev/vmnet[0-9] entry. I've got networking working now (NAT though, since bridging on a wireless device still doesn't work) and have got the rest of the project done (install oracle 10g express edition with a small sample database, for use by my team in testing an oracle application we're developing for a large government owned corporation).

Oh yeah, and to solve it without a trick (i.e., canonically), just use the network connection wizard. It'll choose the correct number for the vmnet device type that you want to use. I like having things numbered sequentially though, which is why I got into trouble in the first place.

Sunday, June 24, 2007

Oracle bogosity - no boolean column type

Oracle has no boolean column type. That is, in a create table statement, you can't say:
MY_BOOLEAN_COLUMN boolean
I've seen some discussion of this and most of it boils down to what Tom Kyte says, that you don't need a boolean type since you can use an integer(1/0), a character(T/F,Y/N,even 1/0) or anything you like. I suppose you could use varchar(5) and use "true" and "false".

For a while I accepted this explanation, until I ran across an oracle database that had boolean types using all of these conventions (in different tables, although I did see T/F and Y/N for different columns in the same table!).

Of course it was implementer error that they didn't use check constraints on those pseudo-boolean fields. So in the integer field, it was possible to set the "boolean" to 314. and in the character fields, well, it was possible to have T/F/Y/N/1/0 all in the same column (fortunately, the character field was limited to one character, else I would have had even more fun with that stupidity).

I suppose Oracle is that way (bogus) because of legacy code, compatibility issues, and inertia. I can see internal discussions going sort of in the direction of creating a boolean type but stopping short of actually doing so because it just seems so hard, or no one wants to rock the boat and introduce potential compatibility issues (e.g., when oracle software uses boolean, and then won't work with oracle installations which didn't have the boolean type).

Another problem, of course, is that anyone confused enough to use all those different encodings for pseudo-booleans, and worse, IN THE SAME COLUMN with no check constraints, is going to continue being confused when the boolean type is introduced. They won't use the boolean type, they'll continue using their iodine-deficiency-generated solution. But just because idiots will continue in their idiocy is no reason to avoid doing the right thing. As it is, when a boolean field is concerned, there's going to be a discussion as to which convention to use and then there's going to be a random choice (unless the shop in question has advanced to the point of having a convention for boolean fields, in which case I say, bravo). If a true boolean column type were available, the canonical answer would be to use that. Iodine-deficient DBAs could still use their non-boolean hacks, but at least a canonically correct solution would exist, guiding iodine-sufficient (but trained by incompetent or iodine-deficient DBAs) in the right direction.

Friday, June 22, 2007

auto-convert images for blog

Sol and I take a lot of pictures. The camera automatically names them (with zero prefixed integer sequential filenames) but it's very easy for filenames to collide (two different days can have 000001.jpg files). I also take pictures at a rather high resolution. The resulting images take up a LOT of space.

I wrote a shell script that, with the help of GraphicsMagick (or ImageMagick) takes all those jpgs and creates two files, one a thumbnail (ending in -th.jpg) and one a large images (ending in -1024.jpg). The date of file transfer (from camera to laptop) is prepended to the image name so that filename collisions become impossible.
irec
I originally put the thumbnails and -1024 files in separate directories. Now I put them in the same directory so that the files are easy to upload to photobucket (they're in the same directory, so clicking on the Browse to select an image button brings me to the same directory. It's very easy this way to upload the thumbnail and the -1024 together).

I still keep the thumb directory around but I populate it with links from the "smaller" directory. Keeping thumb around doesn't really make sense anymore. It's not like I have programs or scripts that depend on existence or contents of that directory. Just laziness, I guess.

If the script were named "picstoblog" (see below) I would do something like the ff to process all the directories in my Pics directory.

for fn in *
do
if [ -d $fn ]
then
pushd .
cd $fn
picstoblog
popd
fi
done


----
picstoblog script below, some things could be improved (mainly be simplifying/eliding, e.g., thumb), but i don't care enough to actually do the fixes)
-----

#!/bin/bash

if [ ! -d thumb ]
then
mkdir thumb
else
rm -f thumb/*
fi

if [ ! -d smaller ]
then
mkdir smaller
fi

for fn in *.jpg
do
base=`basename $fn | cut -f 1 -d '.'`
d=`pwd | cut -f 1-3 -d "-" | sed "s/-//g"`
d=`echo $d | basename $d`

sm=$d-$base-1024.jpg
th=$d-$base-th.jpg

if [ ! -f smaller/$sm ]
then
gm convert -scale 1024x768 -quality "70%" $fn smaller/$sm
fi

if [ ! -f smaller/$th ]
then
gm convert -scale 200x150 -quality "50%" $fn smaller/$th
fi

# for older files, remove if already there so can link
rm -f thumb/$sm
ln -s smaller/$sm thumb/$sm
ln -s smaller/$th thumb/$th
done

Sunday, June 10, 2007

php-oracle bogosity #1

That's not #1 as in it's the worst of its kind. I'm very new to playing with oracle on php, and it's only Oracle 10g Express Edition, so I am definitely not saying anything about oracle in general.

This might even be just a php-oracle thing, not necessarily in the oracle API at all (i tried to read that, got bored and came to no conclusion). In any case, I wasted a few days on this. I'm on vacation and getting online to fix something involves going to the internet cafe in the city. I only do that once a day. Of course, reading the documentation of oci_fetch_array would have helped :-), but I didn't realize oci_fetch_array could be this bogus.

In PHP, oci_fetch_array takes as parameters a resource statement (result of oci_parse) and some integer parameters. Apparently, Oracle (or the PHP-OCI8 library anyway) by default will not return null columns. It's necessary to specify OCI_RETURN_NULLS if you want null columns in the returned row. This is just bogus though. What does it cost to return some extra array entries, after all. Particularly if they're null or empty (which is a separate pure-oracle bogosity for later). It certainly creates an unnecessary asymmetry to have rows sometimes be 10 columns and sometimes 12 depending on whether certain columns in the returned row are null.

Monday, June 04, 2007

Maybe catching up

I've been away from mailing list email for months because the pressures of work don't allow me to even scan, let alone post, mailing lists. That's too bad. I really enjoy reading on the postgresql-general mailing list, for instance, since there's so much to learn and the signal to noise ratio there is incredibly high. On Plug I think the SNR has also been improving. But I'm not sure about that since, well, I just haven't been reading it. I've looked there once in a while and there seems to have been some improvement.

I'm going away for a two-week vacation with my family. We'll be in Cagayan de Oro, Duka Bay, and Camiguin. CDO, to visit, to prepare for timmy's baptism, and for the actual baptism, Dukay Bay for a break. My parents and brothers and sisters have been there many times, I never have, so we'll go. I may dive there, if they've got a mask with the right corrective lenses. If not, I'm sure we'll be going on the glass bottomed boat.

On camiguin, of course, we'll be diving No camiguin adventure tours> for us though. I've done most of them and timmy can't go with us. I'm really looking forward to diving. Sol hasn't been to Sunken Cemetery or Canyons yet and we've got a divecase now to go with the digital camera, so I want to take a lot of pictures :-). I don't know if the pictures will be good. Visibility might not be so great during rainy season, but it'll be great to take our own dive pictures and videos. Sol wants to do a night dive. That'd be great. The last and only time we did that, it was for qualifying for PADI advanced open water diver. It'll be good to do it again without having to worry about exercises, etc. The last time we had a really great time. There were incredible numbers of lionfish (I guess they come out at night, they're a common sight on camiguin, but they were really out in force that night, we even saw two that were doing the deed, or would have been, if they were mammals :-) and a huge cuttlefish, among a lot of other things. I can't wait to do that again. twice :-).

Oh, wait. This was about catching up. I get carried away sometimes. Back on topic, I'll have two weeks of free time. I'm sure I won't be in front of the laptop the whole time (although sol and I are both bringing laptops, we'll be working too while away) but I'll certainly spend 2 or 3 hours a day catching up.