Innovation Day | S+S

I hope you already heard about S+S, at least at the high-level point of view. Its about combining local installed software and services in the cloud. Software makes services better and services make software better. S+S brings together the best of both worlds, to maximize choice, flexibility and capabilities. It is nothing new actually from technology perspective, but it is like a flag that Microsoft has declared as a new vision in our industry. I am going to talk about S+S in Microsoft Innovation Day, this Friday (29-08) in Jakarta.


SS02     SS03

Fat or thin client? Mobile or desktop? Local installation or Web application? Instead of choosing based on “or”, S+S chooses to use “and”? It will not be constrained to one particular technology, but will be mixed from desktop, web, mobile/device and enterprise apps. That’s the concept of S+S. Let me share how you can start to explore about S+S vision.

First, I strongly suggest you read the architect journal #13 : Software + Services, to understand the vision and concept of S+S. It also contains information about Internet Service Bus, Project Astoria, S+S in enterprise, Enterprise Mashup, MS Office as platform for S+S, and interesting article by Gianpaolo Carraro, a planet ruled by software architectures. I really enjoyed reading that journal after long time loosing interest in high-level stuffs :). Second, after read the architect journal #13, take a look on build, run, consume and monetize S+S links from MSDN. Please put focus on Multi-tenant Data Architecture, because you will need to understand that when exploring S+S.

What I can say for now, S+S is interesting concept, but usually developers don't really like conceptual things until they can see it running in a computer. So I will use S+S and Multi-tenant Data Access blueprints to describe the S+S concept in my presentation. If you want to try, please download here:

SS       SS06       

Current release of S+S blueprint contains the Outlook + Services and VideoShow. You can also consult to Multi-tenant Data Access blueprint (MTDA) for more detail. I will try to post more about those stuffs before my presentation.

Cheers - RAM

Share this post: | | | |

Indonesia IT Independence Day - 17-08-2008

Yesterday is the 63rd of Indonesia independence day. If you believe in Numerology, like mystical or esoteric relationship between numbers and physical objects or things, here you go:

63     : 6+3         =   9
2008  : 2+0+0+8 = 10
--------------------------
See : 9 + 10 = 9 + 1 + 0 = 10

There are no set definitions for the meaning of specific digit appears, but I found that common number interpretation is:

0. Everything or absoluteness. All
1. Individual. Aggressor. Yang.
2. Balance. Union. Receptive. Yin.
8. Power/sacrifice.
9. Completion.
10. Rebirth.

So let me tell you on top of symbolic meaning of ten:
- As you see 63 and 2008 gave us, 10 or 01 which is a digital symbol.
- We have completed our "to be heard by the world mission"
- We will rebirth in term of digital knowledge but need power/sacrifice
- Please give your own interpretation as comments in this blogs :)

I am not paranormal nor numerologist, but I love my country like you are!. So lets do something big for Indonesia, again and again! Even by small things consistently, or initiate big things together!

MERDEKA!!!

Cheers - RAM

Share this post: | | | |

SQL Server 2005 Driver for PHP

This release marks another step in Microsoft’s continued commitment on interoperability with PHP. After the CTP, finally David Sceppa and team released it. The driver is available for download on the MSDN download site. I downloaded it, installed and explored some sample applications inside its distribution. Impressive!. I like the way they distribute this PHP Extension, why?

Documentation and Transparency in Design Process

001 

Source Codes Distribution @ CodePlex

002 


Natural Compilation

How to compile it? You must first be able to build PHP not including this extension. See my previous blog to do that, to get the php5ts.lib. 

To compile SQL Server 2005 Driver for PHP:
1 - Copy the source code into the ext\sqlsrv directory.
2 - Then run buildconf.bat
3 - Then run "cscript configure.js --enable-sqlsrv=shared <other options>". 
     It is possible to compile with just --enable-sqlsrv rather than --enable-sqlsrv=shared
4 - Run "nmake".  It is suggested that you run the entire build.  Run "nmake clean" first.
5 - To install the resulting build, run "nmake install" or just copy php_sqlsrv.dll to PHP Dir

I compiled and tested under PHP 5.2.6 Visual C++ 2005 Express and Visual C++ 2008 Standard compilers. No issues :)

Ciao - RAM

Share this post: | | | |

Introducing kUfI

Yesterday, we officially launched KucingFisika (kUfI), August 8, 2008 (08/08/08 08:08:08), physics and scientific computing community for Indonesia. It was inspired by Schrodinger Cat paradox. kUfI will bring fun for physics students by showing simple physics experiments and also aim to focus on scientific computing. See kUfI announcement from Detikinet here.

