Mike Lambert's musings on programming, computer graphics, software reviews, writing and life.
Thursday, December 29, 2005
Hospitals Are So 1500s
Health care is the only business I know where customer service is uneccesary. Why? The answer is simple. No matter how bad their service, a hospital is not going to lose any business. In fact as long as they do not kill you they are almost guaranteed you will come back. This is especially true in areas with very few hospitals.
If you wonder why your medical bills are so high look no further than your local hospital's emergency rooms. You wait 3 hours to get a room (if you're lucky). Then 2 hours later a man comes in for some blood work. If you are unlucky enough to go towards the end of a shift the current shift is looking for a way to shift your case to the next shift. In other words be prepared to have to wait until 4 in the morning to get admitted to the actual hospital from the emergency room if you come in past 8 in the evening be prepared to wait as people shuffle you from person to person like some strange inefficient ballet.
Then, when you do get your room be prepared to be interrupted every hour on the hour as your vitals get checked, blood drawn, etc. Then be prepared to wait for the next afternoon for a Doctor to actually dain to come and release you from the hospital. All in all hospitals are prime example of human stupidity, laziness and inefficiency. Then we wonder why a basic hospital visit costs $1000 a day. I don't have to wonder anymore.
If I ran my businesses like hospitals are run I would not have a business.
Tuesday, December 20, 2005
Merry Xmas
Monday, December 19, 2005
Inconvenient Temp Files
# This program get's rid of all the files matching regex $regex (ckz_* in our case)
# temp files for user ARGV[0]
use File::Path;
my $user = $ARGV[0];
my $regex = $ARGV[1];
my $temp_dir = "C:\\Documents and Settings\\$user\\Local Settings\\Temp";
if (-d $temp_dir) {
opendir(DE,$temp_dir);}
my @all_files = readdir(DE);
foreach $file (@all_files) {
# Make sure file is not a directory
$entry = "$temp_dir\\$file";
if (-d $entry) {
if ($entry =~m/$regex/i) {
print "DELETING ENTRY: $entry\n";
rmtree($entry);
}
}
}
closedir(DE);
else {
print "Directory $temp_dir Does Not Exist!";
}
Friday, December 16, 2005
The Travails Of Using SMS Messaging To Communicate Server Downs
Perl came to the rescue yet again. I remembered that the T-Mobile website (our cell service provider) had a web page you could use to communicate with T-Mobile cellphones. You only needed an existing account setup on their site (with your mobile number and a password).
Armed with this knowledge I started using Samie and Win32::GuiTest to automate Internet Explorer to do the whole process automagically. Samie is a great package but it does have some issues. Some of the procedure calls do not work as expected. I've posted a modified version that works with my code at:
http://www.streamload.com/lamberms/Sam.pm
Anyway, here is the code solution to do SMS messaging. It comes in two parts, tmobile_sms.pl and kill_ie.pl. You call tmobile_sms.pl with five arguments, your T-Mobile cell phone number, account password, T-Mobile phone number to sms, from information and the message. It then automates IE to go to the T-Mobile web page, log in and send the message. When it is done doing this kill_ie.pl kills the popup the T-Mobile web site pops up (Samie does not do this well) and closes IE. Here is the tmobile_sms.pl code:
use Win32::OLE;
$Win32::OLE::Warn = 3;
use Win32::SAM;
$| = 1;
my $URL = "https://my.t-mobile.com/Communication/";
my $IEDocument;
my $seconds;
my $account_mobile_num = @ARGV[0];
my $account_mobile_pass = @ARGV[1];
my $mobilenum_to_page = @ARGV[2];
my $from_text = @ARGV[3];
my $msg_text = @ARGV[4];
if (@ARGV[0] eq "" || @ARGV[1] eq "" || @ARGV[2] eq "" || @ARGV[3] eq "" || @ARGV[4] eq "") {
print "Invalid Command Used. Command Should Be Formatted Like:\n";
print "tmobile_sms.exe your_cell_phone_num your_cell_phone_pass cell_phone_to_sms from_text msg_text\n";
exit;
}
StartIE();
$seconds = Navigate($URL);
print "First Page took $seconds seconds to load\n";
SetEditBox("txtMSISDN",$account_mobile_num);
SetEditBox("txtPassword",$account_mobile_pass);
ClickImage("https://my.t-mobile.com/images/mytmobile/ph/buttons/leftp.gif",0,1);
print "Second Page Loaded In $seconds.\n";
while (not VerifyTextPresent("SELECT A PHONE")) {
print "Select A Phone Text Is Not Present\n";
sleep(1);
}
$seconds = Navigate($URL,0,1);
print "Third Page Took $seconds seconds\n";
while (not VerifyTextPresent("Characters left")) {
print "Characters left Text Is Not Present\n";
sleep(1);
}
SetEditBox("txtNum","$mobilenum_to_page");
SetEditBox("txtFrom","$from_text");
SetEditBox("txtMessage","$msg_text");
$seconds = ClickImage("https://my.t-mobile.com/images/mytmobile/ph/buttons/left.gif",0,1);
if (-e ".\\kill_ie.exe") {
exec(".\\kill_ie.exe");
}
if (-e ".\\kill_ie.pl") {
exec(".\\kill_ie.pl");
}
exit;
And here is the kill_ie.pl code:
use Win32::GuiTest;
$| = 1;
my @windows = ();
my $time_counter = 0;
while ($#windows == -1 && $time_counter < 121) {
@windows = Win32::GuiTest::FindWindowLike( undef, "^Microsoft Internet Explorer", "","",5 );
$time_counter++;
print "Looking For Popup Window\n";
Win32::Sleep(1000);
}
if ($time_counter == 120) {
print "FAILURE Finding Microsoft Internet Explorer Window!!!!\n";
exit;
}
else {
if ( !bring_window_to_front( $windows[0] ) ) {
print "* Could not bring to front $window[0]\n";
}
my @enterbutton = Win32::GuiTest::FindWindowLike( undef, "OK", "Button" );
if ($#enterbutton > -1) {
#Click OK Button
Win32::GuiTest::SendKeys("~",1);
Win32::GuiTest::SendKeys("%({F4})");
print "Clicking OK Button\n";
exit;
}
else {
print "Could Not Click Enter Button\n";
exit;
}
}
exit;
sub bring_window_to_front {
my $window = shift;
my $success = 1;
if ( Win32::GuiTest::SetActiveWindow($window) ) {
print "* Successfully set the window id: $window active\n";
}
else {
print "* Could not set the window id: $window active\n";
$success = 0;
}
if ( Win32::GuiTest::SetForegroundWindow($window) ) {
print "* Window id: $window brought to foreground\n";
}
else {
print "* Window id: $window could not be brought to foreground\n";
$success = 0;
}
return $success;
}
Thursday, December 15, 2005
Mono Is A Game

