Wednesday, July 23, 2008

On scripting

Summary: Scripting resources for Windows application developers and administrators.

I suspect that experienced Windows system administrators are familiar with these tools and resources, but if you are an occasional script writer and never heard of these, check them out:
  • The Portable Script Center is a self-contained help (CHM) file containing dozens of sample scripts for managing Active Directory, applications, desktop, Group Policy, hardware, IIS, and a much more.
  • Scriptomatic is a utility that can help you write WMI scripts for system administration. It generates WMI scripts in VBScript, Perl, Python, and Jscript. Scriptomatic supports numerous output formats from plain text to Web page to XML.
  • WMI Code Creator generates VBScript, C#, and VB.NET code that uses WMI to perform management tasks such as querying for data, executing a method from a WMI class, or receiving event notifications.
  • ADSI Scriptomatic generates scripts to manage objects in Active Directory.
  • Tweakomatic generates scripts to manage Windows and Internet Explorer settings.
More tools and resources are available at Microsoft TechNet Script Center.

Friday, July 18, 2008

Database installer revised

Summary: Overview of changes made to the previously published database installer script (dbsetup.vbs).

I'm not sure what happened to the new and "improved" MSDN Magazine (the web site), but all of a sudden, I started getting messages from readers asking to send them the VBScript file (dbsetup.vbs) accompanying my Data Deployment: Streamline Your Database Setup Process with a Custom Installer article (from the September 2004 issue of the magazine). I checked the site and did not find a download link, so I'm offering* the most recent version of the script here:


I'd also like to mention a couple of alternatives which you may like better than my approach, but first, let me describe modifications I made to the script in case you insist on using it. (If you don't know how the script works, please read the article; it explains the script execution logic.)

The most recent update to dbsetup.vbs was triggered by an idiosyncrasy in Visual Studio 2008. For some reason, Visual Studio 2008 saves new SQL source files added to database projects in the UTF-8 format, even if the files only contain regular 7-bit ASCII characters. [I could not find an explanation to this phenomenon, but since new files added to other (non-database) projects get saved in the ASCII format, I suspect that the issue is caused by the default file templates associated with the Visual Studio 8 database projects (someone at Microsoft must have accidentally saved these files encoded in UTF-8). I may be wrong, though.]

UTF-8 encoded files containing English (ASCII) text are almost identical to regular ASCII files, except that the former include three special bytes called byte-order mark (BOM) identifying the encoding format in the beginning of the file. Most programs, such as text editors, can handle UTF-8 encoding (you may not even notice that the file is UTF-8 encoded), but unfortunately, VBScript (the scripting engine) is not one of them.

When opening a text file in VBScript, you can specify whether the file is encoded in ASCII (TristateFalse) or Unicode (TristateTrue), but if you specify the Unicode format, VBScript will assume that the file is encoded as UTF-16, which is not the same as UTF-8. Because VBScript did not (and still does not) support the UTF-8 format, the original version of dbsetup.vbs could not process UTF-8 formatted files (the returned database error complained about invalid characters).


To handle UTF-8 encoded files, I added a workaround: when processing text files (SQL scripts and others), dbsetup.vbs now looks for the Unicode byte-order marks. If the script finds the UTF-8 specific bytes, it discards them and processes the rest of the file as regular ASCII text (Note: If you want to include real Unicode characters in text files, use UTF-16 encoding, which VBScript and dbsetup.vbs can handle). This workaround is not very elegant, but it seems to work.

Two other modifications affect repair scripts (scripts executed to repair a database without incrementing its version). To provide support for multiple database versions (in source control), dbsetup.vbs now expects to find repair scripts under the version labels in the Repair folder (the Repair folder is expected to have subfolders named after the database versions to which they apply, similar to the approach used for grouping the upgrade scripts). Also, to make sure that repair scripts added during test cycles get executed during production deployment, dbsetup.vbs will process them after an upgrade (only repair scripts defined for the current version will be processed).

