Pages

Wednesday, May 30, 2007

The new Microsoft Surface

Surface is the first in a new category of surface computing products from Microsoft that will “break down traditional barriers between people and technology”. A Surface computer is able to recognize physical objects from a paintbrush to a cell phone and allows hands-on, direct control of content such as photos, music and maps. how cool is that? Surface turns an ordinary tabletop into a dynamic surface that provides interaction with all forms of digital content through natural gestures, touch and physical objects.

It took them 6 years to materialize this from the concepts and ideas. Perhaps the best way to visualize this is by video below.



Check out Microsoft Surface's Virtual Pressroom for more information. Looks like we're already in the future. I personally would like to have this as my home coffee table.

Byte Order Mark (BOM) Tales

Recently I encountered a problem that I never seen before. There is no error display on the system except this weird character ÿþ. I remember searching for the log files looking for clues but nothing could be relate to this character. Later I found out this ÿþ character is an encoding signature called byte order mark or BOM for a file, in this case it's a XSL transformation file. Generally, it's a particular sequence of bytes at the beginning of the file that indicates the encoding and the byte order. For example any file with this particular encoding will have a different BOM:

UTF-8 - EF BB BF - 

UTF-16LE - FF FE - ÿþ

UTF-16BE - FE FF - þÿ

The W3C specify that all XML processor must read the UTF-8 and UTF-16 encoding. This text explain that to differentiate between UTF-8 and UTF-16 a BOM must be present, and that the BOM must be used by the parser as encoding signature. Other encoding may be supported, but no parser is required to have support for all of them, or one in particular, besides the UTF-8 and UTF-16.

This encoding signature is not to be displayed, any tool that support Unicode will understand this and will not show this to you nor consider it to be part of the text file. By checking the Hexadecimal of the file or opening the file in a non-unicode text editor will give you those characters presented in the above.

Now I know what the meaning of the character, but now how could I relate this information to the current problem? Read on...

With IE and MSXML, there are two really common errors that happen when something is not correct with the steps defined below.

An invalid character was found in text content

A parser found a character on your file that is not according the encoding declaration or the BOM specified for that file. If you have character encoded with ISO-8859-1 and then speficy the UTF-8 on the encoding declaration, this will issue the error.

Switch from current encoding to specified encoding not supported

In a basic thinking this error is almost identical to the previous, the only thing is that the parser understands that the real encoding on the file is different from the one in the encoding declaration. What the error is trying to tell you is that it can’t make the switch from the file encoding to the one you specify on the encoding declaration.

Let say if a file encoded as UTF-8 and a text encoding of UTF-16, since UTF-16 must always be two bytes, the parser known forehand that something is wrong with the encoding.

So in my case, it was the first one, character encoded with ISO-8859-1 and then speficy the UTF-8 on the encoding declaration. Case close.

Note: If none works, maybe you should consider re-install the MSXML parser according to your code, because each version has different coding requirement.

Monday, May 21, 2007

Restoring MS SQL Database From .mdf File

Imagine this scenario, you are planning to reformat your SQL server which has 50 databases and all data and log files stored in SAN system. What is the faster way to restore all the databases once you had finish installed the OS and SQL server? I used to backup one by one using the backup and restore database tool. But recently I found a faster way which could save lot of time.

The method is simple enough that I feel stupid not to know this. All you have to do is attach the .mdf file to the SQL Server. How? Open the SQL Server Enterprise Manager, open the tree (Console Root > Microsoft SQL Servers > SQL Server Group > (Your SQL Server) > Database) right-click on the database and select All Tasks > Attach Database. And then, just select the .mdf file, click OK and you are done. The process is almost instantaneous. So for 50 databases you could finish it less than 2 minutes.


If you're not sure what I'm talking about, you could always start with the default database ship with SQL Server. Right cilck on the Northwind database and select All Task > Detach Database
. After that follow the step above.

Good luck.

Friday, May 11, 2007

Snap-in failed to initialize in SQL 2000 MMC

I had this problem recently and this problem causing the Microsoft Management Console (MMC) for SQL 2000 fail to load all database. This is all caused by uninstalling MSSQL 2005 server which was at the same time has another version of MSSQL 2000 server installed. At first I thought the MSSQL is corrupted, however the database remain intact and accessible through SQL service or ODBC. So this must be something to do with MMC alone, and it was. Luckily the solution is simple enough.

All I have to do is reregistering the sqlmmc.dll located in the C:\Program Files\Microsoft SQL Server\80\Tools\Binn\

Just run this command

regsvr32 C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlmmc.dll


That did the trick for me. There are lot of trouble related to MSSQL that I have not discovered yet, maybe I should take the MSSQL professional course.

Monday, May 07, 2007

Useful Windows Tools from Sysinternals

I discover this utilities by accident, well someone told me about it. Sysinternals web site was created in 1996 by Mark Russinovich and Bryce Cogswell to host their advanced system utilities and technical information. Eventually Microsoft acquired Sysinternals in July, 2006. Sysinternals utilities helps you manage, troubleshoot and diagnose your Windows systems and applications. I haven't tried it all but I think I want to share it here. Check it out.

