Mnemorable

  • I love those who can smile in trouble, who can gather strength from distress, and grow brave by reflection. 'Tis the business of little minds to shrink, but they whose heart is firm, and whose conscience approves their conduct, will pursue their principles unto death. - [Leonardo da Vinci]
  • Standing on the Shoulder of Giants - One who develops future intellectual pursuits by understanding the research and works created by notable thinkers of the past.
  • A hundred times every day I remind myself that my inner and outer life are based on the labors of other men, living and dead, and that I must exert myself in order to give in the same measure as I have received and am still receiving... - [Albert Einstein]

Thursday, February 26, 2009

Enable Address Bar in Windows XP SP3

[Source]


Getting the Address Bar back requires what I would call a small hack. That being said, if your psyche can’t handle a little backdoor manipulation, you might want to weigh the risks of this technique with the safety of leaving it be.

By the way, I cannot take credit for this trick; I saw these steps posted on a Microsoft Community Forum. I am merely expanding on it with some more detailed instructions and some imagery. I also want to thank and acknowledge Kenneth P. Grush who e-mailed me about the controversy this morning and posted a comment in my previous blog entry about Windows XP SP3.

The file modified by Windows XP SP3 is browseui.dll. The trick, put simply, is to replace the SP3 version of this file with an SP2 version of the file. The older version of browseui.dll can be found in the following directory of a non-SP3 Windows PC:

C:\Windows\System32\
Copy the browseui.dll to the root directory of the SP3 machine or to some other location that the SP3 PC can access.

Okay, here is where its gets a little tricky. The browseui.dll file is a system file and is therefore protected whenever Windows is running. That means you cannot just copy the SP2 version over to the SP3 version. You will have to start the SP3 PC in Safe Mode. In fact, I would suggest starting the SP3 PC in Safe Mode with a command prompt.

Here is how you do that:

Restart the SP3 computer.

When it starts the reboot process and before Windows starts to load, press the F8 key, which will load the Advanced Boot Options Menu.

Choose to start in Safe Mode with a Command Prompt option.

At the Command Prompt, type this copy command:
xcopy C:\browseui.dll C:\Windows\System32\

Reboot the SP3 PC normally.

Monday, February 9, 2009

Getting Only the Date Part of a Date/Time Stamp in SQL Server.

[Source]

I got a question the other about getting the date-only part of date/time stamp in SQL server. In my experience there are two ways to go about doing this. Both require casting data types from one type to another. The first example is how I used to go about performing this task before I understood how dates were represented numerically. The second method is related to my understanding of ColdFusion dates and timespans and fortunately transferred well to SQL.

First, the more verbose method. This requires breaking the date into its year, month, and day parts, putting them together in "yyyy/mm/dd" format, then casting that back to a date. This method involves 7 method calls including the final CAST(), not to mention string concatenation (which we all know is wicked slow).

CAST(
(
STR( YEAR( GETDATE() ) ) + '/' +
STR( MONTH( GETDATE() ) ) + '/' +
STR( DAY( GETDATE() ) )
) AS DATETIME
)


The second method is much much cleaner. It uses only 3 method calls including the final CAST() and performs no string concatenation, which is an automatic plus. Furthermore, there are no huge type casts here. If you can imagine that Date/Time stamps can be represented, then converting from dates to numbers and back to dates is a fairly easy process (hopefully).

CAST(
FLOOR(
CAST( GETDATE() AS FLOAT )
) AS DATETIME
)

In the example above, we are converting the date/time stamp to its float form. So today (when this was posted), this would yield something like 38903.745537114199. Days are not fractional, meaning that decimal places represent fractions of a day (in hours, minutes, seconds). Then, in order to get the days part (trim off the time portion of the date/time stamp) we are FLOOR()'ing the float value. This will give us the numeric representation of the DAY-only date. Then, we simply cast that back to DATETIME format and there you have it, a date-only date/time stamp.