Finally, dbsetup.vbs now supports conditional execution of scripts. If you want to selectively include certain scripts, keep them in a subfolder (under a regular folder) named after a directive you'll use when running setup and/or enclose the file references in the #if DIRECTIVE ... #endif code block (replace DIRECTIVE with a meaningful name) if you explicitly name the scripts in of the Files.txt files. To include the script, launch dbsetup.vbs with the /set command-line parameter followed by a directive you want to include, such as /set:DIRECTIVE. When dbsetup processes a folder, it first handles regular scripts, and then, if launched with the /set command, it will process all conditional files from the subfolders matching the directives included in the /set command, or the conditional sections of the Files.txt file.

I have to say that there may be better database deployment methods than my simple process. For example, you can try using Database Schema Build & Deployment Tools offered by Database Edition and Team Suite of Visual Studio Team System 2008.

Tip: In addition to Microsoft, other third-party vendors started offering database installation tools, such as:

A couple of weeks ago, I read an article Deploying Database Developments** in which Alexander Karmanov describes an alternative database deployment methodology. Although Alexander's approach seems a bit more complicated (then, say, my technique), it may offer a more comprehensive solution. I didn't have much time to delve into Alexander's solution, but you may want to give it a try.

Additional references:
Get Your Database Under Version Control by Jeff Atwood
Evolutionary Database Design by Martin Fowler and Pramod Sadalage
11 Tools for Database Versioning by secretGeek



*I wrote dbsetup.vbs in a rush a few years ago, so now, when I'm looking at the source code, I can see how imperfect it is. Frankly, I'm a bit ashamed that this code has been made public, but I also do not want to waste time rewriting the parts that work. Anyway, if you are eager to criticize the programming style and approach, I'm with you.
**Does the title Deploying Database Developments sound right to you? Development is a process, so how do you deploy a process? You can deploy an application, code, etc, but development... I don't think so.

Saturday, July 12, 2008

Technobrief #3

Summary: Recent discoveries: software, articles, videos, quotes, humor, and more.

Since the last technobrief, I have added the following to the list of items worth checking out:

Humor
  • From A progressive view of IT by Bob Lewis:
    ManagementSpeak: We just upgraded to a new version of the software.
    Translation: Not only does the software not work the way you expect it to, it doesn't work at all.
SoftwareWeb
  • Tablefy tool for creating and publishing comparison charts of any items.
  • Tips for New Bloggers offers great tips for Blogspot (Blogger) users.
VideoArticlesQuotes
  • From Why I Still Use Windows Despite the Peer Pressure by Adam Frucci:
    "And you know what? Macs are too hip. Oh, look at me! I do graphic design! I wear women's jeans and hang out in coffee shops! I'm a DJ! Well good for you. My computer is not a fashion statement. It's a computer."
  • From The Road to FogBugz 4.0: Part I by Joel Spolsky:
    "RFP stands for "Request for Proposal." It's a request by a large company for a custom proposal from a small company. The small company works on the 200 page laser-printed proposal like mad for three weeks and Fedexes it in great expense and at the last minute, where it gets put in the trash because the large company has their favorite vendor who takes them on a helicopter to Atlantic City on junkets involving blackjack and strippers, and who is going to get the contract no matter what, but someone in purchasing for some unexplained reason, maybe he's bucking for a promotion is insisting that the proposal be opened up to "competitive bidding" and the small company has been chosen as a victim to write up a proposal that has no chance of being accepted just to make the process look a little bit less corrupt, and if you're a small company, I would recommend that you don't fall for it and don't spend any time responding to RFPs unless it's already understood that you're going to get the contract."
  • From Done, and Gets Things Smart by Steve Yegge:
    "All too often I find myself on interview loops where the candidate knows a seemingly astounding amount about coding, computer science, software engineering, and general industry topics, but we find out at the last minute that they can't code Hello, World in any language."
  • From How Do You Find the Best Employees for Your Company? by Dare Obasanjo:
    "The real barrier is that most employers [...] expect people to want to work for them which means they'll get a flood of awful resumes, put a bunch of candidates through the flawed interview process only to eventually get tired of the entire charade and finally hire the first warm body to show up after they reach their breaking point."
  • From Acting Squirrelly: If SAP could make R/3 easier to use they would do it, right? by Robert X. Cringely:
    "SAP and companies like it do something similar by making powerful software that is quite deliberately difficult to use. They could make it easier. Heck, the capability to make it easier is shipped right with the software, though never pointed out to the customer. I used to think this was a matter of geek machismo, where higher value was placed on processes that were more difficult to command simply because it could be used to maintain for the techies an upper hand against management. But now I think it's much simpler than that and SAP just wants its software to be more difficult to use because that maximizes revenue."
  • From a 2003 e-mail rant by Bill Gates:
    "Microsoft.com is a terrible website."