Please visit kUfI and join me to congratulate the team who has developed kUfI from a small LAB at University of Indonesia. This ambitious team will create 1000 videos and screencasts for physics and scientific computing educations in the next one year. Special thanks to Sagi Arsyad, Ridi Ferdiana and Nicolas Saydena, all my brilliant students who involved in this project. We made a history on 08/08/08 08:08:08


Ciao - RAM

Share this post: | | | |

Developer Idol 2008 - Winner Announcement

I have announced this competition on March 18, 2008 through my blog post and PCMedia magazine. I also has published our judgement criteria for all submitted projects. And today, I would like to announce the winners of Developer Idol 2008 !

1st Winner
Project Name  : LibraLINQ
Project Doc     : Part 1, Part 2, Part 3, Part 4, Part 5
1st
 
2nd Winner
Project Name  : Perpustakaan.NET
Project Info     : Download here
2nd

3rd Winner
Project Name  : Celestial Being
Project Info     : Presentation, Demos, Codes
3rd 

Each winner will get:
- Certificate from Microsoft Indonesia
- 1 week internship with my team to complete/enhance their project
- PC Media voucher for 1 year
- External disk 320 GB

Wely as the 1st winner for 2008 will get a trip to Microsoft Technology Center in Bangalore, India. He is also joining Microsoft Developer and Platform Group team as Developer Evangelist!

Please join me to congratulate them and see you as the next Developer Idol!!!

Ciao - RAM

Share this post: | | | |

Midori - Cloud Computing OS

New OS will be an entirely new design, built from the ground up. Microsoft has announced it, code named, Midori that will be released sometime post-2010. Midori OS is based on Singularity and designed for Cloud computing -- or the movement to shift hardware and software, particularly storage, out of home PCs and into computing clusters. Cloud computing is gaining significant momentum and attention huh!. Read more here:

Microsoft Details "Midori" Cloud Computing OS
Microsoft's plans for post-Windows OS revealed
My First Look on Singularity
Goodbye, XP. Hello, Midori
Life After Windows - Microsoft Midori Operating System


If you are interesting in OS stuff, you can download Singularity from CodePlex and play with its codes and compiler (Bartok).

Enjoy!

Ciao - RAM

Share this post: | | | |

PHP4Live - PHP SOAP Win32 Build Environment

Hacking PHP extension on Windows is "little bit" harder. I had a good challenge when trying to make it works on my Vista machine using VC++ 2008 Express (and Windows Vista SDK) for our PHP4Live project. I called Pak Tahir and he told me that easier to use Cygwin DLL, but again, my boldness drove me nuts!. I want to prove that Vista can do that well. Let me share with you (in this long post) to avoid you from doing stupid thing in around 10 hours!

PHP4Live Overview
In our PHP4Live project we want to be able to customize PHP SOAP extension as we want to embed Windows Live ID web and delegated authentication mechanisms. The plan is to natively link Windows Live (WL) Web Services and expose its APIs as PHP 5 user-space scripts, means that we will make PHP extension for Windows Live. This type of extension can bridge the gap between WL Services APIs and the PHP core then seamlessly increase usability of WL Service APIs among PHP developers (hopefully). Beside of usability reason, other motivation for PHP Extension for Window is the sheer need for speed. PHP script code has to be tokenized, compiled, and stepped through in PHP VM environment, which can never be as fast as native code. Certain utilities (known as Opcode Caches) can allow scripts to skip the tokenization and compilation step on repeated execution, but they can never speed up the execution step. By translating it to C code and compile it as PHP extension DLL, the maintainer sacrifices some of the ease of design that makes PHP Extension for WL more powerful.

PHP SOAP Extension
PHP SOAP inside the PHP distribution is an "experimental" extension that can be used to write SOAP (1.1, 1.2 and WSDL 1.1 specs) Server and Client. It is not complete like WSF/PHP from WSO2, but I was thinking this is pretty simple as our PHP4Live base code and I want to prepare build environment for it. So I took the code from PHP source ext/soap, then I moved it to my working directory in C:/Work/PHP-SOAP. I clicked the dsw (VC++ 6.0 based) and followed VC++ 2008 migration wizard successfully. Then I had:

01

First compilation, I got around 100 warnings and 50 error messages. I thought I can fix that within 3 hours, but thing was getting worst!. Why? Because to compile PHP SOAP I need the following libraries:

- odbc32.lib
- odbccp32.lib
- wsock32.lib
- libxml2.lib                      
- resolv.lib                
- php5ts_debug.lib  

