Profilo di Ashish"Getting better never st...FotoBlogElenchiAltro Strumenti Guida

Blog


22 novembre

Software engineer and the social service

I have been working as a .NET developer for quite some time now. I always wanted to be a doctor. I thought that is the most nobel profession you can ever have. Because when your loved one is sick you look up to that doctor after you pray to the god. So, if you are a doctor, you have the best opportunity to serve the human kind and the society. Now I could not be a doctor of course :-). Recently I heard Jeffery Ritcher saying that he wanted to write books because he thinks that when he write books/articles, he is helping people. Because he runs into people who say that they got a job when they read his book and they learnt how garbage collector works. So, he feels incredibly awesome that because of his book, somebody got a job and could support family and children and he helped in that. He also comes across some people who say that this software which is running in this hospital, they learnt how to work with virtual memory from his book and they put that in that software and that makes him feel that he is making a massive impact to the society with this little contribution to the hospital helping people's lives. He says that this is the reason he writes books because he is helping the world to be a better place. What a nobel thought and no doubt why he is a hero many developers like me!

Now we all know that we all  can't be a Jeffery Ritcher. But It gets to me this thinking that you can serve society this way (or can think some other ways), something which I never thought of. hmmm...

02 ottobre

Difference between RPC and Document-Centric/Message Oriented application

With Document/Literal encoding/ Message oriented application, the payload of a message is an XML fragment that can be validated against the corresponding XML schema, for instance:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:mi="http://www.somedomain.com/xyz/message-id"
    xmlns:proc="http://www.somedomain.com/xyz/processed-by"
    xmlns:po="http://www.books.com/purchase">
    <soap:Header/>
    <soap:Body>
        <po:purchaseOrder orderDate="2008-09-22"
            xmlns:po="http://www.somedomain.com/xyz/PO">
            <po:accountName>Books.com</po:accountName>
            <po:accountNumber>923</po:accountNumber>
            ...
            <po:book>
                <po:title>Air Guitars In Action</po:title>
                <po:quantity>300</po:quantity>
                <po:wholesale-price>14.99</po:wholesale-price>
            </po:book>
        </po:purchaseOrder>
    </soap:Body>
</soap:Envelope>

RPC (remote procedure call)/Literal more closely corresponds to remote procedure invocations.
For instance, the method: public float getBookPrice(String inISBN) would correspond to the following RPC/Literal request message:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sd="http://www.somedomain.com/xyz/BookQuote">
   <soap:Body>
      <sd:getBookPrice>
          <isbn>0321146182</isbn>
      </sd:getBookPrice>
   </soap:Body>
</soap:Envelope>

One important difference between RPC and Document web services is that with RPC web services, XML schema will only be created for complex type parameters. It is thus not possible to validate the entire XML fragment contained in the SOAP body.
With Document web services, however, the XML schema needs to define the ENTIRE XML fragment contained in the SOAP body. Consequently, the entire message can be validated against the XML schema.

20 settembre

SQL Server –Error - The FOR XML clause is not allowed in a INSERT statement. - Returning the result of a FOR XML, ELEMENTS in a dynamic query to a variable

Problem :-

When you try to execute a dynamic query having the FOR XML AUTO like this (ignore the query itself for now, you can find the complete script at the end of this article):-

DECLARE @Data2 TABLE(col xml)
DECLARE @Query nvarchar(max)
SELECT @Query= 'SELECT Customer.CustomerID,Address.FullAddress,Phone.PhoneNumber
FROM #tempCustomer Customer
JOIN #tempAddress Address ON Address.CustomerID= Customer.CustomerID
JOIN #tempPhone Phone ON Phone.CustomerID= Customer.CustomerID
FOR XML AUTO, ELEMENTS
'
INSERT @Data2 exec (@Query)

You get an error like the following

"The FOR XML clause is not allowed in a INSERT statement.”

From http://msdn.microsoft.com/en-us/library/aa226520(SQL.80).aspx:-

image

The above is applicable for SQL server 2005 as well. Very annoying…

However, if you have something like below, the query would get executed successfully:-

SELECT @Query= 'SELECT ( SELECT Customer.CustomerID,Address.FullAddress,Phone.PhoneNumber
FROM #tempCustomer Customer
JOIN #tempAddress Address ON Address.CustomerID= Customer.CustomerID
JOIN #tempPhone Phone ON Phone.CustomerID= Customer.CustomerID
FOR XML AUTO, ELEMENTS ) '

 