Enjoy!

Thursday, July 10, 2008

How to watch laptop on TV

Summary: Streaming videоs from your laptop to a TV set is easier than you may think.

Why would you want to hook up a laptop to a TV? No, watching YouTube videos on a big screen is not the best idea (the resolution of YouTube videos is too low for TV), but there are better reasons.

First, many TV shows are now available online in reasonable resolutions. You can stream such programs as Frontline and 60 Minutes (two of my favorites), along with many offerings from PBS, CBS, and other broadcasters. I bet you will enjoy watching your favorite show on the TV in the living room more than on the laptop in the office.


Say you are a proud TiVo owner, so catching up a missed episode of your favorite TV show is not your problem. But what about other video content, such as Netflix or Amazon Unbox video downloads? Wouldn't you prefer watching these on a laptop or a TV?

Or, maybe you borrow a movie on a DVD from a friend for a day, but do not have a chance to watch it. Instead of making a personal copy of the DVD (which is obviously illegal), you can rip it to an ISO file on your laptop's hard drive (you can use free DVD Decrypter, DVDFab HD Decrypter, or DVD Shrink for ripping DVDs). When you have time to watch the DVD, mount the ISO file to a virtual DVD drive and watch it as a regular DVD (for mounting ISO images, use free Daemon Tools or MagicDisc). When you finish the movie, unmount the virtual drive, and delete the ISO file. [While making unauthorized copies of copyrighted media is prohibited by law, I'm not sure if an ISO image, which has not been burnt to a DVD, can be considered a "copy", but law professionals may disagree. I'm rather sure that RIAA's lawyers would consider this a crime, but I doubt that they would pursue prosecution of such "offenses". Don't take my words, though, and use your own judgment to consider the risks.]

In case you wonder what the quality of the streamed video you should expect, it will largely depend on the quality of the video source. Regular YouTube videos will look awful on TV, but video content intended for viewing in the full-screen mode, such as PBS programs and ripped DVDs, should be pretty decent, although HDTV purists will probably be disappointed.

To connect your laptop to a TV, you need to get a proper cable (or cables). Regardless of the type of cable, it must be long enough. If you intend to place your laptop on the coffee table in the living room, make sure that the cable reaches from the laptop to the TV (Hint: a standard 6 feet A/V cables from a 99¢ Only store will probably be too short).

If you own a high-end (expensive) laptop and TV set, check if they have High-Definition Multimedia Interface (HDMI) ports; if so, you can connect them via an HDMI cable.


HDMI cables combine both video and audio signals, so you'll need only one cable. They support both high-definition and regular video. Normally, HDMI cables are expensive, but at the time of writing I found a 15 feet HDMI cable for $6 (plus shipping and handling) offered by MonoPrice*; a better quality cable - which you may or may not appreciate - can cost significantly more ($20-$40). If you decide to buy an HDMI cable, make sure you pick the right type (extra length may affect the signal strength in an HDMI cable, but again you may or may not notice this).

If you cannot use an HDMI cable, check if your laptop has an S-Video (also known as Y/C) port. Most laptops and TV sets support S-Video, so this is your most likely option.


S-Video connectors can have different number of pins, but 4-pin connectors are the most common; nevertheless, check your laptop's and TV set's S-Video sockets to make sure that you get the right connector (you will not be able to plug a 7-pin S-Video connector into a 4-pin S-Video port).

