Saturday, October 25, 2008

Давеча закончил читать “Just for Fun” Линуса Торвальдса и Дэвида Даймонда. Ничего так, вставило. Много чего интересного вынес из этой книги. Линус всю дорогу промывал мозги своей теорией об открытых исходниках, и у него неплохо получалось. Парень временами страдает манией величия в ярко выраженной форме, но надо отдать ему должное это случается редко. После прочтения мне захотелось поставить дистрибутив линукса (Ubuntu наверное) и попробовать снова разобраться в этой системе. Снова, потому что лет 6 назад я было попробовал с RedHatом каких-то ранних версий и что-то ничего не вышло :(. Да и поковыряться в Mono давно хотелось, а лучше этим заниматься конечно в линуксе.
Жду зарплаты, покупаю новый компьютер иншаАллах и ставлю на него второй системой Ubuntu – решено :)

Wednesday, October 22, 2008

DevDays 2008

I've just came back from Microsoft's TechDays event. They have combined seminars for IT-specialists (TechDays) and for the developers (DevDays) into one session - TechDays. But it was DevDays actually (only one day in spite of plural) :). Very interesting and helpful for me was presentation of Gaidar Magdanurov about optimization of ASP.NET applications. Also I was surprised with Michail Chernomordikov's presentation about new version of Silverlight. It is very promising. So the impression is positive - nice organization and good quality of presentation. Keep up good work guys.

Saturday, October 18, 2008

Max Frei Books

I've finished reading Max Frei "The Labirints of Echo" series of books recently. Very interesting and easy to read, fresh and funny. :) Max is very unusual author. Here is what Wikipedia says about him:
Max Frei is the fictional narrator of ten Russian fantasy novels which make up the series called The Labyrinths of Eho ("Лабиринты Eхо"), as well as several other novels. He is also presented as the author of these and other works, being a pen name for the two writers (Svetlana Martynchik and Igor Stepin) who actually wrote them.
The books making up The Labyrinths of Eho desribe how Max, born in our world and having lived his first 30 years here, ends up in the city of Eho in another world, having been called there by the chief of the Secret Police, Juffin Halli. As Max gets acquainted with his new world, he discovers that he was called to Eho to be Juffin's Night Face, i.e. be his representative and second-in-command during the night shift.
Various adventures follow Max, and he always gets inadvertently involved, usually in the midst of things. Fate likes him, and everything happens for a reason. He discovers that he can do magic, more so than the other people he works with. He is special, and no one lets him forget it for a second. His life as described in the novels is full of serendipity and fateful encounters and events, and the books themselves are highly philosophical while being written as fantasy-comedy.

Sunday, October 12, 2008

Witr after tarawih salaat

The witr salaat had been performed after a tarawih salaat at one of the mosques in Makhachkala.


Saturday, October 11, 2008

Using XSLT files with the new XMLDataSource control

I’ve spent almost 2 hours trying to add XMLDataSource to my project and all my attempts were unsuccessful. After some googling I’ve found wonderful article that describes exactly the same problem as for me. So I’m reprinting it here.


VS 2005 RTM (.net framework 2.0)
Target: Intermediate Developers

Consider you have an XML file like this:

 

<Employees>

  <Employee FirstName="Tom" LastName="Jones" CustomerId="1" />

  <Employee FirstName="John" LastName="Doe" CustomerId="2" />

</Employees>

 

 

You wish to display the data in a DropDownList with the DataTextField set to the FirstName and the DataValueField set to the CustomerId..

 

..and you do not want to write any code ;-)

Here is how you do it.

Drag and drop an
XmlDataSource and DropDownList control on to your page. Set their properties like so:

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Employees.xml"></asp:XmlDataSource>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="XmlDataSource1"

DataTextField="FirstName" DataValueField="CustomerId">

</asp:DropDownList>


Run the page.

The DropDownList will get rendered like so:

<select name="DropDownList1" id="DropDownList1">

<option value="1">Tom</option>

<option value="2">John</option>

</select>

What if the XML file were like this (where the values were elements instead of attributes)?

