Wednesday, August 08, 2007

I recently got an invite to join Shelfari through email and I decided to join. It suggested that I sign into my gmail address book so I could look up who's already on shelfari. It showed me a (rather small) list of people already on the network and I intended to send them add requests. Instead what seems to have happened is that every person/unit I have had any correspondence with through my gmail id was sent an invite. Uggh. I do not like the idea of gmail being smart enough to store every email address I communicate with. Stop watching so carefully and ask me if I want to save any of these.

So, if you got such an email from me, apologies. It was unintentional.

Wednesday, August 08, 2007 9:53:40 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [9]Trackback
 Thursday, August 31, 2006

This is my first week of class in the third semester of my course. I have enrolled for Theory of Computing & Quantum Computing. For my third course, I am inclined to take Nonclassical logic theory. The problem is that its a 600 level course and I do not have the adequate background for it. The course is being taught up Prof Michael Dunn, a logician, philosopher, mathematician, computer scientist, informatician and the Dean of Informatics at IU. [Well, that is how he introduced himself :-)]. I will sit in for one more class and decide if I can take this course realistically. I plan to audit it in any case.


I will be working as a Research Associate to build a journal submission system with citeseer like filter capabilities & del.icio.us like tagging abilities. I had to switch advisors & drop my thesis plans with change in my funding source. Last year I was funded by Department of Energy (DoE) through Ohio Supercomputing center. The next year I will be funded by Microsoft through the community grids lab.

Quantum computing is a course that I could not take last year as my plate was full. So the way there is classical physics & quantum physics, this course will talk about quantum computing as opposed to classical computing. It is the sort of thing that could potentially change a lot of things we do in computing today. For eg: If some of the claims about quantum computing being able to work on the superpositioned quantum bits are true then the entire complexity theory as we know it today will be tossed away. The other more fancy things include time travel & parallel universes. A good inspirational small introduction to this is available on A short introduction to quantum computation. I can imagine how exciting & big the invention of transistor would have been ... and the applications following it. QC feels a little like that, The professor said studying some of this would result in us either becoming laughing stocks or winning Noble Prizes :-). Jokes aside, a lot of really smart minds have been studying this for years now. "Quite early in the 20th century Niels Bhor remarked that anyone who isn't shocked by quantum mechanics has not understood it". I am reading David Deutsch's paper on Quantum theory, the Church-Turing principle and the universal quantum computer and am looking at the Schrodinger cat experiment again.

In the next couple of weeks in the course of the course, I will be using haskell to simulate quantum behavior. Its a language I dread learning. Back to the paper now!

Thursday, August 31, 2006 4:52:36 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [8]Trackback
 Monday, July 24, 2006

Recently, I saw a cool demo on the "Round Table" device...Boy, is it neat or what! "Microsoft Office Roundtable" in my opinion is a totally new meeting experience with a rich set of unique features. This baby can detect & display the active speaker at any instant. Using six cameras, it stitches together different (360 deg) views & displays a panorama view of the conference participants at the remote end.  Imagine how a typical conference could be now ... and compare that with the traditional cumbersome Video-Tele Conferencing (VTC) where I would have to struggle to be "in the view" ! ['course the flip side is that now I can only hide under the table ;)]

Jeff Raikes said "you can record meetings, you can have synchronized views of the speakers or data, which also means that then if you miss the meeting you can attend after the meeting.

And one of the things that we've learned from our research is that it's possible to view the meeting in about half the time just by using good compression of the normal pauses in human speech, which, of course, leads to the great paradox: if you can review the meeting in half the time after the meeting, who wants to go to the meeting in the first place?"

The round table has the potential to change the way you and I collaborate in the future. Having said that, now the question is, how soon will it make to yours and my conference rooms???

Monday, July 24, 2006 4:33:21 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [1]Trackback
 Saturday, January 28, 2006

A quine is a program that writes itself.

Consider the syntax: <Function> : <Argument>

For example:

(1) Write this twice : Write this twice would output  Write this twice Write this twice 

(2) Write this twice : Write this twice : would output  Write this twice : Write this twice :

We are working with a register machine in the recursion theory class, and we wrote a quine in it. Later I wrote a quine in scheme and then tried writing one in C. That set me thinking as to whether the problem of being able to write a quine in a given language L was decidable. Is there a formal method to prove that a quine, or other quine like programs can be written in an arbitrary language? Talking to Roshan and Ramyaa about this, we concur that if the language is turing complete [i.e you can build a universal turing machine or eqvt (in lambda calculus, pi calculus)] then it should be possible to model a quine in it. You can find some quine implementations in different programming languages at http://www.nyx.net/~gthompso/quine.htm

We are working on a Register Machine (RM) with 7 possible instructions:

0*m# - add 0 at the end of Rm
1*m# - add 1 at the end of Rm
**m# - add * at the end of Rm
*0m# - add # at the end of Rm
n#    - go forward n steps
n*#   - go backward n steps
n**#  - cases on Rn in the order empty, 0, 1, *, #

I have 7 problems for the weekend, one of the interesting problems is to write twin programs s1 and s2 with the properties that s1 <> s2 and a) running s1 with all registers empty gives s2 in R1 b) running s2 with empty registers gives s1 in R1. Phew!