If you want to compare, try running this:

SELECT
-- Get the full date/time stamp as a base.
(
GETDATE()
) AS date_time_part,

-- Trying casting to a string then back to a date.
(
CAST(
(
STR( YEAR( GETDATE() ) ) + '/' +
STR( MONTH( GETDATE() ) ) + '/' +
STR( DAY( GETDATE() ) )
) AS DATETIME
)
) AS date_only_part,

-- Try casting to float, rounding, and back to date.
(
CAST(
FLOOR(
CAST( GETDATE() AS FLOAT )
) AS DATETIME
)
) AS date_only_part2,

-- Try casting just to float to see what it looks like.
(
CAST( GETDATE() AS FLOAT )
) AS float_value,

-- Try flooring to see the intermediary step.
(
FLOOR(
CAST( GETDATE() AS FLOAT ) )
) AS int_value


As far as performance is concerned, there is no big surprise here. The second method has fewer function calls, no string concatenation, and in my opinion is a much more natural casting idea. In my testing on a table with several thousand records, the second method generally executed in a fraction of the time that string concatenation method executed.

On 3,000 rows (based on CFTimer execution time):

Average time of method one: 115ms

Average time of method two: 16ms (HUGE performance increase)

Additionally, in testing, method one has some runs that were all over the place; very large execution times. Method two, on the other hand, consisently performed at the same speed, give or take a few ms.

Activating and deactivating the built-in main Administrator account in Vista.

[Source]


The following post gives details on activating and deactivating the built-in main Administrator account in Vista. Please note that I recommend that you only activate and use this account if you have problems which cannot be solved by using your other accounts and that when you have finished using it you should deactivate it again. Please also note that this method works for activating the hidden Administrator account in Windows Vista Home Premium (32-bit) and should work for all other 32-bit versions. This may also work for the 64-bit versions, but as I do not have a 64-bit version, I cannot say one way or the other.

Procedure for adding and removing the Administrator account.

Step 1. Bring up the start menu by clicking the logo button on the taskbar or by pressing the 'Windows Start' key on the keyboard.

Step 2. In the search box, type 'cmd'. Do not press 'Enter/Return'.

Step 3. Instead, press and hold down 'Ctrl', 'Shift' and 'Enter/Return'.

Step 4. In the user accounts dialog box that appears, select the name and enter the password of the administrator account that you created when first installing Vista and click 'OK'.

Step 5. You should now be at the command prompt. Note that if you do not follow Steps 2 and 3 as above, you will arrive at the command prompt but it will be the incorrect one. The prompt should be 'C:\Windows\System32>'. If not, Steps 6 and 7 will give you these error messages: 'System error 5 has occurred' and 'Access is denied'.

Step 6. To turn on the account, type 'net user administrator /active:yes'. Continue on to Step 8.

Step 7. To turn off the account, type 'net user administrator /active:no'.

Step 8. Close the command console.

Step 9. Open the Control Panel.

Step 10. Click 'User Accounts and Family Safety' then 'User Accounts' then 'Manage another account'.

Step 11. In the user accounts dialog box that appears, select the name and enter the password of the administrator account that you created when first installing Vista and click 'OK'.

Step 12. If the Administrator account is currently active, you should see the account displayed. If not, and you wish to make the account active, then repeat this procedure from Step 1, making sure to use Step 6 and not Step 7.

Step 13. Select the Administrator account by clicking on it.

Step 14. The account will be password protected, so in the list of options that appears click 'Remove the password'.

Step 15. After accepting the warning and removing the password, you will be returned to the list of options.

Step 16. Select 'Create a password' and follow the instructions to create a new Administrator password.

Step 17. Close the Control Panel.

Step 18. You will now be able to select the Administrator on startup. Note that if the password has expired, you may reset it by beginning at Step 9.

Step 19. If you wish to remove the Administrator account, the repeat the procedure from Step 1, omitting Step 6 and finishing at Step 8.