Notice that I prefixed the query with ‘SELECT(‘ and suffixed it with ‘)’. This would allow the query to execute but to return the data in text format rather than XML. However, you can have the result stored in a column of XML data type of a temporary table/variable and It would appear as if the result was XML.

So we need to stuff the prefix and then the suffix in the query. Here is where the STUFF function would come to rescue. It is different from REPLACE function as it allows you to replace a specific instance of a character for a length.

The complete query :- (Just run it)

/* Temporary table to hold sample data. Forgive me for not using the table variable as they would be out of scope when I would use them in the dynamic query*/
if OBJECT_ID('tempdb..#tempCustomer') is not null
BEGIN
DROP TABLE #tempCustomer
END
CREATE TABLE #tempCustomer (CustomerID INT)


if OBJECT_ID('tempdb..#tempAddress') is not null
BEGIN
DROP TABLE #tempAddress
END
CREATE TABLE #tempAddress (CustomerID INT,FullAddress VARCHAR(100))

if OBJECT_ID('tempdb..#tempPhone') is not null
BEGIN
DROP TABLE #tempPhone
END
CREATE TABLE #tempPhone (CustomerID INT,PhoneNumber VARCHAR(100))

/* Insert sample data*/
INSERT #tempCustomer VALUES(1)
INSERT #tempAddress VALUES(1,'Some Address')
INSERT #tempPhone VALUES(1,'212-111-2222')
INSERT #tempCustomer VALUES(2)
INSERT #tempAddress VALUES(2,'Other Address')
INSERT #tempPhone VALUES(2,'212-777-8888')

/* Build the dynamic query*/
DECLARE @Data2 TABLE(col xml)
DECLARE @Result XML
DECLARE @Query nvarchar(max)
SELECT @Query= 'SELECT Customer.CustomerID,Address.FullAddress,Phone.PhoneNumber
FROM #tempCustomer Customer
JOIN #tempAddress Address ON Address.CustomerID= Customer.CustomerID
JOIN #tempPhone Phone ON Phone.CustomerID= Customer.CustomerID
FOR XML AUTO, ELEMENTS'

/* There can be many 'SELECT' in the query, we need to get the last one as that would be the one
which is having the FOR XML AUTO, ELEMENTS .
So, reverse the string and get the first index of the 'select'
and then stuff the reverse of ‘SELECT (‘ and ‘)’ and reverse the result again to get the correct
string*/
--PRINT @Query
SELECT @Query=REVERSE(  @Query)
--PRINT @Query
DECLARE @FirstIndexOfSelect INT
SELECT @FirstIndexOfSelect = CHARINDEX(REVERSE('SELECT') , @Query )
--PRINT @FirstIndexOfSelect
SELECT @Query =STUFF(@Query,@FirstIndexOfSelect,6,REVERSE('SELECT (SELECT'))
SELECT @Query=REVERSE(@Query)+')'
--PRINT @Query
INSERT @Data2 exec (@Query)
SELECT @Result =Col FROM @Data2
SELECT @Result

19 settembre

Procrastination

Procrastination - “is a behavior which is characterized by the deferment of actions or tasks to a later time” and its better explained here.
A funny example is in an excellent you tube video her

 

e.

The problem
---------------
I truly believe that procrastinate because of most importantly the lack of focus among many other reasons.
I procrastinate because I think even if I study, I wont get anything and there is no point spending time..there is too much to study. Even if I start I wont be able to study a lot and if I don't, there is no point studying.

This is how I try to overcome this?
---------------------------------------
- Study short items and not too many items and be aware that you have studied them and take 15 minutes in a day to remind them to yourself.
- Do not think that you have studied less at any point of time.
- Get the gist of the short items and get that as fast as you can.
- Take frequent breaks.
- Do not think of anything while studying irrespective of whatever it is about.
- Think whatever you are doing now is moving you towards your goal and the goal is that short item you are focusing on and studying.

 

N.B. :- The funny thing is I procrastinated for writing this blog entry itself for 3 days. :-) See the point I am making above. ;-)

06 settembre