I wrote a scheme parser and interpreter for the langauge, so I can write code and execute it. If anybody wants a copy, drop me an email.

Saturday, January 28, 2006 7:04:25 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [2]Trackback
 Thursday, January 12, 2006

                I finally decided to build the mini kanren system in ruby for one of my class assignments. I have uploaded the code here.  My implementation does a run* always, so for

               a divergent case the run will always diverge giving no results. There is no provision for run1, run2,..., runn etc to get n values. I have kept the code similar to the

               scheme version as far as possible. Surprisingly, it wasn’t very difficult.

 

                Roshan has a comega version.

Thursday, January 12, 2006 9:11:03 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [2]Trackback
 Sunday, September 11, 2005

Spent the weekend doing my scheme assignment. More precisely spent most of the weekend thinking about how to write a macro for letrec. No clean solutions yet.

However, I see that there is a class of problems that need *something* extra to be solved. Its all guesswork at this stage, so I could be totally off the mark.
Here's a simple problem.


(let ([a 5] [b a]) ..)

A let* or a nested let will make the above assignments work by making a visible to b.  The sequential approach would require a to be defined before b or b to be within a's scope.

(let ([a 5])
    (let ([b a])
       .....
))


This would probably solve the above problem.
Now, how about


(let ([a b] [b "B"]) ...)
   
In (letrec ([x1 v1][x2 v2]...[xn vn])How can you ensure that all x's can see other x's?
In scheme, my guess is that this is implemented as a function [How? Dont arguments need to be evaluated then?]

An attempt to write this as a macro,
without using any side-effecting operations will prove the need for some kind of a parent structure that embeds all the variables and passes the structure around for each assignment. This problem led me to the discovery of  (1) and (2).  While the first url is very readable, the 2nd one is more complete and much less readable.

I keep trying to shut out the imperative part of my brain, How would you do this functionally?

Sunday, September 11, 2005 5:00:48 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [20]Trackback
 Monday, September 20, 2004

The new release of Monad (partner drop 3) is put up on http://beta.microsoft.com. This also means that besides all the cool features of Monad, we can now see Sammy the snake (game written in monad) running on msh :)

Monday, September 20, 2004 11:53:38 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [5]Trackback
 Thursday, September 02, 2004

Here are some links that talk about the changes in the shipping plans and features for Longhorn.

 

Jeremy Mazner’s blog entry about WinFs

 

Jeremy Mazner’s blog entry about Longhorn

 

CNET interview with Bill Gates

 

Official announcement by Microsoft

Thursday, September 02, 2004 6:30:31 AM (US Eastern Standard Time, UTC-05:00)  #    Comments [2]Trackback
 Friday, July 16, 2004

SQL forms a good candidate for a cmdlet provider in Monad/MSH. Using something like this you will be able to browse through the database, DB tables, SPs etc as though it were a filesystem. I was thinking ways of writing a C# app to do the work, especially about connecting to SQL and getting all information besides Databases. Before I could make up my mind, I found an option to expose the SQL server group as an AD object in the AD.

 

The registry and AD cmdlet providers also come with MSH. Now since the AD provider exposes the AD as a browsable system, you should be able to browse through the SQL server on the msh commandline! Is it really as simple as that or am I missing something here. Unfortunately I don’t have the resources to test this out now.  

 

We’ll find out soon J

Friday, July 16, 2004 7:38:37 AM (US Eastern Standard Time, UTC-05:00)  #    Comments [2]Trackback
 Monday, July 05, 2004

I have been using dasblog for a few months now. While I have fixed some of the minor issues, there are some issues that are pending.

 

One of the major issues with dasblog is the time settings. Besides the time [of posting a blog/comment] not being displayed correctly, there is yet another issue. We cannot make a blog post post-midnight for a couple of hours. After Pandu and Rosh had some bad experiences with this in the past, we three deliberately avoid making posts between 12.00 – 5.00 am in the nights.

 

A big thing missing in dasblog is an archive view, there is no real way of viewing your past blog entries based on some archive view. I saw somebody’s implementation of archive view in dasblog, not exactly what I would have liked to have but atleast there is an archive. I should check that out. Anybody else has an archive implementation for dasblog?

 

Some of the other minor issues:

 

  1. No delete comment feature
  2. Post a comment and you are brought to the main page [I have fixed this]
  3. No obfuscation of your own email-id [I have fixed this. You can now add the text you wish to replace @ and . with in the e-id in the config file. Neat?]
  4. Time display error
  5. Sometimes, when you edit an old entry, it makes a new entry. I am not able to re-produce this though. Happens once in a while.
  6. Delete category
  7. Rename category

 

This blog entry doesn’t talk about the good things in dasblog [Yeah, you could read it as whatever is not listed here works good in dasblog ;)]

