Tuesday, December 20, 2005

ACME license maker
I always wondered how my nick names would look on a license plate, at this site you can create your own license plate on line for the state you live in (US and Canada) or any other state, the site has a preview image that you can save and put anywhere you want, i.e. your web site
the only thing the site doesn't do is to actually let you get the license plate, just the image =oP
but in case you wanted to get your own license plate, at least you would know exactly how it would look =o)

Tuesday, December 13, 2005

Five day week, get prior day function

I wrote a program that requires to get the prior day, based on a five day week, so for :
Saturday..Monday, return previous Friday
Tuesday..Friday, return previous day

of course you could do it using if statements, or a case statement, but I wanted a simple and elegant, single line kinda thing, in other languages like C this would've been easier, because you can basically embed if statements in one line using ?, but in Delphi I tried different things and finally came up with this

//include DateUtils in the uses
function FiveDayWeekPriorDayEx(const theDate:TDateTime):TDateTime; const
ar:array[1..7] of Byte = (3,1,1,1,1,1,2);

not bad, but I can probably do something with bits to come up with a shorter answer

Monday, December 12, 2005

DLL Help database
today someone was wondering where this dll came from, and I knew there was a site at Microsoft where you can find information about any (Microsoft) DLL, so I'm posting this here as a reminder for my self, and perhaps anyone who doesn't know about the site


you can enter the DLL name and it will tell you on which packages it was included, etc, so you could find other DLLs that might be related as well and avoid many headaches

I use this utility myself to find any missing references, there's no "it works on my machine" excuse

Friday, December 02, 2005

The power of a T-Shirt, check out this great story of how Trisha Weir made it to work at google

Wednesday, November 23, 2005

set the wallpaper in C# using IActiveDesktop SetWallpaper

someone was wondering how to set the wall paper using the SetWallpaper function and didn't find any examples on the web, I decided to give it a try myself, armed with PInvoke and some Delphi sample code I found on the web, I came up with this solution.

You have to create a bunch of interfaces, enums, structs, etc that are defined in the IActiveDesktop interface and were originally in the shlobj.h, so I decided to create a new class to put all this stuff

you can download the class file here
after adding that to your project and adding
using Windows.Native; to the top of your class file, is as simple as:
private void button1_Click(object sender, System.EventArgs e) {
IActiveDesktop activeDesktop = shlobj.GetActiveDesktop();
activeDesktop.SetWallpaper(@"F:\somepic.jpg", 0);

Friday, November 18, 2005

Workaround for the MSDN subscription login problem
if you're behind a firewall and you're trying to access the MSDN subscription site, you might get a "The page cannot be displayed" error when trying to login, the page it redirects you to login is something like

to work around that, and be able to login, first navigate to this site:

and login there using your passport information, then on the address bar paste this address:

you are now logged in to your beloved MSDN subscriptions =o) (notice the sign out button), to get to the main page you would normally get if you logged in normally, just click on the left on the "Manage Subscription" link

Thursday, November 17, 2005

Command-line reference A-Z
for those of you die-hard command line fans... ok, more for me to remember

Wednesday, November 16, 2005

do not press the red button
really, do not press the red button

Monday, November 14, 2005

Pandora let's you discover music you didn't know you liked

if you like listening to music you have to check out http://www.pandora.com, is quite a cool concept, is a small Flash Application that loads on your browser and lets you create radio stations based on your input, i.e. you enter an artist or a song that you like and from there Pandora gives you other songs that are similar in tones, rithm, etc from artists that you may even never have heard of but that you might like, you can create multiple radio stations of different styles of music, if you really like some song, you can even buy it from a link that is provided for each song, there's even music in spanish =o)

very nice marketing concept, you have to check it out

Thursday, November 03, 2005

MSN Messenger tabbed messaging (with Messenger plus)

if you use MSN Messenger and are not using Messenger Plus, you're missing a bunch, one of the features recently added is tabbed messaging, so you can have all your conversations in a single window just in different tabs, instead of having one conversation on each window

download the Messenger Plus from here:

and once you install it, in MSN Messenger main window go to the Plus! menu, Preferences, Instant Messages, Tabbed Chats, and check the "automatically group all my chats", or you can do it when you already have a conversation, on the Plus menu, Grouping options, group all chats (F9), the other nice thing, is when you are in tabbed mode, and you hit [ESCAPE] on your conversation, it closes that tab, and keeps all the other ones (just what I expected! =o) )

very nice work from the Messenger Plus team

if you are using Yahoo messenger, throw that away and try MSN Messenger with Messenger Plus!

Monday, October 31, 2005

Dynamic Einstein picture

check out this link

enter whatever text and Einstein will draw that for you in his chalkboard

Sunday, October 30, 2005

ready to start playing with Visual Studio 2005 and .NET 2.0

last night I finished burning and installing Visual Studio 2005 and SQL Server 2005, the install went very smooth and fast, I got the whole thing installed in about 40 minutes, I guess my Samsung H552A 16X DVD±RW helped a lot for this to happen

Now I feel like is almost starting over, there is so much to learn with .NET Framework 2.0, Visual Studio 2005 and SQL Server 2005, just to mention a few things, but is definitely exciting to be here at this time, and get to see how the technology is evolving and be part of that evolution, I think is a great opportunity for us developers to learn all this stuff right from it's birth and even during it's conception (Betas), we are learning today what future generations will learn and what will drive tomorrow's technology

now if you'll excuse me I gotta get busy playing with .NET 2.0 =o)

Friday, October 21, 2005

new search engine: exalead

check out this new search engine, it is REALLY nice, introduces many new concepts to the search arena, it shows that even though searching is simple, you can really make it richer in content and options without making it bloated, some of the features are (when you hit search):

- on the left side it has lists of: Related terms, related categories, web site location, document type
- on the middle section the results, with some links that redefine your search, also on this middle section, you can click on the result (but not on the link) and it presents a preview of the site a la Microsoft Outlook
- on the right side you see a thumbnail of the web page of each result

very nice concepts, the search engine may not be as powerful as google or msn search, but will definitely get attention and I'm almost sure that google and Microsoft will soon change their pages to have something like this

do we need yet another search engine? you bet! go try out your self

Thursday, October 13, 2005

Amazing optical illusions (or visual illusions)

check out this page, with (at the time of writing) 59 amazing visual illusions, and each one with an explanation of how it works, history of how/who discovered it, etc. very nice work put together

you can fint it here:

59 Optical Illusions & Visual Phenomena

I specially like these ones:
Frazer's Spiral

“Rotating Snake” Illusion