All green color libraries are coming with Windows Vista SDKs and the blue one is the GNOME XML Library, that maintained by Igor Zlatkovic. You can download Libxml 2.6.32 from Igor website or from XMLSoft. My biggest problem was resolv.lib and php5ts_debug.lib, because I had to compile it directly from PHP source codes.

Building PHP from Source
This my step-by-step quick-start guide to build PHP using Windows Vista and VC++ 2008 Express edition. First, create

1. Download and Install Windows SDK for Windows Server 2008 and .NET Framework 3.5
2. Copy C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\WinResrc.h
    to the same directory then rename it as WinRes.h.
3. Create the directory C:\work.
4. Download Windows build tools and unzip the contents into C:\work.
5. Create the directory C:\usr\local\lib. Copy the C:\work\win32build\bin\bison.simple
    into the new directory.
6. Download Windows DNS resolver library and unzip into C:\work.
7. Open C:\work\bindlib_w32\bindlib.dsw, follow migration wizard.
    Choose Debug or Release configuration, then Build => Build Solution.
    Make sure you have set the Additional Include Directories like below:
 
05

8. Get copy of the PHP source and extract it into the C:\work directory, I use PHP 5.2.6.
    At this point, that directory should look something like this:

06 

   Note : As we will need iconv library, please download from Igor website.

9. Open Visual Studio 2008 Command Prompt and execute the following command:

C:\Program Files\Microsoft Visual Studio 9.0\VC> set "PATH=C:\work\win32build\bin;%PATH%"

10. Go to PHP-5-2-6 directory and run : cscript /nologo win32\build\buildconf.js

11. Run : cscript /nologo configure.js --disable-all --enable-cli --enable-cgi
     --enable-object-out-dir=.. --disable-ipv6.
     To enable debugging, add --enable-debug to the end.

12. Run : nmake

If all went well, from step #7 you will get resolv.lib in bindlib project debug folder and from step #12 you will get php5ts_debug.lib in Debug_TS or Release_TS folder. Also, it means you are ready to compile PHP SOAP.


PHP SOAP Build Environment
Ok lets start. First, you have to configure your VCE "Additional Include Directories" under C/C++ option to make use all header files before doing the compilation, here is my configuration:

02 

After you set the include directories, now you have to set the "additional library directories" under linker options for linking purpose. Below is how it looks like. There is Windows SDK and LIBXML 2.6.32+ lib locations. Make sure you put C:\Work\Debug_TS where php5ts_debug.lib located. Also C:\Work\bindlib_w32\Debug where resolv.lib located.

04 


I believe you still get some error messages if you compile PHP SOAP, but don't be panic, error messages are bonuses for us (image if there the error has no message). If the error points you to system header files stat.inl and utime.inl, I know how to fix it.

Error 3 error C2466: cannot allocate an array of constant size 0   
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\sys\stat.inl    44

Error 6 error C2466: cannot allocate an array of constant size 0   
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\sys\utime.inl    39

Just add _USE_32BIT_TIME_T in the preprocessor definitions and you are DONE!. I am sure you can compile PHP SOAP successfully now. But you will find at least 3 errors in linking process.

03 

BUGS in PHP SOAP EXTENSION (PHP 5.2.6 WIN32)
As PHP SOAP is an experimental extension, bugs are very welcome. I currently found that there are two bugs related to LIBXML2 Win32 linking that cause LNK2019.

1> Creating library .\Debug_TS/php_soap.lib and object .\Debug_TS/php_soap.exp
1> php_encoding.obj : error LNK2019: unresolved external symbol
     _php_libxml_xmlCheckUTF8 referenced in function _to_xml_string
1> php_sdl.obj : error LNK2019: unresolved external symbol
    
_php_libxml_switch_context
referenced in function _get_sdl
1>.\Debug_TS/php_soap.dll : fatal error LNK1120: 2 unresolved externals

Why I said bugs? If I try to comment part of codes in php_encoding.c and php_sdl.c that doing function call the following methods:

- php_libxml_xmlCheckUTF8(BAD_CAST(str))
- php_libxml_switch_context(new_context TSRMLS_CC)

No problem at all. I can compile PHP SOAP and get its DLL extension very well! I don't know how long time I can mitigate this LIBXML bugs, but I believe should be less than 10 hours!. Now I need sleep!

Note for Zeddy: Can you try in *NIX machine?

Ciao - RAM

Share this post: | | | |

Programming with PowerShell SDK | Part 2

In this tutorial, I would like to show you how to build your first CMDLET (command let) using C# and PowerShell SDK. We will make the simplest one as our HelloWorld, only to learn the skeleton of creating it. Many things we can do with CMDLET. For example, some folks make CMDLET for IIS 7.0 Management, SQL Server 2008, TFS, Sharepoint etc. Maybe myself should release one for MSMPI for example hmmm, spicy!. Ok, let start!