Monday, July 05, 2004 8:27:15 AM (US Eastern Standard Time, UTC-05:00)  #    Comments [5]Trackback
 Tuesday, June 29, 2004
  1. get-command

The idea of being able to see all the commands supported by a shell is pretty cool. Has this been there in the past? I doubt. This command outputs not only the standard commands that come with msh but also the cmdlets that have been added by the user.

  1. get-help

get-help followed by a command name gives a detailed help for that command. Try (get-help get-command).synopsis, the get-command here could be any other command. Cool?

  1. get-member

Any command gives its output as an object in msh. This object could offer a set of methods and properties. Get-member uses reflection and lets you see these members. For eg: get-command | get-member -methods lists the methods available for the command object

  1. Programmability on  the commandline – write functions, use foreach, if-else etc.
  2. out-*

Killer feature. Try get-process | tail | out-excel. Now try get-process | sort id | tail | out-chart processname, id. You are gonna love what you see J. For other output options, type get-command out-*

  1. –Whatif

What if you had a series of commands, pipes and weren’t 100% sure if it did what you thought it did. What if you spend 2 min thinking if you should press the carriage enter key or not.  You use exactly this feature => the –whatif feature provided by msh. You type in the command and append it with a –whatif. Now the output you see is the output that the command if executed would have given. This is a way to let you know the output of a command without it really executing. Should reduce the average tension in an admins life ;)
stop-process 12,4 -whatif

  1. errorpolicy –confirm

This option gives you an option Yes to all, No to all, yes, no and suspend. Suspend is new. Suspend launches a new shell, lets you explore and find out about the problem, exit and come back to the same option. The idea is that you are probably now surer of which option to choose.

  1. The idea of having cmdlet providers. [Yeah you can traverse the registry as though it were a filesystem. You can write your own providers!!]
  2. where/where-object/reduce-expression

lets you specify a condition, filter. For example.

                                                               i.      gps | where “processname -like n*”

                                                      ii.      $ps get-process

foreach ( $p in ps | where { $_.handlecount -ge 500 } | sort handlecount) {  $p.processname,$p.id }

 

That was a listing of some of the commands that are aha!!

Tuesday, June 29, 2004 2:47:09 AM (US Eastern Standard Time, UTC-05:00)  #    Comments [2]Trackback
 Monday, June 28, 2004

I have been wondering about the cmdlet lifecycle. 

 

How do you add a new cmdlet?

How are the cmdlets loaded by MSH?

 

You use registercommand.exe <Path/dllname> and the new dll is registered. Now what happens when msh is started again? Does it load all the dlls in memory? Or does it load it when a cmdlet in the dll is explicitly invoked? Loading all cmdlet dlls in memory seems like too much memory consumption and overhead. The converse argument could be that practically the number of cmdlets wouldn’t be a very huge number; so doing this at start would give a performance hit.

 

Then again, when do we design stuff for pracrtical cases alone, we usually think of the worst cases!

 

Well, so how do you really find out how MSH is handling commandlet life cycle? There is no cordbg for .Net 2.0 yet and no CLR profilers in the picture.

 