Programmatically showing only the custom styles in the style pane of a Word 2007 file

 

The project in which I working nowadays is a content authoring and management system and makes extensive use of Word 2007. The system has two parts in context of the problem I am going to discuss about – One part where the Admin uploads a Word 2003 (.doc) file containing all the custom styles created in there into the system. Let us call this file as a word template. The second part is where the user uploads his own content files Word 2003 (.doc) files in the system. When the user uploads the content in the system, the styles from the word template gets into the to the uploaded content file (more on this later). This facilitated the styles being introduced in the system only once (or whenever the Admin wants) using the template and the same styles getting used in all the content files without having the user to recreate them in each content file. This also offered the consistency in the styles used in the content files used in the system.

Problem :- When the user uploads the content and then later opens the content for editing, he was seeing the inbuilt styles as well and they wanted only the custom styles and “Clear Formatting” option to be seen in the content file. Silly , isn’t it. But this is was requirement.:-)

Just to make sure we we are all clear on what an in-built and what a custom style is :-

 

Open Word 2003 and choose Format > Styles and Formatting and what ever styles you see in the style pane are all in-built styles.

image 

And you can create a new style by clicking on  the “New Style” button. I created one “MyCustomStyle”. So this is the custom style in my file.

image

I need to take the attention back to my following line which I mentioned earlier :-

“When the user uploads the content in the system, the styles from the word template gets into the to the uploaded content file (more on this later). “

The way we do this is following :-

1. Convert the template word 2003 file to word 2007 format using a third party component named “Aspose.Words.dll” (www.aspose.com)
2. Convert the content word 2003 file to word 2007 using Aspose.Words.dll.

Just in case you are not aware, a Word 2007 file is an archive/zip file. You can rename any Word file (.docx) to zip file and extracts its contents as if it was a Zip file. When you look into the contents of that zip file, you will see each component of the word 2007 being represented by a file. Read about this here.
3.Copy the custom styles in the style.xml of template file to the style.xml content file.
4. Convert the content word 2007 file back to word 2003 using Aspose.Words.dll.

All the above four steps happen while the user attempts to open the file and when the file was ultimately opened, he sees the inbuilt styles as well along with the custom styles which is the problem.

When I started looking into the problem(an you, dear reader must have realized by now for sure), it seemed that user can always filter the custom styles:-

image

However, this is exactly what the users of the application did not want to do. So the effort of convincing them was in vain.

So, first I started looking at if Aspose.Words.dll offers any API to change the filter to show only the custom styles in the word 2003 file, when we convert the content 2007 file back to 2003. It turns out that It does not and a request for incorporating that change would take months.

I started looking at any other commercial product which would do a better job than Aspose and even the using Office Migration Utility(OFC) and wordconv.exe (comes with the Office compatibility pack). Those did not help either.

So then I looked at if we can find something in the files in the content word 2007 archive itself. There must be something in that archive which is telling Microsoft Word 2007 which types of styles to show in the style pane.

I came across an article at http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.stylepaneformatfilter(office.14).aspx

Which states that For this , the w:stylePaneFormatFilter element in the settings.xml of the docx file can have the following values:-
          0x1000 -  Specifies that a style should be present which removes all formatting and styles from text.
          0x0002 - Specifies that only styles with the customStyle attribute should be displayed in the list of document styles.
So I sum the hex values above to get 1002 to show both Custom Styles and the Clear Formatting.
       

To test this, I created a new file in Word 2007 and created a new style named “MyCustomStyle” in it.

image

Then I rename that .docx file to .zip and then unzipped the same:-

image renamed to image

and extracted and navigate to Word folder to see the Settings.xml:-

image

Opened that file and see the following structure :-

image

I added the following node right under the root of the xml:-
<w:stylePaneFormatFilter w:val="1002"/>

image 

Updated the zip file and renamed the zip file back to docx and opened the docx file and saw only my custom style and “Clear All”!

image

15 agosto

Accessing user control's control from the ASPX page‏

 

Ok, I know, I know! ?This is something you must be wondering like "Why this guy is so scre*** up and he had to blog about this". But I got into this problem last week and an realized that I have seen this problem and addressed this ..but just forgot about. So why not just blog about this. At least for myself :-). So, forgive me folks!!

Using user control from the ASPX page:-