File & Disk Utilities

AccessChk
This tool shows you the accesses the user or group you specify has to files, Registry keys or Windows services.

AccessEnum
This simple yet powerful security tool shows you who has what access to directories, files and Registry keys on your systems. Use it to find holes in your permissions.

CacheSet
CacheSet is a program that allows you to control the Cache Manager's working set size using functions provided by NT. It's compatible with all versions of NT.

Contig
Wish you could quickly defragment your frequently used files? Use Contig to optimize individual files, or to create new files that are contiguous.

DiskExt
Display volume disk-mappings

Diskmon
This utility captures all hard disk activity or acts like a software disk activity light in your system tray.

DiskView
Graphical disk sector utility

Du
View disk usage by directory

EFSDump

View information for encrypted files

Filemon
This monitoring tool lets you see all file system activity in real-time.

Junction
Create Win2K NTFS symbolic links

LDMDump
Dump the contents of the Logical Disk Manager's on-disk database, which describes the partitioning of Windows 2000 Dynamic disks.

MoveFile
Schedule file rename and delete commands for the next reboot. This can be useful for cleaning stubborn or in-use malware files.

NTFSInfo
Use NTFSInfo to see detailed information about NTFS volumes, including the size and location of the Master File Table (MFT) and MFT-zone, as well as the sizes of the NTFS meta-data files.

PageDefrag
Defragment your paging files and Registry hives!

PendMoves
See what files are scheduled for delete or rename the next time the system boots.

Process Monitor
Monitor file system, Registry, process, thread and DLL activity in real-time.

PsFile
See what files are opened remotely

PsTools
The PsTools suite includes command-line utilities for listing the processes running on local or remote computers, running processes remotely, rebooting computers, dumping event logs, and more.

SDelete
Securely overwrite your sensitive files and cleanse your free space of previously deleted files using this DoD-compliant secure delete program.

ShareEnum
Scan file shares on your network and view their security settings to close security holes.

Sigcheck
Dump file version information and verify that images on your system are digitally signed.

Streams
Reveal NTFS alternate streams

Sync
Flush cached data to disk

VolumeId
Set Volume ID of FAT or NTFS drives

Networking Utilities

AdRestore
Undelete Server 2003 Active Directory objects

PsFile
See what files are opened remotely

PsTools

The PsTools suite includes command-line utilities for listing the processes running on local or remote computers, running processes remotely, rebooting computers, dumping event logs, and more.

ShareEnum
Scan file shares on your network and view their security settings to close security holes.

TCPView
Active socket command-line viewer.

Whois
See who owns an Internet address.

Process Utilities

Autoruns
See what programs are configured to startup automatically when your system boots and you login. Autoruns also shows you the full list of Registry and file locations where applications can configure auto-start settings.

Filemon
This monitoring tool lets you see all file system activity in real-time.

Handle
This handy command-line utility will show you what files are open by which processes, and much more.

ListDLLs
List all the DLLs that are currently loaded, including where they are loaded and their version numbers. Version 2.0 prints the full path names of loaded modules.

Portmon
Monitor serial and parallel port activity with this advanced monitoring tool. It knows about all standard serial and parallel IOCTLs and even shows you a portion of the data being sent and received. Version 3.x has powerful new UI enhancements and advanced filtering capabilities.

Process Explorer

Find out what files, registry keys and other objects processes have open, which DLLs they have loaded, and more. This uniquely powerful utility will even show you who owns each process.

Process Monitor
Monitor file system, Registry, process, thread and DLL activity in real-time.

PsExec
Execute processes remotely.

PsKill
Terminate local or remote processes.

PsList
Show information about processes and threads.

PsService
View and control services.

PsSuspend
Suspend and resume processes.

PsTools
The PsTools suite includes command-line utilities for listing the processes running on local or remote computers, running processes remotely, rebooting computers, dumping event logs, and more.

Regmon
This monitoring tool lets you see all Registry activity in real-time.

Security Utilities

AccessChk
This tool shows you the accesses the user or group you specify has to files, Registry keys or Windows services.

AccessEnum
This simple yet powerful security tool shows you who has what access to directories, files and Registry keys on your systems. Use it to find holes in your permissions.

Autologon
Bypass password screen during logon.

Autoruns
See what programs are configured to startup automatically when your system boots and you login. Autoruns also shows you the full list of Registry and file locations where applications can configure auto-start settings.

LogonSessions
List active logon sessions

NewSID
Learn about the computer SID problem everybody has been talking about and get a free computer SID changer, NewSID.

Process Explorer
Find out what files, registry keys and other objects processes have open, which DLLs they have loaded, and more. This uniquely powerful utility will even show you who owns each process.

PsExec
Execute processes with limited-user rights.

PsLoggedOn
Show users logged on to a system

PsLogList
Dump event log records.

PsTools
The PsTools suite includes command-line utilities for listing the processes running on local or remote computers, running processes remotely, rebooting computers, dumping event logs, and more.