Basically, cmdlets are .NET class, derived from abstract classes:

- System.Management.Automation.Cmdlet or
- System.Management.Automation.PSCmdlet

and what we should do is to override some methods with our needs. The cmdlet assembly then can be installed to the PowerShell and can be used from PowerShell or from other applications which use the PowerShell to Invoke cmdlets.

A cmdlet has a name, that consists of a verb that indicates the action the cmdlet takes and a noun that indicates the items that the cmdlet acts upon. For example Get-Proc, it uses the verb "Get", defined by the VerbsCommon enumeration, and the noun "Service" to indicate that the cmdlet works on service items. When naming cmdlets, do not use any of the following characters: # , () {} [] & - /\ $ ; : ” ’<> | ? @ `. We should choose a noun that is specific. It is best to use a singular noun prefixed with a shortened version of the product name, for example Get-Proc.

Once we have chosen a name for our cmdlet, define a .NET class to implement the cmdlet, here is the class definition for Get-Proc cmdlet:

[Cmdlet(VerbsCommon.Get, "Proc")]
public class GetProcCommand : Cmdlet 

The class for a cmdlet must be explicitly marked as public. Classes that are not marked as public will default to internal and will not be found by the Windows PowerShell runtime. CmdletAttribute attribute, with the syntax [Cmdlet(verb, noun, …)], is used to identify this class as a cmdlet. This is the only required attribute for all cmdlets, and it allows the Windows PowerShell runtime to call them correctly. It is a good practice to reflect the cmdlet name in the class name. To do this, use the form "VerbNounCommand" and replace "Verb" and "Noun" with the verb and noun used in the cmdlet name.

Cmdlet class can derived from both Cmdlet and PSCmdlet abstract classes. It depends on deep we would like to integrate with PowerShell runtime, let say access to session state data, call scripts etc. When deriving from Cmdlets, we aren't really depend on Powershell. We are not impacted by any changes in PowerShell runtime. Our cmdlet can invoke directly from any application instead of invoking it through the Windows PowerShell runtime. In most cases, deriving from Cmdlet is the common choice.

ps01.jgp 

The Cmdlet class provides three main input processing methods, at least one of which your cmdlet must override.

BeginProcessing
For all types of input, the Windows PowerShell runtime calls BeginProcessing to enable processing. If our cmdlet must perform some preprocessing or setup, it can do this by overriding this method. Windows PowerShell uses the term "record" to describe the set of parameter values supplied when a cmdlet is called.

ProcessRecord
If your cmdlet accepts pipeline input, it must override the ProcessRecord method. For example, a cmdlet might override both methods if it gathers all input using ProcessRecord and then operates on the input as a whole rather than one element at a time, as the Sort-Object cmdlet does.

EndProcessing
This method is used optionally to end the pipeline input. Means that EndProcessing is optional when if we use ProcessRecord method to accepts pipeline input.  If our cmdlet does not take pipeline input, it should override the EndProcessing method. Be aware that this method is frequently used in place of BeginProcessing when the cmdlet cannot operate on one element at a time.

For example, because our sample Get-Proc cmdlet must receive pipeline input, it overrides the ProcessRecord method and uses the default implementations for BeginProcessing and EndProcessing. Some cmdlet might have object variables to clean up when it is finished processing (for example, if it opens a file handle in the BeginProcessing method and keeps the handle open for use by ProcessRecord). It is important to remember that the Windows PowerShell runtime does not always call the EndProcessing method, which should perform object cleanup. For example, EndProcessing might not be called if the cmdlet is canceled midway or if a terminating error occurs in any part of the cmdlet. Therefore, a cmdlet that requires object cleanup should implement the complete IDisposable pattern, including the finalizer, so that the runtime can call both EndProcessing and Dispose at the end of processing.


Here is my simple codes to show OS processes stream :

//This class implements a Get-Proc cmdlet that has no parameters.
[Cmdlet(VerbsCommon.Get, "Proc")]
public class GetProcCommand : Cmdlet
{
    protected override void BeginProcessing()
    {
        base.BeginProcessing();
    }

    protected override void ProcessRecord()
    {
        // Get the current processes from Diagnostic Object
        Process[] processes = Process.GetProcesses();
        WriteObject(processes, true);
    }

}

How to Register Cmdlets
There are two mechanisms that can be used to register our Get-Proc cmdlet:
1 - Extending the shell using a snap-in (commonly used)
2 - Registering with a custom shell