The goal was to access the user control’s control from the ASPX page. First I started looking into why that control in the user control wont be available in the page load of the ASPX page. I could have debugged it. But I thought enabling tracing in and looking into the traces would be a better idea. So I added the trace switch in the web.config (I could have done this on that page itself, but I just did that in the Web.config.). I use the following tag in the Web.config under <System.Web>:-

<trace enabled=”true” pageOutput=”true”/>

clip_image002

Then I put the some Trace.Write statement in the Page_Load of the user control. Notice this is the method where the menu control is getting created (getting populated with the child control). I put the Trace.Write statement at the end of the Page_Load event handler.

clip_image004

I put the Trace.Write statement in the Page_Load of the ASPX page as well at the end.

clip_image006

Now, when I try accessing the aspx page, It would give all the tracing information right from “PreInIt” to “Render” along with all the information on the controls on this page.

Notice that the Trace.Write statement from the user control is after the same from the ASPX page which implies that the page load of the user control is fired after the page_load of the ASPX page and hence the user control’s control collection wont be available in the aspx page.

clip_image008

Now, there is another event named Page_PreRender which fires after the page load and you can tweak the controls before thry get Rendered to the page. You can override that event handler as given below.

Notice that in the below screenshot the user control’s(UserStatus1) control(userMenu) is being accessed and is getting modified. To show that this would work, there is a Trace.Write right at the end of the end of this event handler.

clip_image010

See the Trace.Write statement (highlighted) in between the Begin PreRender and End PreRender.

clip_image012

30 giugno

The SOAP vs REST

A very interseting comparision of REST vs SOAP :-
 
An analogy of SOAP and REST is an envelop vs a postcard (which one is bulky..huh..! :-) )
07 giugno

Create a RESTful service using WCF

 

Ok,so I decided to learn creating the REST services using WCF.
First I had to download the following :-

a) WCF REST Starter Kit Preview 2

image

After you have installed the starter kit,you should see a set of templates under “File > New > Project”:-

image

06 giugno

Roadmap to learn REST (Representational State Transfer)

1) What is REST?
    a)Definition
    b)Tenets of REST ful services
    c)High REST and Low REST ful service   (“ 302- Object moved”  :-) - to the last point I need a lot to learn before I get back to this)
    d)Ways to develop REST ful services.

Question :- Are you comfortable confident in in REST for what you have read till now?

  1. 2) REST ful services using WCF
        a) How to map REST verbs with HTTP verbs
        b) Reading HTTP specification for the GET,POST,PUT and DELETE

Question :- Are you comfortable confident in in REST for what you have read till now?

    c) How to create a REST ful service?
        i) Get comfortable with the different templates of the REST starter kit.
        i) Making use of GET,POST,PUT and DELETE
        ii) When to use POST,PUT and DELETE
            Get the examples.
Question :- Are you comfortable confident in in REST for what you have read till now?
    d) How to consume a REST ful service?
        Create examples which do the following:-
            i) Use Yahoo search
            ii) Use Google search
            iii) Use Twitter
    e) Caching with REST
    f) Database operations with REST
Question :- Are you comfortable confident in in REST for what you have read till now?

1) c)High REST and Low REST ful service
Reading material :-
a) http://www.mnot.net/blog/2006/03/20/hi_lo
b) http://lesscode.org/2006/03/19/high-low-rest/

I started here at 12:33 PM 6/6/2009:-

What is a Service ?
- Means to get the resources get some operations done
What is REST ?

REST is an architectural style for building resource oriented services by defining the resources that implement uniform interfaces using standard HTTP verb LIKE Get,POST,PUT and DELETE.

Tenets of REST ful service:-
1)  Use the URI to locate the resources.
2)  Use the verbs to work with resources.
Get the resource :- GET
Do something with the resource :- POST,PUT,DELETE
3) The content type of the data sent to/received from the services is the object model
XML,JSON
4) Result of a service request is nothing but the HTTP result code.
200- OK,404-Not found

kcron This is from Ron Jacobs:-
Internet is a web of pages,right? and has following characteristics:-
A) Simple and Open

Addressing scheme – URI
Application Protocol – HTTP
Representational format – XHTML
Response codes – HTTP status

B) Scales best when

Stateless
Cached

C) Hyperlinks!- and right, internet would just suck if there are no links!

