Monday, October 31, 2005

Interesting puzzles - 6

Back to puzzles.

A man is walking through a long railway tunnel and is 1/3 rd through when he hears the sound of a train approaching from far. As it turns out, he would have narrowly escaped from the train by continuing forward or going backward without changing his current speed. What is his speed if the train is moving at 20kmph.

Try to solve this without using math equations and such. I think it was OP who clued me on these kind of problems in college :)

Thursday, October 27, 2005

slickrun is cool

This utility does to UI programs what aliases do to your cmd shell. I have been using it for a few weeks now and I must say it is great.

Check it out: SlickRun

Wednesday, October 26, 2005

Uninstalling a product from command line.

It is surprising that once you install a program, the only way to remove it is through the add-remove programs unless you have access to the msi that installed it. There is no builtin command line equivalent and this becomes a pain when u r repeatedly installing successive builds of the same product. Luckily, the info required is exposed through WMI and python has hooks into the same (Tested only on xp-sp2. Your mileage may vary...):

import win32com.client
import os

def GetWMI(comp, namespace):
comObj = win32com.client.Dispatch("WbemScripting.SWbemLocator")
return comObj.ConnectServer(comp,namespace)

def GetProductId(productName):
wmi = GetWMI(".", r"root\cimv2")
prods = wmi.ExecQuery("Select * from Win32_Product where Name='%(productName)s'"%vars())
if (prods.Count == 0):
return None
else:
return prods[0].IdentifyingNumber


if __name__=="__main__":
prodCode = GetProductId("My Product Name")
if (prodCode):
print "found a previous installation...."
print "uninstalling..."
os.system("msiexec /x " + prodCode)
else:
print "No previous installation found."

There is a WindowsInstaller.Installer automation object exposed, but I could not get it to work through python :(, guess I have to learn vbscript or some such for sake of efficiency.

Tuesday, October 25, 2005

Hooking into the perfcounter installer..

It is surprising how often you find uses for a tip that you get. Case in point: IFEO.

I never heard/nor felt its need in 3.5 years at my previous job. But these days I seem to use it fairly often!

Dotnet has this PerformanceCounterInstaller class where you define various attributes and counters that you want to expose for you app. Then call installutil to install it.

However, installutil is not used in production setups as selfreg has a whole range of issues to handle and the unmanaged equivalents (lodctr stuff via provided custom actions in the setup tools) are generally used.

So for setup we needed to figure out the dotnet specific registry entries + the ini files that we give to lodctr. Setup the debugger to launch on invocation of lodctr by:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\lodctr.exe]
"Debugger"="c:\\debuggers\\windbg.exe "

Then invoked installutil. This gets the lodctr invoked by installutil into the debugger and you have all the time to figure out that .net internally creates the ini files in the %temp% directory :) Figuring out the additional reg entries was a matter of inspection...

Monday, October 24, 2005

Office viewers....

Acrobat reader is pretty popular; recently I found that Microsoft Office readers are available and free too !!

http://www.microsoft.com/office/000/viewers.asp

Wednesday, October 19, 2005

Debugging in production..

For someone building server apps for windows there are some pretty good resources on production debugging on msdn. Check these out:
  1. Production debugging for .netfx
  2. Production debugging for unmanaged code
I think most people will find the the section on using diagnostic tools in 2 to be useful.

Tuesday, October 18, 2005

Video tools.

Most of our life is word based - blogs, code, bugs, setup documents etc. etc. It does not have to be. There are a few tools out there which make it a snap to build demo videos. Try these out to create that next bug report, the next setup "document" and you will be pleasantly surprised :)

Wink (freeware, no sound, pretty small output files in flash): http://www.debugmode.com/wink/

Hypercam (commercial, sound support but the output files are pretty big wmv files): http://www.hyperionics.com/

Thursday, October 13, 2005

Job descriptions..

Most of the job descriptions I have seen mention fluffy things like passion, vision, coordination, industry leading percentile of salary blah blah and blah. This one over at jetbrains is refreshing different :) !! You can't get more straight forward than

We offer
* Participation in development of world leading products
* Creative team work
* High salary

In case you are getting ideas, check out the location...

Friday, October 07, 2005

Troubleshooting resharper installation

Jetbrains has this cool addin to visual studio that brings in some of IDEA features to VS. Tried installing build 207 today and had to hack quite a bit to get it to install. The problem was it was doing something during setup, goes right till the end and rolls back with error "something that ran as part of setup did not complete". Tried to see if I can find anyway to get any more information:

ReSharper2.0-VS2005-build207.exe /?
informed me that /V option can be used to pass arguments to msiexec (called internally by setup). So to get more logging info I executed
ReSharper2.0-VS2005-build207.exe /V"/l*v abc.log"

From the log it was clear that it was invoking devenv.exe /setup which supposedly failed (god knows why). So I wanted setup to take it easy about this so that I could execute the same command manually later and figure things out. Now, the problem reduced to bypassing this devenv.exe invocation by setup.

IFEO to the rescue!! So I created a donothing.exe, which as the name suggests, is an executable which does nothing. Placed it in path and created the following registry entry:


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersionImage File Execution Options\devenv.exe]
"Debugger"="donothing.exe"


Re-ran setup and it was happy the devenv invocation :) and the installation succeeded!!

Thursday, October 06, 2005

what the bleep do we know?

Never got around to watching the movie/documentary "What the bleep do we know", but they have put up a website for a book that they are bringing out. Worth a checkout: what the bleep
....

What if the mind and matter are not split? What if there are
observable feedback loops between the two? It’s the 21st century,
yet mainstream science still refuses to look at this...

I know many, many academic colleagues... distinguished people in their fields—in psychology, cognitive neuroscience, basic neurosciences, physics ...
who privately are very, very interested in... psychic phenomenon. Some of them are getting successful results in their experiments. Well, why aren’t we hearing about it? Because the culture in the academic world says you cannot
talk about it. So we’re living in the parable of the
emperor’s new clothes.
...
So, who now hijacked the search for truth?
Two sides of the same coin.
First the Church, and now the new priesthood—the Scientists.