<Employees>

  <Employee>

    <FirstName>Tom</FirstName>

    <LastName>Jones</LastName>

    <CustomerId>1</CustomerId>

  </Employee>

  <Employee>

    <FirstName>John</FirstName>

    <LastName>Doe</LastName>

    <CustomerId>2</CustomerId>

  </Employee>

</Employees>

 

Our page will fail with the following error:
DataBinding: 'System.Web.UI.WebControls.XmlDataSourceNodeDescriptor' does not contain a property with the name 'FirstName'.


The reason is that attributes of XML elements are promoted to properties and exposed through the XmlDataSource during databinding. In our case, FirstName is an element instead of an attribute which leads to the error.

 

So what can we do about this? Easy, we have to figure out how to transform the FirstName, CustomerId so that they become attributes of the parent node - Employee. In other words, we need to transform the second XML file so that it looks like the first XML file. This is were XSLTs come in. Explaining XLSTs is beyond the scope of this post. Please use your search engine to learn more J
XSLT Reference

The
XmlDataSource allows you to specify an XSLT file where you can define a transformation that will be applied to the DataFile you specified. 
 

Add an XSL file to your project and enter the following  (In brief, the XSLT below will transform the XML file resulting in the  FirstName, CustomerId elements becoming attributes of the Employee node)


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="Employees">

    <Employees>

      <xsl:apply-templates select="Employee"/>

    </Employees>

  </xsl:template>

  <xsl:template match="Employee">

    <Employee>

      <xsl:attribute name="FirstName">

        <xsl:value-of select="FirstName"/>

      </xsl:attribute>

      <xsl:attribute name="CustomerId">

        <xsl:value-of select="CustomerId"/>

      </xsl:attribute>

    </Employee>

  </xsl:template>

</xsl:stylesheet>

Set the XmlDataSource’s TransformFile property to point to this XSL file. Our page will look like this:

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Employees.xml" TransformFile="~/XSLTFile.xsl"></asp:XmlDataSource>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="XmlDataSource1"

           DataTextField="FirstName" DataValueField="CustomerId">

    </asp:DropDownList>

 

The DropDownList will now get rendered like so:

<select name="DropDownList1" id="DropDownList1">

<option value="1">Tom</option>

<option value="2">John</option>

</select>

 

What if you wanted to display the FirstName, LastName in the DataTextField separated by a comma?

Easy! Change the XSL file to this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="Employees">

    <Employees>

      <xsl:apply-templates select="Employee"/>

    </Employees>

  </xsl:template>

  <xsl:template match="Employee">

    <Employee>

      <xsl:attribute name="FullName">

        <xsl:value-of select="FirstName"/>

        <xsl:text xml:space="preserve">, </xsl:text>

        <xsl:value-of select="LastName"/>

      </xsl:attribute>

      <xsl:attribute name="CustomerId">

        <xsl:value-of select="CustomerId"/>

      </xsl:attribute>

    </Employee>

  </xsl:template>

</xsl:stylesheet>


Note that we changed the attribute name to FullName.  

Note also the xml:space attribute which specifies that the space after the comma should be preserved.

Now change the page to this:

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Employees.xml" TransformFile="~/XSLTFile.xsl"></asp:XmlDataSource>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="XmlDataSource1"

           DataTextField="FullName" DataValueField="CustomerId">

    </asp:DropDownList>


The DropDownList will get rendered like this:


<select name="DropDownList1" id="DropDownList1">

     <option value="1">Tom, Jones</option>

     <option value="2">John, Doe</option>

</select>

 

Tuesday, October 07, 2008

Abnormal CPU temperature

I've just measured up a temperature of my laptop's CPU and was a little bit shoked. It is really hot! As hot as I can roast eggs on it :(. Now I’m going to disassemble it and find out why it heats. Hope I will be able to manage with it.

UPD: I fixed it. The reason of heating was in stripes of pressed dust on a radiator. These stripes were blocking internal air from going outside of the laptop. Now (after whole night + half a day of work the temperature of CPU is 44 degrees only.