There still is filemon.exe. Thanks to filemon.exe, these are my observations.

 

  1. All the cmdlet dlls are not loaded at msh start up.
  2. get-command doesn’t use reflection on all dlls’ to get all cmdlet names.
  3. Typing a specific cmdlet name loads the corresponding dll, processes and closes it

 These observations lead to the following conclusions:

 

  1. At start-up, msh does not load all the cmdlets in memory
  2. On typing get-command, it does a look-up [may be something like a file lookup], finds all the cmdlet name entries and outputs them
  3. On typing a specific cmdlet at the msh prompt, the corresponding dll is loaded by msh, the processing done, results obtained and dll unloaded [I think]
  4. Due to caching, all cmdlets take time during their first invocation and are faster thereafter.

 

How is a cmdlet executed?

 

First the corresponding dll is found and loaded. Then the cmdlet class is instantiated.

StartProcessing() if overrid is executed. If there are any input parameters, then they are filled with the values by msh and passed to ProcessRecord() if one exists. If pipelined input is enabled then the input parameter is filled with the current pipeline object and ProcessRecord() is exceuted for each of the input records. [So, this kind of looping is not the cmdlet’s responsibility, msh handles it and pumps in the value each time into the input parameter variable]. Finally if EndProcessing() is overrid, then it is executed. The object is then disposed off. Msh handles the output display/formatting/piping/redirection.

 

DISCLAIMER: These are my views only. This is not documented stuff, so I am just taking a guess as to how things may be working under the cover. I could be wrong!

Monday, June 28, 2004 1:15:42 PM (US Eastern Standard Time, UTC-05:00)  #    Comments [0]Trackback
 Friday, June 25, 2004

I took a session on Monad at the Bangalore .NET User Group meeting yesterday. Here is a brief write-up about the session for those of you who missed the session. People starting off on Monad may be interested in reading this.

 

Introduction

Unlike conventional shells that work on text streams and expect the end user to be an expert in text parsing, MSH introduces the idea of using structured object pipelines where objects instead of text flow between commands.

 

At the msh prompt, if we type

MSH C:/ > dir

we see a list of files [the same way the dos dir worked]. We see the same output for ls.

 

In Monad commands are called cmdlet [Commandlets]. Each cmdlet is a combination of a verb-noun pair. For example the cmdlet get-children or get/children gets all the children [files and directories when invoked in a FS]. dir and ls are aliases of get-children. By default the verb ‘get’ is assumed for a command given without a verb. So typing children gives the result of get-children and command gives the result of get-command. Alias is an exception. Typing alias gives the result of set-alias and typing aliases give the result of get-alias.

 

To see all the commands type command. To see all the aliases type aliases.

 

Some example Commands

 

MSH C:/> get-process

 

By using reflection, any object can list the methods and properties that it supports. To get a list of methods supported by a get-process object [which is a System.Diagnostics.Process object] try the command below.

 

MSH C:/> get-process | get-member -methods

 

MSH C:/> $a = get-process

 

MSH C:/> $a[0]

 

MSH C:/> $a[0].ToString()

 

Here $a is an array of Process Objects. We can invoke any function or property from the process class on object $a[0] and see the results like the ToString() example above.

 

MSH C:/> get-process | get-member -property

 

MSH C:/> $a[0].handlecount

 

MSH C:/> gps

 

MSH C:/> gps | tail

 

MSH C:/> gps | sort id | tail

 

MSH C:/> gps | where “processname –like cmd*”

 

MSH C:/> gps | reduce-expression {$_.handlecount -ge 500}

 

get-process or gps returns an array of objects. Reduce-expression works like a lambda in functional programming languages [similar to anonymous method]

For example in scheme (lambda((a b)(+ a b))) acts as a block of code.

In Monad the block of code after reduce-expression in braces is the script that will be carried for each pipeline object. $_ is set to the current pipeline object. So for each object in the object array returned by gps, $_ is filled with an object (the current pipeline object) for which the block of code is executed.

 

MSH C:/> gps | sort handlecount | tail | out-excel

 

MSH C:/> get-process | out-chart processname,handlecount -Title "Processes" -Filename Processes.html

 

MSH C:/> gps | sort handlecount | tail | out-grid processname,handlecount

 

MSH C:/> get-command out-*

 

MSH C:/> foreach ($p in $a | where "handlecount -ge 500"  | sort handlecount) { "{0,-15} has {1,6} handles" % $p.processname,$p.handlecount }

 