After my last blog entry on Mono the development environment I thought it would be appropriate to talk about my new game obsession, Mono. In this game you go around shooting simple spheres and collecting powerups that increase the power level of your shots. All of this is happening to a simple techno score and it just ROCKS! It is like asteroids with a twist and I cannot get enough of it. I think you might like it as well.
Wednesday, December 14, 2005
Orange Is Not Just A Fruit Anymore

For a long time now I have been fascinated by the use people make of such open source tools as Blender, Povray, Audacity, etc. Put together, these excellent 3d rendering and sound packages make it possible for the end user to produce Pixar quality short films. As proof, I offer up Project Orange. This is a project to use Blender and other open source tools to produce a short film. The blogs on this site give quite a bit of insight as to what it takes to produce creative works with free tools. It makes for interesting reading.
Tuesday, December 13, 2005
Mono Is Cool In Concept
Monday, December 12, 2005
I've Been Dug
http://digg.com/programming/Resize_And_Markup_PDFs_For_Free
Welcome diggers ;-)!
Friday, December 09, 2005
Resize And Markup A PDF For Free (Well If You Have The .Net Dev Environment Anyway)
To get this working:
- Create a new Console Application VB .NET project
- Set a reference to the ITextSharp dll (found from the ITextSharp link above)
- Set the startup object as the Main subroutine in the code
- Build the project
- Source PDF file
- Destination PDF File
- Operation - Resize or Markup
- The size for the destination PDF (A,B,C,D,E,A3 or A4) or the markup text
Thursday, December 08, 2005
Stay Tuned
Wednesday, December 07, 2005
Playing With PDFs Programmatically
1. Perl - PDF::API2
2. Java - Itext
3. .NET - ITextSharp
With these libraries on your side PDF manipulation ceases to be a chore and becomes fun (OK, well tolerable then).
Monday, December 05, 2005
Christmas Times A Coming
I wish instead of remembering this I was experiencing it now.
Friday, December 02, 2005
My Head's In The Clouds