If you look at how we write web services,you see that we follow SOAP which in no doubt an incredible way of interoperability between the clients and the services.
Now HOLD ON.. before I say something anything against SOAP,why not consider something which also does the same/similar thing in a simplistic way. This makes us look at the ways how we can make “web of services” work like the “web of pages”.

 

    a) How to map REST verbs with HTTP verbs
    b) Reading HTTP specification for the GET,POST,PUT and DELETE

Have a look :-
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

Look at sections 9.3 for GET,9.5 for POST ,9.6 for PUT and 9.7 for DELETE. Here is the following:-

 

9.3 GET

The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process.

The semantics of the GET method change to a "conditional GET" if the request message includes an If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring multiple requests or transferring data already held by the client.

The semantics of the GET method change to a "partial GET" if the request message includes a Range header field. A partial GET requests that only part of the entity be transferred, as described in section 14.35. The partial GET method is intended to reduce unnecessary network usage by allowing partially-retrieved entities to be completed without transferring data already held by the client.

The response to a GET request is cacheable if and only if it meets the requirements for HTTP caching described in section 13.

See section 15.1.3 for security considerations when used for forms.

9.5 POST

The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:

      - Annotation of existing resources;
      - Posting a message to a bulletin board, newsgroup, mailing list,
        or similar group of articles;
      - Providing a block of data, such as the result of submitting a
        form, to a data-handling process;
      - Extending a database through an append operation.

The actual function performed by the POST method is determined by the server and is usually dependent on the Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a database.

The action performed by the POST method might not result in a resource that can be identified by a URI. In this case, either 200 (OK) or 204 (No Content) is the appropriate response status, depending on whether or not the response includes an entity that describes the result.

If a resource has been created on the origin server, the response SHOULD be 201 (Created) and contain an entity which describes the status of the request and refers to the new resource, and a Location header (see section 14.30).

Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.

POST requests MUST obey the message transmission requirements set out in section 8.2.

See section 15.1.3 for security considerations.

 

9.6 PUT

The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request. If the resource could not be created or modified with the Request-URI, an appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a 501 (Not Implemented) response in such cases.

If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those entries SHOULD be treated as stale. Responses to this method are not cacheable.

The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires that the request be applied to a different URI,

it MUST send a 301 (Moved Permanently) response; the user agent MAY then make its own decision regarding whether or not to redirect the request.

A single resource MAY be identified by many different URIs. For example, an article might have a URI for identifying "the current version" which is separate from the URI identifying each particular version. In this case, a PUT request on a general URI might result in several other URIs being defined by the origin server.

HTTP/1.1 does not define how a PUT method affects the state of an origin server.

PUT requests MUST obey the message transmission requirements set out in section 8.2.

Unless otherwise specified for a particular entity-header, the entity-headers in the PUT request SHOULD be applied to the resource created or modified by the PUT.

9.7 DELETE

The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response is given, it intends to delete the resource or move it to an inaccessible location.

A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not include an entity.

If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those entries SHOULD be treated as stale. Responses to this method are not cacheable.

 

Although HTTP fully supports CRUD, HTML 4 only supports issuing GET and POST requests through its various elements. This limitation has held Web applications back from making full use of HTTP, and to work around it, most applications overload POST to take care of everything but resource retrieval. HTML 5, which is currently under development, plans to fix this by adding new support for PUT and DELETE.

GET, HEAD, and OPTIONS are all examples of safe methods that aren’t intended to have side effects. All safe methods are also idempotent, as are PUT and DELETE, so you should be able to repeat them multiple times without harm. The POST method is something of a special case. According to the HTTP specification, POST should be used to provide a representation that can be treated as a subordinate of the target resource. For example, you could POST a new blog entry to the URI representing the blog feed, causing a new blog entry to be added to the feed. POST can also be used to process a block of data such as the data transmitted by an HTML form. The actual function performed by the POST method is defined by the server. Therefore, POST cannot be considered safe or idempotent by clients.

HTTP also defines a suite of standard status codes that specify the result of processing the request. Status codes are organized into ranges that mean different things. For example, status codes in the 200 range mean “successful” while status codes in the 400 range mean the client issued a bad request. Figure 2 describes each status code range and provides a few examples of common status codes.

28 gennaio