Notice the .NET style for formatting strings above.

 

MSH C:/> function n{notepad}

 

MSH C:/> n

 

MSH C:/> n;n;n

 

MSH C:/> gps [a-c]*,[t-z]* -exclude *[p-t] | stop-process –whatif

 

MSH C:/> gps | where “processname –like notepad*” | stop-ps1 –confirm

 

For invalid process ids, an error message is displaying when trying to stop them.

 

MSH C:/> stop-process 123,345,100000,200000,300000

 

MSH C:/> stop-process 123,345,100000,200000,300000 -errorpolicy notifystop

 

MSH C:/> stop-process 100000,200000,300000 -errorpolicy inquire

[Error stop-process]: (No process found for given ID :  : 100000) 100000"

 

[Error stop-process]: (No process found for given ID :  : 100000) 100000"

Continue :[y/yes/ n/no t/yestoall l/notoall s/suspend] s

MSH C:/> exit

 

[Error stop-process]: (No process found for given ID :  : 100000) 100000"

Continue :

[y/yes/ n/no t/yestoall l/notoall s/suspend] l

Stopped (Cmdlet:stop-process): User requested stop

 

MSH C:/>

 

Cmdlet

Each cmdlet is a managed class and not a separate executable. A simple cmdlet code is given below.

 

using System;

using System.Diagnostics;

using System.Management.Automation;

 

namespace SampleCmdlet

{

#region GetPs1

       [CmdletDeclaration("get", "ps1")]

       public class GetPs1: Cmdlet

       {

              public override void ProcessRecord()

              {

                     WriteObjects(Process.GetProcesses());

              }

       }

#endregion

}

 

The class that is to be exposed as a cmdlet is annotated with a CmdletDeclaration property specifying the verb and noun that is to be used to access this cmdlet. Also your class must inherit from the Cmdlet class and override atleast one of the three functions StartProcessing, ProcessRecord and EndProcessing.

 

A cmdlet that receives some input parameters and does exception-handling is given below

 

using System;

using System.Diagnostics;

using System.Management.Automation;

 

namespace SampleCmdlet

{

#region StopPs1

       [CmdletDeclaration("stop", "ps1")]

       public class StopPs1: Cmdlet

       {

              [ParsingParameterMapping(0)]

              [ParsingAllowPipelineInput]

              [ParsingMandatoryParameter]

              [ParsingPromptString( "Input the id: "  )]

              public int [] Id;

      

              public override void ProcessRecord()

              {

                     Process p = null;

                     foreach ( int i in Id )

                     {      if (ShouldProcess(i.ToString()))

                           {

try

                                  {

p = Process.GetProcessById(i);

                                         p.Kill();

                                  }

                                  catch (System.ComponentModel.Win32Exception e)

                                  { WriteErrorObject("No adequate permissions",e); }

 

                                  catch (System.ArgumentException e)

                                  { WriteErrorObject("No such process exists",e); }

                           }

                     }

              }

       }

#endregion

      

}

 

The code declares the input parameter, annotates it with attributes and assumes that the input values have been filled in. It doesn’t care if the input is coming form the pipeline, file, console or any other means. All the parsing and filling up the value is taken care by the shell. The same goes for output. The code calls WriteObject() function to do any output and the shell takes care of the formatting, displaying and routing of output as per the context.

 

The code above is for Monad, March 2004 build. Sample code for July, 2004 build is available at

http://msdn.microsoft.com/theshow/Episode043/Transcript.html

 

Cmdlet Providers

Cmdlet Providers provide the user with a basic set of cmdlets like pushd, move, copy, cd, dir etc that make the provider as navigable as a file store. Two standard providers come with the msh installation, one for registry browsing and the other for active directory.

 

[ProviderDeclaration("REG", "Microsoft", "Windows", "6.0", "MSH", "Registry", "1.0", ProviderCapabilityFlags.None)]

public class RegistryProvider :  NavigationCmdletBase

{

    protected override void GetItem(string path)

    {

        RegistryKey key = GetRegkeyForPath(path, false);

 

        if (key == null)

        {  WriteErrorObject(path, new ArgumentException("does not exist"));

        }

        WriteObject(key);

    }

    ....

}

 

For installing registry provider use:

MSH C:/> new-provider -Assembly "${MSHHOME}\System.Management.Automation.Core.dll" -Provider REG

 

 

 

 

 <