I am not usually a fan of games that don't involve First Person Shooter characteristics. That may explain why I came to Cloud with low expectations. I thought I would find boredom, instead I found a non-linear, entertaining and engaging game. Give it a check out.
Thursday, December 01, 2005
Just Curious
Spyhunter Rides Again

Remember the SpyHunter arcade game? I do. I remember how it bankrupted my tight budget as I tried to stay one step ahead of the enemy vehicles and ended up feeding quarter after quarter into the darn machine.
Thankfully, with the Internet, I have an alternative to bankruptcy and it's called Highway Pursuit. This freeware game is basically SpyHunter for a Windows machines and has the advantages of being free and a lot prettier than the original. Check it out for some good ol' fashioned fun.
Wednesday, November 30, 2005
Who Still Runs DOS ... I do, I do!

It is an unfortunate fact of my life that I still have to use DOS applications ... frequently. I recently was called in to look at replacing an old drawing log system still in use at my company. The goal was to replace its functionality and put it in our company portal. There was only one problem with this ... how to get the data out of the system? The old Drawing Log System was written in Turbo Pascal 6.0. That's right folks, Turbo Pascal ;-). All of the data files were in a binary format and we did not have the source code. Bummer. To make matters worse it did not run reliably on anything besides an older system (original Pentium class or older).
This is where DOSBox comes in. DOSBox emulates DOS (machine and all). It runs not only on Windows but also on Linux. You can even emulate older PCs by setting up how many operations per second it emulates. After I fired up the program in DOSBox it worked reliably and I was able to save the Drawing Log files to text files (after some wrangling). If you are having problems running DOS games or applications, DOSBox is for you.
Tuesday, November 29, 2005
EverNote - A Review

I've seens a lot of organizer programs come and go over the years. I've used a lot of them and the ultimate test in how useful they are is how long I can stand to use them. If they are a toy then typically they last about a week. If they are marginally useful they might last a few. If they are very useful they might hang around as long as EverNote.
EverNote is not everything to every person but it sure has taking notes, tasklists, etc. down cold. I have set up many to do lists, etc. in the program and I just keep coming back for more. With search, categorization, image pasting and many more features than I have the time to name EverNote is worth your time to check out.
Monday, November 28, 2005
Grease Lightning

I'm not much of one for time wasting games. I play maybe 5-10 hours a week (and have to squeeze that in around a lot of other things). However, recently I have started playing a game called Lightning Break. Lightning break is a game of skill with pool balls. The object is to put balls into the pockets in a specific order (depends on the round). It sounds simple but aren't all the really fun things in life. I truly suggest this game as a lunch time time waster.
Wednesday, November 23, 2005
Unless I Get A Wild Hair
Unless something dramatic comes to me, I'm starting off my Thanksgiving Holiday and will not be writing until next Monday (Nov. 28, 2005). I wish all the Americans out there a very Happy Thanksgiving. To all the rest of you, Happy Days ;-).
-Mike