Monday, November 27, 2006
Knuth's Lecture
First problem:
Monotonic squares: Find all positive integers n such that the decimal digits of n and
n2 are both in nondecreasing order from left to right
While solving this problem, Anil Gangolli pointed out
(6(m)7)2=4(m+1)8(m+1)9
where a(m) is series of a digits (something like Kleene's operator)
eg 3(5) is 33333.
Here is proof for above statement using mathematical induction:
Given: (6(m)7)2=4(m+1)8(m+1)9
TO prove:(6(m+1)7)2=4(m+2)8(m+1)9
Take lhs:(6(m+1)7)2
=(6(m)7+60(m+1))2
so i am now squaring
applying (a+b)2=a2+b2+2ab
= (6(m)7)2 + (60(m+1))2 + 2.6(m)7.60(m+1)
= 4(m+1)8(m)9 + 360(2m+2) +80(m)40(m+1)
Now this can be simplified as
4(m) 4 8(m) 9
8 0(m) 4 0(m) 0
36 0(m) 0 0(m) 0
Adding three equations gives us
44 4(m) 8 8(m) 9
Final equation is
4(m+2) 8(m+1) 9
Hence proved
Tuesday, November 21, 2006
Creating Custom Installer (msi)
I am writing this article since I found very less article on custom installer.
First create a dll (or an exe). Add an Installer class (UrInstaller.cs) into it.
It should generally contains :
- Install method
- Uninstall method
You can have an additional method that validates parameters (and if they are null, then assign default values).
In Install method, you can write custom action for setup. You can use the parameters by Context.Parameters["TARGETDIR"].
You cannot use any standard i/o methods eg. MessageBox or Console.WriteLine. But you can throw an exception and it will be caught by installer and displayed in message box.
Install method contains base.Install(stateSaver); by default.
Similarly you can write uninstall method for the removing any files you have created using custom install method.
If you face any error while using your custom Uninstall method, use Windows Installer Cleanup Utility (http://support.microsoft.com/kb/290301).
Then to the same solution, add a setup project. Add above project as primary project output.
Then in custom actions, Install or Uninstall > Application Folder > Primary output from above project.
Then right click > Property Window > Custom Action Data >
/someparameter=”[someparameter]” /targetdir=”[targetdir]/”
Note: targetdir is inbuilt parameter. Therefore extra backslash required.
You can access someparameters as Context.Parameters["someparameter"]
You can also add file or assembly and it will be placed in “targetdir”.
For installing the application, use
msiexec /i UrSetup.msi someparameter="abc"
For uninstalling the application, use
msiexec /x UrSetup.msi
Friday, November 17, 2006
Metaphysical Coding
It showed that begindate as current date but to my suprise, last date was 99991231, ie 31st December, 9999. (What a work around !! - Why not assign End date to a predefined macro or value ie something similar to infinity)
So, SQL Server guys predict that world would end on 31st December, 9999 (Armageddon - There are people who think other wise Refer Wikipedia).
Come on, I always knew there was something spiritual about Microsoft products. They defy all the rules on Computer Science. :-)
When a tester enters my room wearing a big smile, most common replies are "It was working on my machine" or probably "It was working that day" :-) .
Well I say, "You know since it uses Microsoft products, you can start it only on auspicious day and that too by chanting OM (holy word that Hindus use)"
Ok jokes apart, I never supported Microsoft products until I was hired by a Microsoft based company and was placed on .NET and SQL Server projects.
Thats when I realized that Microsoft somehow allows you to create most of the things and that too easily, but still as a computer science engineer I still find things are not in place.
For eg. I was experimenting SQL Server Integration Services using C# code. I wanted use Microsoft.SqlServer.Dts.Runtime namespace. But it is not imported by default for Console application. So I tried to find dll that I should reference (I presumed it should have been Microsoft.SqlServer.Dts.dll or with similar name).
I was visited MSDN for help (See MSDN). I didnt find a thing on which DLL to reference. By the way, if Microsoft claims that they have improved their Visual Studio standards by n%, they have detoriated their MSDN standards by same n%. It is one of the most pathetic documentation for a good product like .NET.
I personally think all MSDN documentor should read Java Doc before even starting to write a line. Any time while coding in Java, most of my problems are solved using Java Doc. This is not in case of C#.
Anyways, I did found out the dll after 1/2 hour of trial and error search. It was Microsoft.SqlServer.ManagedDts.dll
Come on guys, we are not robots to find such references among huge list of dll. (Why Managed ? I understand the difference between managed and unmanaged code. Even if it is important to use Managed substring, please reflect that in your documentation).
Disclaimer: This blog is simply meant for humour and is not meant to offend anyone. This doesnot reflect any views of my company or my collegues. It is purely my personal opinion.