The 24 Hours of DeXter (Delphi, C++Builder and C#Builder)

Borland has announced another event similar to the last 24 hours of Delphi, it is scheduled for Monday, October 24, 2005. I hope this one goes better than last time, but we'll see

the official announcement is here:

24 Hours of DeXter (Delphi, C++Builder and C#Builder)

Tuesday, October 11, 2005

MSDN event in Salt Lake sold out
I was planning on attending the MSDN event in Salt lake today, we got there 5 minutes late, only to find out that the event had "sold out", the guy that was there explained that normally they get about 60% of people who register, to show up, but this time there was even people standing in the room
as we were waiting there just for a few minutes, people kept coming for the event, seems like .NET 2.0 will be more successful than a lot of people would like it to be. They gave us the DVDs containing the whole .NET 2.0 stuff (Visual Studio beta 2, SQL Server 2005, etc), we left our tickets there and they said we would have a priority seat for the next event in December, well see...
this much attendance reminds me of this... except, the exact opposite way, this single event, in a small city probably got more attendants than the 24 hrs of Delphi (at peak time) in the whole world =o(
Finally I am a Black Belt!
After 2 and a half years, last saturday I tested for my Taekwondo Black Belt, it was very hard, my whole body still hurts, but it was fun, and the Black Belt looks really cool

here are some pictures:
Black Belt test

Thursday, October 06, 2005

Free code translation from VB.NET to C# (and viceversa)

do you program in VB.NET and are trying to find example code for such or such thing but all you can find is C# example code (unlikely, but maybe is the other way around)?
don't worry, you can translate the code using this online tool:

CodeTranslator: Free Code Translation From VB.NET <-> C# (from your browser)

that's right, you just paste the code and it gets translated right there in your browser

quote from the site:
"This service will translate the code for you, just start typing the code or upload a file to translate it."

Tuesday, October 04, 2005

Parameters.Refresh might slow your application big time (Delphi + ADO)

I recently found that that by calling someADOStoredProcedure.Parameters.Refresh you might be slowing your application quite a lot, I use this method to retrieve the stored procedures parameters very often, I have used it for many years with no problems, then last week I came accross this problem where my application would work very well when executed against the local database, but really slow when executed against a remote server in another office.

I went through the "trouble" of adding counters to measure the time each part of my program was taking, to determine where exactly the problem was, and it did tell me what block of code was causing the problem, but I still couldn't see anything obvious, it was simple code to execute a stored procedure, I was still confused, because other parts of code also executed procedures, and so by looking very closely I saw that the other procedures weren't using the Parameters.Refresh; still not convinced that that was the problem, I decided to give it a try, and sure enough it fixed the problem, it dropped the execution time from 300+ milliseconds to 30+

so there you have it, be careful when using this method to retrieve your parameters, while it can be very useful, it might kill your application if it runs against a remote database

my solution to completly fix the problem, was to call this method once, and after that, make sure I populate all the parameters values, because that also can cause issues, if you don't call the .Refresh method, make sure that you update all the parameters values, or you'll end up with parameters data from your previous call, which can really mess up your data
freeware .NET visual components from obout inc

Danny just pointed to this site that contains some visual components for .NET, the components include:
- ASP Treeview
- Slide Menu
- Calendar
- New Postback (ajax based)
- Splitter
- EasyMenu

really nice components, work in all major browsers, and best of all, they are completly free!!
go check them out
obout inc

Monday, October 03, 2005

more news on Office 12: native PDF support!

it has been announced that Office 12 will have native support for the PDF format, it will be built into Word, Excel, PowerPoint, Access, Publisher, OneNote, Visio and InfoPath

so now you have the option of HTML, RTF, the new Open XML and PDF!... pretty cool, check more details here

Office XML Formats
Virtual Earth Shared Map (with MSN Messenger)

now you can navigate through a Virtual Earth map with your peers that are using MSN Messenger, simply use the Actions menu, Start Activity and select Virtual Shared Map, you then are prompted to enter your location (city, postal code, address), as each person navigates both users can see the changes, pretty cool add-in for MSN Messenger, try it out your self

Friday, September 30, 2005

measuring elapsed time for blocks of code (Delphi version)

in a production application quite often is nice to see how long each part of the program takes, i.e. you have an application that performs an operation on a database, then on some files, is nice (and useful) to see something like:

db access time: 120ms
file creation : 420ms

if you didn't have that information, and your program one day started working slow (perhaps after a Windows update), you would have no idea where the problem is, but by adding this small feature to your program, you know where you should focus to solve the problem:

db access time: 15000ms
file creation : 420ms

now, to create this information you tipically need to declare some variables:

DBLastTime:Cardinal; //stores the last time it took for this operation
DBTotal :Cardinal; //a sum of all the time it has taken
DBCount :Cardinal; //how many times the operation has been executed
DBAvg :Real; //average time for this operation (unless you wanted to calculate it every time)

I have seen countless times when developers start adding a set of those 4 variables for each operation that they want to measure on the application, and not only that, but also add code to capture the times:

SomeOperation; //
Inc(DBTotal, DBLastTime);
DBAvg:=DBTotal div DBCount;


this greatly bloats the code and makes it hard to see what the intent was, when all it is, is duplicated code, for such simple task

my approach is as follows:

I create a structure to store all the required values for an operation:

TTimeRecord = record
Total :Cardinal;
Count :Cardinal;
Avg :Real;

I have some constants:

TR_OPEN_DB = 0; //time it takes to connect to the database
TR_MOVE_ZIP = 2; //time it takes to move one zip


I declare an array of those structures

TimeRecords : array[0..TR_MAX_SITES-1, 0..TR_MAX_TR_COUNTS-1] of TTimeRecord;

on this example this is a bidimensional array, that I use to have counters on the same operations for both a local and a remote sites

by using those constants you an easily extend your code to add another operation that you want to measure

then I have these 2 functions to do all the "dirty" work:

procedure OpenTime(var timeRecord:TTimeRecord);

procedure CloseTime(var timeRecord:TTimeRecord);
Inc(timeRecord.total, timeRecord.lastTime);
timeRecord.Avg:=timeRecord.Total div timeRecord.Count;

and the code is simplified to:



of course you could go further and make this a class or a component, where you specify which controls are updated with the values, etc... but the idea here is to simplify a task

I hope you can use this technique, I'll post the C# version soon, that version should make things even easier, because we can use Static Classes there

Friday, September 23, 2005

what's new in Excel 12? more rows!

one of the most requested features of all times to MS Excel was to have more rows/columns, with the next version of Microsoft Office 12 products, Excel will have 1,048,576 rows by 16,384 columns

I wonder how long this will be enough

check the Excel blog here for more features coming in Excel 12
Creating a complete login screen in ASP.NET 2.0

Visual Studio 2005 has a series of controls for common tasks, like login, user creation, etc,
for example the login control makes it very easy to create complete login pages with a "create user wizard" page, without writing a single line of code, you just drop a login control and you get the appropiate labels, a text box for the login name, another text box for the password, even labels that indicate that you entered the wrong password, and of course you can change the text in any of those, or change the style by using CSS.
The login control can connect to any datasource (SQL, XML, etc) where you store the users/passwords, everything that you do today to create a login page, is already built-in in a single control, you get all that in a single control that has properties like DestionationPageUrl, that you use to redirect the user when it has been authenticated

check the video that shows all this:

Building a quick lookup screen in .NET 2.0

check this out:

nice!!... just like the ones Delphi has had for the last 10 years

Thursday, September 22, 2005

Windows Vista: Clarity in the user interface

you have to download this video and check this feature of Windows Vista, is awesome

Windows Vista: Clarity in the user interface
on passwords...

I don't know about you, but my passwords already have those =o)

Tuesday, September 20, 2005

googlebombing "failure"

a few days ago it was noted that if you enter "failure" or "miserable failure" in google and hit "I'm feeling lucky" you get the Biography of President George W. Bush, some people started saying that it had some political connotations from google. Then google replied in their blog that the cause of this was a googlebombing and they explain how this works, I quote from their blog:

Pranks like this may be distracting to some, but they don't affect the
overall quality of our search service

so nobody else is using this technique to get their site to the top right?
seems like google is broken, welcome to being #1

Monday, August 29, 2005

all day, no crashes:

Nick Hodges from the [TeamB] reports:
"I worked with Delphi 2005 yesterday for over 8 hours, and it didn't crash once, it performed marvelously, and I was well pleased to be using it. "

you can find the full "discussion" here:

obviously this caused all kinds of jokes and ironic comments, I specially liked this one:

"Sounds great, Nick. Maybe Borland could make that a selling point of the next version?
"Our cutting-edge IDE - now even better. Authenticated by TeamB to run for at least 8 hours without crashing." Eat your heart out, Microsoft.... "

now, on the serious part, that's, just plain bad and sad, when I need to create applications that run for months, and the development environment has been broken for a long time (Delphi 8 anyone?), and to get a bug fix (not all of the bugs fixed) costs you another 3,000 (Delphi 2005), and that still doesn't work right, and another bug fix will cost another 3,000, who has the money to keep up with buggy versions of software and why would you even bother?
I know from my company, we at least used to buy 200 licenses of Delphi, but that's gone, and I really don't think we'll magically go back to Delphi one day =o(

Friday, August 19, 2005

web services/FxCop gotcha: changing capitalization

I deployed a web service project yesterday and started testing and I was getting null response from the service, but of course when I was testing the web service on my machine it would work fine, so I started debugging and came to the conclusion that the test client was sending empty parameters to the service call, so I updated the web reference on the test project and everything started working on the production environment
After giving it some thought last night, I came to the conclusion that what caused this was that I put the web service project through FxCop and I had done some changes, and so I suspected that I had changed the signature of one of the functions, but only on the capitalization of the parameters, like
MyFunction(string TrackingID)
MyFunction(string TrackingId)

because that's what FxCop recommends, came in this morning, went to the source code repository to compare the actual version to one of the first versions and confirmed the above

so there you have it, be careful when using FxCop and changing the capitalization of variables around, if you change the capitalization of the parameters the call to the webservice/function will still work! but it will not return the expected results

Thursday, August 04, 2005

copy VPN profiles to another computer

yesterday I wanted to copy the VPN profile to my new computer (I use Cisco Systems VPN Client), because I had saved the group password and didn't remember what it was and didn't want to bother the company network guy late at night, so I started lookin in the registry for the domain vpn.mycompany.com, nothing, so I searched for Cisco, nothing... I thought I could somehow export that part of the registry to the new computer with VPN installed but could not find anything that looked like my connection

so I opened a browser to
C:\Program Files\Cisco Systems\VPN Client
then saw a profiles folder there, opened and there it was, myconnection.pcf, the name of the connection I used in my laptop to connect to my company, I didn't think it was that simple but decided to give it a try anyway, I copied it to my new computer under the same location, started VPN, and the connection showed up there, double clicked it and I was connected!

while that can be a *good thing* is definetely a security issue, pretty much any program that can read files on your machine could steal this file and get access to whatever access you have at your company, pretty scary...

Saturday, July 23, 2005

the magic and evil of the MTU

2 days ago I was trying to share the internet between my two XP machines and something strange happened, I would open www.google.com and everything was fine, I was even able to do searches on it, but most other pages did not open, I had already seen this before, even on my linux box, when sharing the internet from my XP box, to my Ubuntu box, so I started digging here and there, finally found some articles that described that the problem might be the MTU (maximun transmission unit), so I decided to give that a try and sure enough that fixed the problem
I guess google and some pages somehow break the packages into smaller ones, which cause them to work ok
to find out you MTU, you can just ping any site, specifying the size:
ping -t -l 1500 www.google.com
then, if that doesn't return, decrease the size, and keep doing that until you get a result back

then go ahead on open your registry editor (regedit.exe), navigate to:


(you may have more than one, find the one that matches the address 192.168.something)

if you see a MTU key there, modify it's value, it you don't see it, add it (DWORD), and put the value that you found out from pinging the site, this value however has to be hexadecimal value, so fire out the windows calculator and convert that number to HEX... you know, menu View, Scientific, put the decimal value, then click in Hex

you can find a lot more detail article here:

after you make the changes, reboot your machine and you should be good to go

to change the MTU in Linux, it would be something like:
sudo ifconfig en0 mtu 1400


Thursday, July 14, 2005

The 24 hours of Delphi

yesterday we had 24 hours radio live broadcast with interviews to BIG Delphi guys, anything from Marco Cantu to Danny Thorpe, it was pretty cool that they put all those guys together and the whole event was a good idea.
here's the announcement:

and you can find the recordings for the whole thing here:

the only thing that stroked me was that I checked how many users were on, and I saw up to 176, later some guys reported that they had about 300 listeners at peak times, and average of 150 at a time

300... that's kinda of (really) low for a worldwide event, isn't? or is it just me thinking this?

That's pretty sad for us, who have been Delphi developers for years and truly love Delphi, but this is reality, Borland is paying for the huge mistakes they did with Delphi 8 and Delphi 2005, and we will pay that price too. How many of you Delphi developers have moved to C# with Visual Studio? way too many I know.
Borland guys have to understand that Delphi.NET is not the #1 IDE for RAD and do something about it, they have lost a LOT of ground against MS products and even other vendors but WE are hoping that they are able to make it, unfortunately most of the developers work for companies, and companies don't like risks, and some companies bought Delphi 8, but did not buy Delphi 2005 because they got Visual Studio 2003 after the whole Delphi 8 mess, and will get VS 2005 instead of the next *killer* version of Delphi
and for many of us developers, the copy (of Delphi) that the company buys us is the only opportunity we have to get Delphi, so unless Borland comes up with a really really good product (way better than Visual Studio 2005 and before than VS 2005) and cheaper, I don't see how they would be able to come back with Delphi, I'm sure they'll still have a business with all the other products that they have, but I don't know about Delphi.

...and I really wish that time will prove me wrong on this one

Sunday, June 26, 2005

MonoDevelop in action

I got MonoDevelop working, I was even able to compile the ITextSharp library, here are some screenshots
and after cleaning up some warnings...

I also tested some asp.net applications with the included xsp web server
=o) cool!... and I just realized that there is no visual designer in MonoDevelop and there are quite a few things missing, but I can just write the stuff in Visual Studio, then move it to my Linux Box and run it from there, sweet!

Wednesday, June 22, 2005

Inserting an item on a dynamic array of records

Someone asked this question, I had never tried to do this before, but I didn't think it was difficult, here's the answer:

//first, we declare some record that we are going to use
TRecord = record

TMyDynArray = array of TRecord;

{$R *.dfm}

//the function to insert the record
procedure InsertToArray(var theArray:TMyDynArray; const InsertAt:Integer; const value:TRecord; const RecSize:Integer);
SetLength(theArray, Len+1);
Move(theArray[InsertAt], theArray[InsertAt+1], (Len-InsertAt)*RecSize);

//just something to test that the code actually works
procedure TForm1.Button1Click(Sender: TObject);


x:TMyDynArray; //here's our array
count, RecSize:Integer;
aRecord:TRecord; //the record to be inserted

SetLength(x, 5); //create a new array
x[0].value:='a'; //fill it with some values

RecSize:=SizeOf(TRecord); //get the size of one TRecord (used in the function to move bytes)

InsertToArray(x, 1, aRecord, RecSize); //call our function

//check that it actually worked
for count:=0 to Length(x)-1 do



Monday, June 20, 2005

finally after many headaches, including two Ubuntu reinstalls, I found out the easy way to get mono installed:


the detailed instructions are here:

the installer is just what you would be used to in Windows, simple "next, next, next, finish"

it even comes with Mono Develop, the whole thing, really to be used

at least I learned how to compile and install packages manually :)

next I'll be talking about my experiences with Mono Develop... I would like to install Chrome too


Friday, June 17, 2005

After a LOT of research I finally got Linux installed, I went with Ubuntu because is FREE and so far seems easy, has good support, they promise releases every six months, the community is amazing, I am yet to try the differences between GNome and KDE, but that'll be another story

I had my "new" machine (new because I just bought it:
Barebones Intel LGA775 DDR+AGP
· SPIKE Gaming Case 350W Silver/Black
· ASRock 775V88 PT880/Dual DDR/SATA/Lan/Audio/8XAGP
· Intel Pentium 4 530 3.0 Ghz 800 1MB
· Intel Recommended Aluminum Ball Bearing Fan
· 2x 512Mb DDR 400 PC-3200 (1Gb Total)
· Hitachi 80GB Serial ATA 7200RPM 8MB
· Samsung H552A 16X DVD±RW Beige
· Radeon 9600 256MB 2HDW/TV&DVI AGP
· Microsoft USB Optical Intellimouse OEM
with Windows XP installed (after quite some trouble with the SATA drive, and getting the BIOS to recognize my HD a bootable), I left 25G for Linux, the installation went smooth (but sure they can do a whole lot better), the only thing that the install didn't recognize was the network card (3Com plugged to a USB port), but I was able to get it to work once I got Ubuntu running, then I tried to install mono, since that's one of the reasons I'm trying Linux again (last time I tried I was very frustrated with it, it would keep locking up my machine and I just gave up, I don't have any problems with Windows 2000 or XP, so I didn't need anything else), but with the mono project I got my interest again in Linux, so here I am, starting from scratch, I followed some instructions found with google (of course) but didn't work, seems I'm missing some packages, I found them on the web, but obviously I don't know how to install new packages, so I'll be working on that next, hopefully I'll find out exactly what needed to be done to get Ubuntu-Mono working and I'll post it here
finally decided to start my blog.

I will publish any articles related to programming (Delphi and C# mainly) here, I'll also be posting my experiences with Linux, and we'll see where this goes.