I used the first one using a snap-in. This registration mechanism does not require a new shell, but adds the cmdlet to the current session or a saved session. A Windows Powershell snap-in can register all the cmdlets in a single assembly, or it can register a specific list of cmdlets. Note : snap-in assembly should be installed into a protected directory; otherwise, an unauthorized user could replace your assembly with malicious code.

To write a snap-in that register our cmdlet in its assembly, our snap-in class must derive from the PSSnapIn class. Here our simple codes look like:

  // Create the PowerShell snap-in used to register Get-Proc CmdLet
  [RunInstaller(true)]
  public class GetProcPSSnapIn : PSSnapIn
  {
      //Create an instance
      public GetProcPSSnapIn(): base(){}
     
      // Specify the name of the PowerShell snap-in.
      public override string Name
      {
          get
          {
              return "GetProcPSSnapIn";
          }
      }

      //Specify the vendor for the PowerShell snap-in.
      public override string Vendor
      {
          get
          {
              return "RAM";
          }
      }

      //Specify the localization resource information for the vendor.
      public override string VendorResource
      {
          get
          {
              return "GetProcPSSnapIn,RAM";
          }
      }

      //Specify a description of the PowerShell snap-in.
      public override string Description
      {
          get
          {
              return "This is a PowerShell snap-in that includes the Get-Proc cmdlet.";
          }
      }

      //Specify the localization resource information for the description.
      //Use the format: resourceBaseName,Description.
      public override string DescriptionResource
      {
          get
          {
              return "GetProcPSSnapIn,This is a PowerShell snap-in that includes the Get-Proc";
          }
      }
  }

Using the Windows Powershell snap-in library (.DLL file), register it to GAC using InstallUtil.exe. Remember that we need to sign our cmdlet assembly before register it to GAC. We can use PowerShell to set alias for InstallUtil.exe by the following:

PS > set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil
PS > installutil SelectStrCommandSample.dll

Now we can add the Windows Powershell snap-in to the shell using the Add-PSSnapin cmdlet as shown below. Note : make sure you run the PowerShell using Administrator right.

PS > add-pssnapin GetProcPSSnapIn

To check the registration result, we can run:

PS > get-PSsnapin -registered

DONE

If the operation is successful, we should be able to run our cmdlet

PS > Get-Proc

DONE. Please download source code here. What about the MSMPI stuff??? Just to inform you as a closing, that PowerShell can use any Windows Objects (.NET, COM, WMI, etc). So MSMPI CMDLET should be possible! 


Hope this helps!

Ciao - RAM

Share this post: | | | |

Programming with PowerShell SDK | Part 1

In my previous posting, you may see many strange words, cmdlet (command let), provider, and hosting application. Those are the building blocks of PowerShell. To enable you writing them, you need PowerShell SDK. Windows® PowerShell SDK is part of the Microsoft Windows Software Development Kit for Windows Vista and .NET Framework 3.0 Runtime Components SDK.

ps01

Be aware that the Microsoft® Windows® PowerShell reference assemblies physically are downloaded onto disk (by default at C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0).They are not installed in the Global Assembly Cache (GAC).

ps03
If you go to GAC, you will find PowerShell assemblies as well.


02

Once you know where they are, you are ready to developer your first cmdlet, provider and hosting application. I will show you how to do that for simple cases in Part 2 (again, if I have enough spare time tonight). But the following MSDN articles will be helpful to build your understanding before writing codes. Let say, these are pre-requisites reading :) :

Conceptual
- How Windows PowerShell Works
- Windows PowerShell Programmer's Guide
- Windows PowerShell Object Concepts
- Extending Object Types and Formatting


How To Guidance
- How to Create a Windows PowerShell Cmdlet
- How to Create a Windows PowerShell Provider
- How to Create a Windows PowerShell Hosting Application
- How to Register Cmdlets, Providers, and Host Applications
- Cmdlet Development Guidelines

See you in MSDN Day !

Ciao - RAM

Share this post: | | | |

PowerShell - How It Works

It is important for Geeks to know how thing works before use it. Let me share with you little bit. After you installed PowerShell, check it out at:

Windows/System32/WindowsPowerShell/v1.0.

There are PowerShell.exe plus two DLLs (one for EventLog Message and the other for Crypto SIP). Many files with *.format and *.help extensions, of course for formatting and help description :). What is PowerShell? I profiled it to find its call tree. Let see:

ps08

The result is, PowerShell utilizes 3 additional DLLs on top of mscorwks.dll and BCRYPT.dll :

- Microsoft.PowerShell.ConsoleHost.ni.dll
- System.Management.Automation.ni.dll
- Microsoft.PowerShell.Commands.Utility.ni.dll