RootkitRevealer
Scan your system for rootkit-based malware

SDelete
Securely overwrite your sensitive files and cleanse your free space of previously deleted files using this DoD-compliant secure delete program.

ShareEnum
Scan file shares on your network and view their security settings to close security holes.

Sigcheck
Dump file version information and verify that images on your system are digitally signed.

System Information

Autoruns
See what programs are configured to startup automatically when your system boots and you login. Autoruns also shows you the full list of Registry and file locations where applications can configure auto-start settings.

ClockRes
View the resolution of the system clock, which is also the maximum timer resolution

Filemon
This monitoring tool lets you see all file system activity in real-time.

Handle
This handy command-line utility will show you what files are open by which processes, and much more

LiveKd
Use Microsoft kernel debuggers to examine a live system.

LoadOrder
See the order in which devices are loaded on your WinNT/2K system

LogonSessions
List the active logon sessions on a system

PendMoves

Enumerate the list of file rename and delete commands that will be executed the next boot

Process Explorer
Find out what files, registry keys and other objects processes have open, which DLLs they have loaded, and more. This uniquely powerful utility will even show you who owns each process.

Process Monitor
Monitor file system, Registry, process, thread and DLL activity in real-time.

ProcFeatures
This applet reports processor and Windows support for Physical Address Extensions and No Execute buffer overflow protection.

PsInfo

Obtain information about a system

PsLoggedOn
Show users logged on to a system

PsTools
The PsTools suite includes command-line utilities for listing the processes running on local or remote computers, running processes remotely, rebooting computers, dumping event logs, and more.

Regmon
This monitoring tool lets you see all Registry activity in real-time.

Winobj
The ultimate Object Manager namespace viewer is here.

Miscellaneous Utilities

AdRestore
Restore tombstoned Active Directory objects in Server 2003 domains.

Autologon
Bypass password screen during logon.

BgInfo
This fully-configurable program automatically generates desktop backgrounds that include important information about the system including IP addresses, computer name, network adapters, and more.

BlueScreen
This screen saver not only accurately simulates Blue Screens, but simulated reboots as well (complete with CHKDSK), and works on Windows NT 4, Windows 2000, Windows XP, Server 2003 and Windows 9x.

Ctrl2cap
This is a kernel-mode driver that demonstrates keyboard input filtering just above the keyboard class driver in order to turn caps-locks into control keys. Filtering at this level allows conversion and hiding of keys before NT even "sees" them. Ctrl2cap also shows how to use NtDisplayString() to print messages to the initialization blue-screen.

DebugView
Another first from Sysinternals: This program intercepts calls made to DbgPrint by device drivers and OutputDebugString made by Win32 programs. It allows for viewing and recording of debug session output on your local machine or across the Internet without an active debugger.

Hex2dec
Convert hex numbers to decimal and vice versa.

PsTools
The PsTools suite includes command-line utilities for listing the processes running on local or remote computers, running processes remotely, rebooting computers, dumping event logs, and more.

PsLogList
Dump event log records.

RegDelNull
Scan for and delete Registry keys that contain embedded null-characters that are otherwise undeleteable by standard Registry-editing tools.

Regjump
Jump to the registry path you specify in Regedit.

Strings
Search for ANSI and UNICODE strings in binary images.

ZoomIt
Presentation utility for zooming and drawing on the screen.

You may find some redundancy but some tools has multiple capabilities.

Thursday, May 03, 2007

Establish Database Connection with Perl

It's been a while since I use Perl to connect to a database and my memory about it has faded long ago. But now since I'm no longer purely involve in web development so I thought this method could be useful. Let see how it goes.

To cut the chase, here is the sample code

use strict;

use DBI;

# Connect to the database
# See footnote 1
my $dbh = DBI->connect('DBI:mysql:my_database', 'my_username', 'my_password')
or die "Couldn't open database: $DBI::errstr; stopped";

# Prepare the SQL query for execution
my $sth = $dbh->prepare(<execute() or die "Couldn't execute statement: $DBI::errstr; stopped";

# Fetch each row and print it
while ( my ($field1, $field2, $field3) = $sth->fetchrow_array() ) {
print STDOUT "Field 1: $field1 Field 2: $field2 Field 3: $field3\n";
}

# Disconnect from the database
$dbh->disconnect();


DBI is Perl's DataBase Interface. There are many different databases: Oracle, mSQL, MySQL, Ingres... even files containing data separated by columns could be considered databases. DBI works with practically all of them. DBI requires a database driver module to talk to the database. The driver module handles all of the details about connecting to and communicating with the database. DBI sits on top of the driver; its job is to make reading from (and writing to) all databases as similar as possible. That way, if your project grows from something that could be handled with mSQL to something needing Oracle, you can make that change without altering the code very much.

Database driver modules are Perl modules like any other, and often they contain documentation. They are all inside the root package DBD. So, to get information on an Oracle driver you've installed, you can type:

perldoc DBD::Oracle


Other than installing the module, and possibly reading the documentation, you rarely need to deal directly with the database driver module. DBI handles all of that.