Quickly open a file in VS2005/VS2008

Just in case you know the name of a file and want to open the among many without finding in the solution explorer,check out the following option in the VS.NET.
Just type "> open" followed by first few characters of the file in the "Find" in the toolbar and it would give you all the matching results(irrespective of the location or extensiton). You just hit enter on the file you want to open.

Update  :- And how to go to that Find bar in the VS 2008. Just hit Ctrl+/ and you are there! :-)Just hit Ctrl+/ and you are there! :-)

 
 
26 gennaio

ASP.NET performace tricks

Performance Issues in ADO.NET DataTable Usage - Use Enum to Access Items in DataRow http://www.knowdotnet.com/articles/adoenums.html
03 gennaio

Lyrics - "You had me from hello" - song by Kenny Chesney

If there is one reason why I started liking country music,it is because of Kenney Chesney. He is an outstanding country singer and following is lyrics of one of the songs I really like. Its "You had me from hello".
 

One word, that's all you said
Somethin' in your voice caused me to turn my head.
Your smile, just captured me
And you were in my future as far as I could see
And I don't know how it happened, but it happened still
You asked me if I love you, if I always will

Well you had me from "Hello"
I felt love start to grow
The moment that I looked into your eyes, you won me
It was over from the start
You completely stole my heart
And now you won't let go
I never even had a chance you know
You had me from "Hello"

Inside, I built a wall
So high around my heart, I thought I'd never fall
One touch, you brought it down
The bricks of my defenses scattered on the ground
And I swore to me I wasn't gonna love again
The last time was the last time I let someone in

But you had me from "Hello"
I felt love start to grow
The moment that I looked into your eyes, you won me
It was over from the start
You completely stole my heart
And now you won't let go
I never even had a chance you know
You had me from "Hello"

That's all you said
Somethin' in your voice caused me to turn my head
You had me from "Hello"
You had me from "Hello"
Girl I've loved you from "Hello"

 
Some of his many gems are-
 
 
28 dicembre

My introduction to the Assembly Language

So,I started studying Assembly Language.It is very silly to say that it is interesting language at the first glance when you look at those hexadecimal codes with some weird command like MOV on the command prompt and also when you are coming from working on all the high level languages like C++,Java and C#.However,there is no denial to the fact that you start to learn a lot about the CPU architecture especially "registers". Most important thing is Assembly language is just one level up from the machine language and hence are bound to be real fast compared to the high level (read "layered/abstract/sugar coated") languages. I would be really cool if I can get my fundamentals straight out here and then get into something real deep. I am sure it would help me in writing efficient code (or better understanding) in the language I speak,C# ! :-) Why Assembly language all of a sudden?? Ok,ok,let me confess,it is one of the papers in my MS (Computer Science) degree. :-). I realized that this subject (which I have never worked on),deserves some time to be understood and and there is an opportunity to learn a new thing. See..I am thinking! :-)

I started with real basic introduction and a good place is http://www.swansontec.com/sprogram.htm. Which basically says that the Assembly language is a mnemonic language i.e. a set of instructions mapping to the machine language. It has a pretty small but basic example of creating a assembly language program.

I read about the Assemblers and Loaders which,respectively are responsible for converting the Assembly language to the machine language and loading the machine language to the memory.

26 dicembre

"kaise Mujhe Tum Mil Gayee" - From Ghajini

 
Just in case you cant see the video above..following is the link:-
 
Of all the songs from the soundtrack of Ghajini, my favorite is Kaise Mujhe Tu Mil Gayi. A great composition by A R Rehman, the lyrics by Prasoon Joshi,as usual are are really deep and meaningful. Listen to the song at the dead of the night and you'll really like it.

Hoo hooo oooo..
Hoo hoo hooo…
Oooo..hoo…hooo..oooo
Hooo hooo…

Kaise mujhe tu mil gayi,
Kismat pe aaye naa yaakeen,
Utar aayi jheel mein jaise chand utarta hai kabhi,
Haule haule dheere se,
Gunguni dhoop ki tarah se taranum mein tum,
Choo ke mujhe guzari hu yu,
Dekhu tumhe ya mein sunu,
Tum ho sukoon, tum ho junoon,
Kyu pehle naa aayi tum?
Kaise mujhe tu mil gayi, hoo hoo..
Kismat pe aaye naa yaakeen, hoo hoo..