Those DLLs are core engine of PowerShell. PowerShell.exe itself is Windows PowerShell hosting application that exposes a command line to the user, and uses a host interface to communicate with the commands invoked by the command line. The hosting application can be a console application, a Windows application, or a Web application, some folks try to make PowerShell WPF Console or develop their own GUI/IDE like Open Source PowerGUI,  so it is completely extensible (click on image to download).

ps03   

In most cases, the hosting application uses its Main function to interact with the Windows PowerShell runtime through the internal host interface; however, a hosting application can optionally support its own custom host by implementing the PSHost class along with one or more related user interface classes. Together, these classes allow direct communication between the application and Windows PowerShell commands. A hosting application derives from PSHost class, overriding the abstract properties and required methods, and then passes an instance of its host class to the CreateRunspace method.

04 

Windows PowerShell runtime is the execution engine. The data retrieved and written by the runtime is in the form of data objects that are compatible with the .NET Framework. Windows PowerShell differs from other command based environments in that it uses objects to pass data through the pipeline. When passing objects through its pipeline, Windows PowerShell wraps each object in a PSObject object that is typically transparent to the user. We can also use the PSObject object to extend the members of objects. This feature, along with adapted views of object, is part of the Extended Type System (ETS) provided by Windows PowerShell. Let me explain ETS little bit more.

Windows PowerShell uses its PSObject object to extend the types of objects in two ways. First, the PSObject object provides a means to show different views of specific object types. This is referred to as showing an adapted view of an object. Second, by wrapping existing objects within the PSObject object, cmdlet and provider developers can add members to the base object. This allows you to manipulate any .NET object within the shell.

ps05   ps06

Invoked as a runspace, the Windows PowerShell runtime normally processes commands synchronously and delivers the results of processing to the hosting application, which then renders the results for the user. In this case, there is only the default interaction between the hosting application and the commands in a runspace. As I mentioned before, Windows PowerShell supports the execution scenario in which the hosting application implements its own custom host. In this case, the runspace is kept open and any number of commands can be run. The custom host can retrieve the results of processing either synchronously or asynchronously.

Windows PowerShell uses the Windows PowerShell provider infrastructure in the Windows PowerShell runtime to manage the Windows PowerShell providers. It normally starts the installed Windows PowerShell providers when it initializes the runspace and the corresponding session state, which tracks the providers in a global dictionary. The session state uses a path search mechanism to find all the *.cmdletprovider files reflected in the PSCOMMANDPATH and PATH environment variables.

ps07 

You can read more about that from this MSDN article. "How Thing Works" knowledge is really important when you want to extend PowerShell. I also suggest you to read PowerShell team blogs. A lot of information there, including new product ideas local ISVs :).

How To Get PowerShell and Its Documentations
- PowerShell 1.0 RTM
- PowerShell v2.0 CTP2
- PowerShell 1.0 Documentation Pack
- PowerShell 1.0 Quick Reference
- PowerShell Graphical Help File

Hope that helps!.

Ciao - RAM

Share this post: | | | |

MSDN Day with PowerShell

This is an invitation to all Geeks to attend Microsoft Developer Network event that will be held on Thursday, July 24, 2008. As always, this event is free, so you can take this as your free learning day every month!. My session is to help build and maintain momentum around PowerShell in a relation to Windows Client technologies, thats why Naren put a cozy "orchestrating" title on my session. 

PowerShell itself is not a big application. Some people think of it like a command line scripting language, such as Perl for example. But for me it depends to how you will use it. Let me give you a Hello Word PowerShell script here:

[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
$form = new-object Windows.Forms.Form
$form.Text = "Welcome to MSDN Day"
$button = new-object Windows.Forms.Button
$button.text="Push Me To Learn Powershell!"
$button.Dock="fill"
$button.add_click({$form.close()})
$form.controls.add($button)
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()

01

Note : I hope you can realize now how big is PowerShell but don't be panic!

Space is big. Really big. You just won’t believe how vastly hugely mind-bogglingly big it is. I mean you may think it’s a long way down the road to the "PowerShell", but that’s just peanuts compared to space. Don’t Panic!

— Modified from : Douglas Adams, The Hitchhiker’s Guide to the Galaxy

MSDN

So, I welcome you to MSDN Day! Come in, learn PowerShell, be creative, and, above all, have fun! To explore more, please read my articles to help you jump into deeper PowerShell exploration.

PowerShell - How it Works
Programming PowerShell SDK | Part 1
Programming PowerShell SDK | Part 2

Hope this helps! 

Ciao - RAM

Share this post: | | | |

Programming Multi-core | Part 2

The message-passing programming paradigm is one of the oldest and most widely used approaches for programming parallel computers. The famous MPI implementation is coming from Argonne National Laboratory. I am just downloaded MPICH2 (portable and high performance MPI API) it and want to share with you my first exploration. It is shipped with both Windows installer and source codes, so you can easily explore it. Please download here:

- MPICH2 - Installer
- MPICH2 - Source Codes
- MPICH2 - Documentation includes Windows Developer Guide

I strongly recommend MPICH2 from Argonne Lab, before you start to jump into Microsoft, HP or Intel implementations. First, because you have MPICH2 source codes to learn deeper, and second, because the codes are portable and came from the root of MPI. In this post, I will give you a quick start on how to compile and use MPICH2 API. I am using Vista SP1 in Intel Centrino Duo machine with Visual Studio C++ 2008 and Windows SDK installed.

1. Windows Binary Distribution
MPICH2 binary distribution uses the MS Installer. Please download and execute mpich2-1.x.xxx.msi to install the binary distribution. The default installation path is C:\Program Files\MPICH2. You must have administrator privileges to install mpich2-1.x.xxx.msi. The installer installs a Windows service to launch MPICH applications and only administrators may install services. This process manager is called smpd.exe. Access to the process manager is passphrase protected. The same passphrase must be installed on all nodes that will participate in a single MPI job.

02 

Under the installation directory are three important sub-directories: include, bin, and lib. The include and lib directories contain the header files and libraries necessary to compile MPI applications. The bin directory contains the process manager, smpd.exe, and the the MPI job launcher, mpiexec.exe. The dlls that implement MPICH2 are copied to the Windows system32 directory. The smpd process manager for Windows runs as a service that can launch jobs for multiple users. It does not need to be started like the *NIX version does. The service is automatically started when it is installed and when the machine reboots and it has additional options:

smpd -start            : Start the Windows smpd service.
smpd -stop             : Stop the Windows smpd service.
smpd -install          : Install the smpd service.
smpd -remove        : Remove the smpd service.
smpd -register spn : Register the Service Principal Name with the domain controller.

SPN command enables passwordless authentication using kerberos. It must be run on each node individually by a domain administrator.

3. Windows Source Distribution
To build MPICH2 from its source distribution on Windows, you will need Visual Studio 2005 or later and Perl. Once you extracted the source codes, please run script : winconfigure.wsf. You can remove FORTRAN if you dont have plan to use it by putting --remove-fortran option. Complete options of configuration are here:

03

If you want to compile the MPICH2 source codes using VC++ 2008 in Vista, there are some adjustment you have to do due to the change of vsprintf and sprintf. Do the following change to mpichconf.h :

#if not defined(_MSC_VER) || defined(__MINGW32__)
   #define snprintf _snprintf
   #define vsnprintf _vsnprintf
#endif


You will also get some error messages because VC++ 2008 can not find some header files. You can fix that by simply add include directories where the header files located. Once you can fix all the errors, you can easily compile MPICH2 source codes of 21 projects using VC++ 2008.

01 

3. Your First MPICH2 Program
You don't have to understand the whole MPICH2 source codes if you only want to use it for your computation. Source code level understanding is required if you want to extend or modify MPI implementation in MPICH2, let say, to match your deployment scenarios or to add more features. For MPICH2 users, what they need to care is the include header files (mpi.h) and library directories. Let start with the example program shipped with MPICH2 binary distribution:

#include "mpi.h"
#include <stdio.h>
#include <math.h>

double f(double);

double f(double a)
{
    return (4.0 / (1.0 + a*a));
}

int main(int argc,char *argv[])
{
    int done = 0, n, myid, numprocs, i;
    double PI25DT = 3.141592653589793238462643;
    double mypi, pi, h, sum, x;
    double startwtime = 0.0, endwtime;
    int  namelen;
    char processor_name[MPI_MAX_PROCESSOR_NAME];

    MPI_Init(&argc,&argv);
    MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
    MPI_Comm_rank(MPI_COMM_WORLD,&myid);
    MPI_Get_processor_name(processor_name,&namelen);

    /*
    fprintf(stdout,"Process %d of %d is on %s\n",
        myid, numprocs, processor_name);
    fflush(stdout);
    */

    while (!done) {
        if (myid == 0) {
            fprintf(stdout, "Enter the number of intervals: (0 quits) ");
        fflush(stdout);
            if (scanf("%d",&n) != 1) {
        fprintf( stdout, "No number entered; quitting\n" );
        n = 0;
        }
        startwtime = MPI_Wtime();
        }
        MPI_Bcast(&n, 1, MPI_INT, 0, MPI_COMM_WORLD);
        if (n == 0)
            done = 1;
        else {
            h   = 1.0 / (double) n;
            sum = 0.0;
            for (i = myid + 1; i <= n; i += numprocs) {
                x = h * ((double)i - 0.5);
                sum += f(x);
            }
            mypi = h * sum;
            MPI_Reduce(&mypi, &pi, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);

            if (myid == 0) {
                printf("pi is approximately %.16f, Error is %.16f\n",
                       pi, fabs(pi - PI25DT));
        endwtime = MPI_Wtime();
        printf("wall clock time = %f\n", endwtime-startwtime);          
        fflush( stdout );
        }
        }
    }
    MPI_Finalize();
    return 0;
}


To compile above codes in VC++ 2008, just make sure you have set the additional include and library link directories the project property of VC++ 2008. Then after compiled the codes, please run it with mpiexec.exe. Student can use VC++ 2008 Express Edition, which is free to download. I am waiting my new machine to be able to show how it really works. MPICH2 use WinSock for communication between processes. I hope you will not wait too long to see how it can be used for Numerical Computation and Computational Physic!

Hope this helps!


Ciao - RAM

Share this post: | | | |

SSCLI 2.0 with VC++ 2008 on Vista

I tried to compile SSCLI 2.0 with VC++ 2008 on Vista, and again, too many error messages, due to :

- Change of Windows Vista SDK include path and directory name
- SUBSYSTEM_WINVER = ,4.00 and SUBSYSTEM_CONVER = ,4.00 changed to ,5.00
- Incompatible warning level = -Wp64 (I am using 32 bit)
- Change of compiler (_MSC_VER ==1500) & runtime versions (_MSVCRT MSVCR90)

Basically you can do find and replace through all SSCLI source codes, but I strongly suggest you to follow Jeremy Kuhne manual steps. Once you done, just run env.bat and then buildall again. He also gives useful tips regarding the MSBUILD and VS Template for SSCLI.

Enjoy learning CLR through SSCLI Codes!

Ciao - RAM

Share this post: | | | |

LaTeX Equation Editor from CodeCogs

CodeCogs is an collaborative open-source library developed by community, with numerical components in C/C++ that can also be downloaded as Excel addins or used interactively through any website. CodeCogs goal is to create a well documented source of numerical solutions in all areas of engineering, computing, mathematics, science and finance. Great huh! I will spend time looking on their numerical library later on, but I want to share with you a cool thing, CodeCogs LaText Equation Editor.

01

Simple, first, please visit here, then try out the editor. Once you have done, test it with Render Equation button. You can copy the resulted HTML codes to your blogs. For example:

LaTeX                : \int_{0}^{10}\alpha \beta \gamma xdx
HTML Code        :

<a href="http://www.codecogs.com">
   <img src=
http://www.codecogs.com/gif.latex?\int_{0}^{10}\alpha&space;\beta&space;\gamma&space;xdx
            alt="\int_{0}^{10}\alpha \beta \gamma xdx" border="0"/>
</a>

Then put HTML code above into your Windows Live Writer (make sure you use HTML Mode). The result is:

\int_{0}^{10}\alpha \beta \gamma xdx 

CodeCogs LaTeX Equation editor can give you PDF, JPG, GIF, PNG and SWF format. Can anyone make it as Windows Live Write plug-in? Thats will be helpful.

Ciao - RAM

Share this post: | | | |

Weekend with Scientific Developer

I spent my weekend with my junior folks in Prof. Rosari Saleh research group. The problem was, I couldn't stop work if I have something cool (Geeks Syndrome). I just started my scientific blogs (RAM on Scientific Computing) and start working to coach my junior through KucingFisika.com and MIC-UI C++/Win32 Courses. Sagi and Wiria from Win32 Company was helping me much to encourage those scientific folks, and I am happy to let you know that "a new wave" is just started. We still have long journey to arrive at Parallel stuffs. Be patient!.

Below is the starting point :

- Welcome to KucingFisika
- Part 1. C++ /Win32 Programming at MIC-UI
- Additional C++ Texts for KucingFisika
- Mengintip Ke Luar Angkasa dengan WWT
- MPI.NET | Message Passing with C#
- Getting Numerical Recipes C++ Codes
- Numerical Recipes Tutorial - Part 1

Thats all for last week. See you this weekend with Scientific Computing. I possibly move my next lecture to Friday, July 18, 2008, because I will have vacation with family for Razka birthday (July 20, 2008).

Hope this helps!. 

Ciao - RAM

Share this post: | | | |