S-Video cables only transfer video signals; to pass audio from the laptop to the TV set, you will need to use a standard 3.5mm stereo to two RCA audio cable, such as this one.


You plug the 3.5mm jack on one side of the cable into the laptop's headset port and the two (red and white) RCA connectors on the other side of the cable into the TV set's RCA audio input sockets (make sure you do not get the cable with two RCA plugs on both ends by mistake). If you can, get both the S-Video and RCA audio cables of the same length.

If you do not want to mess with two different cables, check out an S-Video|3.5mm to composite|stereo combo cable, which connects laptop's S-Video and 3.5mm audio ports to the three RCA A/V sockets; this cable has the S-Video and 3.5mm stereo jacks on one side and three RCA plugs on another side (see example at MonoPrice).

If neither of the above-mentioned options work for your laptop and TV set, you should be able to connect them using an adapter (there are lots of audio and video adapters out there). A new service, WireWize (currently in beta), may help you figure out how to connect your devices. [I could not test WireWize, because it did not find the model of my TV, so your mileage may vary.]

Once you connect your laptop to the TV, you can switch video output from laptop's LCD to the TV. Most newer laptops will detect connection to an external display (such as a TV set) and show you a prompt to switch automatically (you can project output to TV only, or keep it displayed both on the laptop and TV). You can also change the display output settings via the system display properties or function key (such as Fn+F4, Fn+F5, or some other keys, depending on the laptop make and model).