Mein to yeh sochta tha ki aaj kal,
Upar wale ko fursat nahi,
Phir bhi tumhe bana ke woh,
Meri nazar mein chadh gaya,
Rutbe mein woh aur badh gaya..

Aaaa..aaaaa…
Aaaa..aaaa….
Hoo..hoo…hooo..

Badle raaste jharne aur nadi,
Badli deep ki timtim,
Chedhe zindagi dhun koi nayee,
Badli barkha ki rimjhim,
Badlengi rituyein adaa,
Par mein rahungi sada,
Ussi tarah teri bahon mein baahein daalke,
Har lamha, har pal..

Aaaa..aaaaa…
Aaaa..aaaa….
Zindagi sitar ho gayi,
Rimjhim malhaar ho gayi,
Mujhe aata nahi kismat pe apni yakeen,
Kaise mujhko mili tum
29 novembre

Gazal by Jagjit Singh - Hai Lau Zindagi

 
This is one of the numerous beautiful gazals from Jagjit Singh. I first heard this in a documentary named "Hello Zindagi" on Doordarshan hosted by Nalini Singh. I loved this song and after some searching I got this.
 
 
Lyrics:-
 
hai  lau  zindagi...zindagi noor hai
magar isme jalne(?) ka dastoor hai

adhoore se rishton me jalte raho
adhoori si sasson me pal te raho...
magar jiye jaane ka dastoor he...

rawayat hai ke zindagi gahana hai
ya heera hai aur chatate rahana hai
Ke lamhon main marne kaa dastoor hai-2

If you see a spelling mistake and ,please ldo me a favor to let me know and I would correct the same..

Thanks,
Ashish


08 agosto

Nice add-ins for Reflector

Nice add-ins for Reflector:-
 
 
(if you dont have reflector,download the same from http://www.aisto.com/roeder/dotnet).
 
One of the very useful add-in is the "diff" add-in. Which would point out the differences between the two versions of the same assemblies including any added/changed/deleted members/methods.
And also the "File Diassembler" where all you have to do is provide the assembly (with the dependent assemblies) you want to disassemble and it would generate the class library out of the same with all the source code.
Others are code search,Code Metrics and many more.
 
In order to use an add-in in the Reflector :-
a) Copy the all the binaries for the add-in in the same directory as the Reflector.exe.
b) In the reflector,View > Add-In. In the Add-ins dialog,Add the dll for the Add-in.
c) You should see the added "Add-In" under Tools menu.   
 
23 luglio

Gios PDF .NET library

Very sleek open source PDF creation library built in .NET and its up for commercial use.

http://www.codeproject.com/KB/graphics/giospdfnetlibrary.aspx

Use sections in the config file and access them...

(NameValueCollection)ConfigurationManager.GetSection("applicationSettings/ConnectionStrings");

for the following XML fragment in the config file:-
 
<applicationSettings>
<ConnectionStrings>
<add key="DevConnectionstring" value="server=myserver1;database=mydatabase;uid=ashish;pwd=password"/>
<add key="QAConnectionstring" value="server=myserver2;database=mydatabase;uid=ashish;pwd=password"/>
<add key="ProdConnectionstring" value="server=myserver3;database=mydatabase;uid=ashish;pwd=password"/>
</ConnectionStrings>
</applicationSettings>
02 giugno

Visual studio 2005 Build error :- The volume for a file has been externally altered so that the opened file is no longer valid

Just clean the solution and rebuild.
 
Just dont have any idea why the above error happened this morning when I tried to add some code to a windows service and tried to build the solution.But it has a simple resolution,just clean the solution. :-)  [Solution Explorer > Right click on the Solution> Select "Clean Solution"].
 
 
 
26 maggio

Convert string to byte array and viceversa

                   byte[] elementByteContent= contentObject.Content; //  this  byte array content
                    string elementStringContent = System.Text.Encoding.UTF8.GetString(elementByteContent);
                    elementStringContent = elementStringContent.Replace(" ", "");
                    if (elementStringContent == string.Empty)
                    {
                        elementStringContent = "<P>&nbsp;</P>";
                        contentObject.Content = System.Text.Encoding.UTF8.GetBytes(elementStringContent);
                    }