In addition to changing laptop's video output display settings, you must also adjust the source of TV input (using TV's remote). Depending on the type of connection, it can be Video 2, HDMI 1, or something else (just flip through the options until you see the laptop's display).

TIP: You may find it handy to turn your laptop's screen saver off temporarily, while you are streaming video to the TV; otherwise, you will have to move mouse or press a key every time the screen saver kicks in. You can do it manually, but it will be easier if you use a free program Caffeine. After you stop video streaming, just stop Caffeine from the system tray.
If you're still not clear how to connect your laptop to TV, check the references below or watch the following short video:


See also:
How To Connect Your Laptop To Your Television
How to Connect a Laptop Computer To Your Television Screen
How to connect your Laptop/PC/Computer to your TV
How-to: Connect your PC to your television and stereo.
How can I connect my laptop to TV?
How to Connect a Laptop Computer To Your Television Screen
How to Change the Primary Monitor on a Laptop
How To Connect A Laptop To A TV


*Be careful: when streaming video, InTV displays SMS messages at the bottom of the screen which often contain obscenities (I could not find any way to block them).
**This and other links to hardware vendors in this article are not paid advertisements. I reference them because I purchased or intended to purchase the same or similar products from these vendors and found the prices, charges, and services provided by these vendors reasonable.

Monday, June 30, 2008

From $500 desktops to $500 laptops

Summary: How much does a reasonably powerful laptop cost these days?

The first sub-$500 PCs, which came to the U.S. market just a few years ago, were pretty basic desktop systems with low-end processors, little RAM, small hard drives, and bulky CRT monitors. Look how times have changed.

This week (June 29-July 5, 2008), for about $500 (after the $125 mail-in rebate) you can get this laptop from Office Depot (free delivery is available):
  • Model: Acer Extensa EX5620-6419
  • 15.4" WXGA (1280x800) CrystalBright™ LCD screen
  • Intel Core 2 Duo Mobile processor T5550 (1.83 GHz)
  • 3GB DDR2 memory (RAM)
  • 160 GB hard drive
  • CD/DVD drive (reads/writes CDs and DVDs, supports double layer)
  • Intel 802.11a/b/g wireless LAN
  • 4 USB ports
  • 1 FireWire (IEEE 1394) port
  • 1 S-video port
  • Integrated webcam and microphone
  • 5-in-1 memory card reader (supports SD, MMC, Memory Stick, Memory Stick Pro, xD)
  • Intel Graphics Media Accelerator X3100 with up to 358MB shared memory
  • High Definition Audio with 2 built-in speakers
  • 6-cell lithium-ion battery; 65W AC adapter
  • Microsoft Windows Vista Home Premium
I have been buying cheap (sub-$400) laptops for friends and family for a while, but this is the first time I see a Core 2 Duo-powered notebook computer with 3 GB of RAM priced below $500. Although I don't need a laptop now, I'm really tempted to get this one.

UPDATE: According to some SlickDeals posters, you may be able to get this laptop for around $500 -- or even less -- without a mail-in rebate hassle. The price should be valid until July 19, 2008.

Thursday, June 26, 2008

Russian keyboard

Summary: How to add a Russian (Cyrillic) keyboard to Windows XP.

If you need to type in Russian on your computer's keyboard, you have several options:

Option 1: Use a virtual keyboard
This option is handy if you are using someone else's computer or for some reason don't want to modify your computer settings. You can find many virtual keyboards that support Russian (Cyrillic) characters online. The virtual keyboards I like are offered by:Option 2: Enable a standard Russian keyboard
You can enable a built-in Russian keyboard via Control Panel:
  1. Select Settings - Control Panel - Regional and Language Options from the Start menu.
  2. In the Regional and Language Options dialog box, selecy the Languages tab and click the Details button in the Text services and input languages section.
  3. In the Text Services and Input Languages dialog box, select the Settings tab and check the Installed services section.


    If you do not see the desired language or keyboard layout, click the Add button.
  4. In the Add Input Language dialog box, select Russian (or the language of your choice), check the Keyboard layout/IME box, and select the desired keyboard layout.


    Out of the box, Windows offers two Russian (Cyrillic) keyboard layouts: Russian and Russian (Typewriter); pick the one you like:[You can see and print international keyboard layouts supported by Windows at the Windows Keyboard Layouts page.]
  5. To change the default hotkey, which activates languages, clicking the Key Settings button in the Preferences section of the Settings tab, and use the Advanced Key Settings dialog box:

If you cannot touch type and don't have a standard Russian keyboard (with imprinted Russian letters), you can buy the keyboard stickers on eBay for less than $5 including shipping (I recommend transparent stickers).

Option 3: Install Russian phonetic keyboard.
If you cannot touch type on a standard Russian keyboard and do not want to mess with keyboard stickers, you can install a phonetic keyboard, which maps Russian letters to the keyboard keys with similarly sounding or looking English letters or characters. For example, a phonetic keyboard can offer the following English-Russian character mappings: A-А, S-С, D-Д, F-Ф, G-Г, H-Ч, J-Й, and so on.

There are many versions of Russian (Cyrillic) phonetic keyboards, but I like the ones created by Paul Gorodyansky. On his web site, Paul -- among other things -- explains how to install Russian keyboards on various flavors of Windows (the articles are available in both English and Russian). I found these articles very helpful, but the amount of information may be overwhelming.

If you just want to install a phonetic keyboard, download the desired layout from the Download section of the Russian Keyboard and Typing Russian page. If you are not familiar with the Russian phonetic keyboard layouts created by Paul Gorodyansky, read the Install phonetic (transliterated, homophonic) Russian keyboard layout section first; this section shows the layouts of the three versions of the keyboards Paul built.

The first two layouts are very similar; they only differ in the mapping of the W and V keys (they map these keys to the Russian letters В and Ж in reverse). You can download the installation files for these keyboard layouts for Windows XP, 2003, and Vista (files for other versions of Windows are available at Paul's site) from:While most of the character mappings in these layouts are obvious, several characters and symbols require a three-letter key (while in the Russian character mode):

: Ctrl+Alt+E
: Ctrl+Alt+5
Ъ : Ctrl+Alt+7
ъ : Ctrl+Alt+8
Ё : Ctrl+Alt+9
ё : Ctrl+Alt+0

In addition to these two keyboard layouts, Paul offers another variation:I haven't tried the Student layout, but compare it with the other two and see if you like it better.

BONUS: If you want to Russify your version of Windows, see these articles (note: text is in Russian):

Friday, June 13, 2008

Google I/O 2008 presents

Summary: Recommended videos and presentations from the Google I/O 2008 developer conference in San Francisco.

Videos from the Google I/O 2008 sessions (and events) are finally available. If you are interested in subjects such as Google (in general), Ajax, Google APIs, Gears, OpenID, OAuth, and other developer-centric topics, here are some videos, which I would recommend (this list includes sessions which I attended, as well as sessions which I'm planning to watch, so I don't guarantee all of them to be interesting; I'll mark the ones that I haven't seen, yet, as such):

Keynotes
  • Client, Connectivity, and the Cloud
    by Vic Gundotra, VP of Engineering (1 hr 30 min)
    Vic is responsible for developer evangelism and open source programs at Google. He also oversees applications development. Previously, Vic spent 15 years at Microsoft, where he worked on a variety of products and operating systems, including Windows 3.0, NT, Windows XP, and Vista. This keynote offers a brief overview of technologies discussed at the conference and features several speakers including Allen Hurff (MySpace), Steve Horowitz, Kevin Gibbs, Mark Lucovsky, Bruce Johnson, David Glazer, and Nat Brown (iLike).
  • Imagination, Immediacy, and Innovation... and a little glimpse under the hood at Google
    by Marissa Mayer, VP of Search and User Experience (1 hr)
    Marissa leads Google's product management efforts on search products – web search, images, news, books, products, maps, Google Earth, the Google Toolbar, Google Desktop, Google Health, Google Labs, and more. This talk is a glimpse from inside the trenches of how Google builds products (including practical insights on how to build the best products), how to prioritize your efforts especially under resource constraints, and how to think about strategy.
AJAX & JavaScript
  • Spice up Your Web Apps with AJAX APIs
    by Mark Lucovsky (Google) (57 min)
    Mark is an engineering director at Google and Google API lead. He previously worked for Microsoft, where he was part of the team that designed and built the Windows NT operating system. In this presentation, Mark shows how to use Google AJAX APIs to perform such tasks as downloading Atom and RSS feeds, search and display videos, images, news, maps, local business data, and do other things.
  • Can We Get There From Here?
    by Alex Russell (SitePen) (1 hr 2 min)
    Alex is Project Lead for the Dojo Toolkit and Director of R&D at SitePen. He discusses the goods and bads of various Web technologies: HTML, HTTP, JavaScript, CSS, GWT (Google Web Toolkit), Flex, Silverlight, HTML 5, Gears, Ajax libraries, and more.
  • State of Ajax: The Universe is Expanding
    by Dion Almaer (Google) and Ben Galbraith (Ajaxian.com) (56 min)
    Dion and Ben are the founders of Ajaxian.com. In this presentation, they discuss the latest Ajax developments, including multithreaded JavaScript technology-powered UIs, robust offline storage, choosing the right Ajax/JavaScript technology framework, Ajax outside of the browser, and more.
  • HTML5, Brought to You by Gears*
    by Aaron Boodman (Google) (36 min)
    In addition to his daytime job at Google, where Aaron works with JavaScript, DHTML, and Ajax, he is also the author of youngpup.net, a weblog about web development; numerous open-source JavaScript libraries; and Greasemonkey, a popular user script manager for Firefox. In this talk, Aaron explains the purpose and mission of Gears.
  • Even Faster Web Sites
    by Steve Souders (Google) (59 min)
    Steve is the author of High Performance Web Sites. At Google, he works on web performance and open source initiatives. In this talk, Steve discusses the best practices he's discovered, including the impact of iframes and where to place (and where not to place) inline script blocks.
  • Improving Browsers in New Ways: Gears++
    by Chris Prince (Google) (49 min)
    Chris, who is a tech lead of the Google Gears development team, explains what the Gears technology is good for.
SocialIf you can recommend other sessions, please add a comment.

Additional references:
Videos from all Google I/O 2008 sessions
Description of all Google I/O 2008 sessions
Google I/O 2008