Mohd Malaka Weblog

About anything….

  • Welcome


    Welcome to my Weblog. Here I post about anything, mainly about programming. Enjoy

  • Archives

  • Flickr Photos

    Dublin





    Dublin Buildings

    Dublin

    More Photos
  •  

    November 2009
    M T W T F S S
    « Sep    
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  
  • free counters

Archive for the ‘Uncategorized’ Category

Write to a file using JavaScript

Posted by malakablog on September 9, 2009


Use this function to write to a file using JavaScript

 

function WriteToFile(sMessage)
{
  try
  {
        var fso, s;
        fso = new ActiveXObject(“Scripting.FileSystemObject”);
        sFile = fso.OpenTextFile(“C:\\logs.txt”, 8);
        sFile.writeline(sMessage);
        sFile.Close();
  }
  catch(err)
  {
        var strErr = ‘Error:’;
        strErr += ‘\nNumber:’ + err.number;
        strErr += ‘\nDescription:’ + err.description;
        document.write(strErr);
  }
}

Posted in Uncategorized | Tagged: , , , , , , | Leave a Comment »

Dublin

Posted by malakablog on September 7, 2009

Posted in Uncategorized | Tagged: , , , , | Leave a Comment »

In Dublin Zoo

Posted by malakablog on September 3, 2009

Posted in Uncategorized | Tagged: , , , , , , , , | Leave a Comment »

GreyStones

Posted by malakablog on August 17, 2009

GreyStones is located on Ireland’s east cost, I used to live there for more than a year (September 2006 – November 2007). It is a very beautiful town with amazing beach and beautiful green areas, since we moved from GreyStones we used to go back there from time to time. I recommend this town to anyone visiting Ireland

Map picture

 

 

 

more of my GreyStones’s photos here

Posted in Uncategorized | Tagged: , , , , , | Leave a Comment »

My Simpsons Avatar

Posted by malakablog on August 5, 2009

Take a look at the Simpsons movie site. I created my own avatar.

Avatar

it looks like me :) .

Posted in Uncategorized | Tagged: , , , , | Leave a Comment »

VB.NET Sort Method for a Collection Class

Posted by malakablog on August 4, 2009


I have a VB.NET collection class EmployeesCollection for an Employee Class that got an Integer Property named Age; I want to create a method (SortByAge) to sort the collection members by Age.

 


This is the EmployeesCollection Class:

 

Imports Microsoft.VisualBasic

Public Class EmployeesCollection
Inherits System.Collections.CollectionBase

Public Sub Add(ByVal tblEmployee As Employee)
' Invokes Add method of the List object to add a widget.
List.Add(tblEmployee)
End Sub

Public ReadOnly Property Item(ByVal index As Integer) As Employee
Get
' The appropriate item is retrieved from the List object and
' explicitly cast to the Widget type, then returned to the
' caller.
Return CType(List.Item(index), Employee)
End Get
End Property

End Class
 


To create the SortByAge method I need a SortHelper Class, This helper Class will include a Function called Compare to compare between the Age values of the employees, the SortHelper Class will be part of the EmployeesCollection Class.

 

 
Private Class AgeSortHelper
        Implements IComparer

        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _
             Implements System.Collections.IComparer.Compare
            If x.Age > y. Age Then
                Return 1
            End If

            If x. Age < y. Age Then
                Return -1
            End If

            Return 0
        End Function
    End Class

 


Now we need to create the SortByAge method for the EmployeesCollection Class, in this method we will use the AgeSortHelper to sort the Employees.

 

    Public Sub SortByAge()
        Dim sorter As System.Collections.IComparer = New AgeSortHelper()
        InnerList.Sort(sorter)
    End Sub

 

This is the Final EmployeesCollection Class:

 

Imports Microsoft.VisualBasic

Public Class EmployeesCollection
    Inherits System.Collections.CollectionBase

    Public Sub Add(ByVal tblEmployee As Employee)
        ' Invokes Add method of the List object to add a widget.
        List.Add(tblEmployee)
    End Sub

    Public ReadOnly Property Item(ByVal index As Integer) As Employee
        Get
            ' The appropriate item is retrieved from the List object and
            ' explicitly cast to the Widget type, then returned to the
            ' caller.
            Return CType(List.Item(index), Employee)
        End Get
    End Property

    Public Sub SortByAge()
        Dim sorter As System.Collections.IComparer = New AgeSortHelper()
        InnerList.Sort(sorter)
End Sub
   
Private Class AgeSortHelper
        Implements IComparer

        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _
             Implements System.Collections.IComparer.Compare
            If x.Age > y. Age Then
                Return 1
            End If

            If x. Age < y. Age Then
                Return -1
            End If

            Return 0
        End Function

    End Class
End Class

Posted in Uncategorized | Tagged: , , , , , , , , , | Leave a Comment »

I am back

Posted by malakablog on July 31, 2009

I have been very busy in the last couple months, I was in a vacation in Amman, Jordan for a month, and when I returned back I had to move into a new house.

 


This post to share with you my most viewed photo in my flickr, I took this photo in Connolly Station.


Connolly Station

Connolly Station


From Wikipedia

 

          The station was opened on 29 November 1844 by the Dublin &amp; Drogheda Railway Company as Dublin Station, but was renamed ten years later as Amiens Street Station after the street on which it is located. Originally the station only served a single mainline to Drogheda, and only in 1853 did through services to Belfast commence. In 1891 the City of Dublin Junction Railway connected the station with Westland Row Station (now Pearse Station) on the city’s south side. The C of D Jctn was a separate station known as Amiens St Junction and consisted of the present platforms 5,6 &amp; 7 with a separate street entrance. After the amalgamation of the GNR (I) at the end of the 1950s this station became part of the overall Amiens St and the separate entrance fell into disuse. The C of D Jctn Rly. allowed services to run from Amiens St., through to Westland Row, and onwards to Rosslare and the Southeast. Services to Sligo were transferred to Westland Row (Pearse Stn) operating through the station non-stop in 1937, with the closure of Broadstone Station by CIÉ (see also MGWR). Services to Galway and Mayo also originated/terminated at Westland Row, operating through Connolly Station after 1937, running via Mullingar and Athlone. This was discontinued in the 1970s in favour of running services out of Heuston Station on the better quality Cork line. Passenger running between Mullingar/Athlone ceased completely in 1987.

 

During the 1960s, Sunday trains to Cork, Limerick and Waterford operated from Connolly platforms 5, 6 &amp; 7 (running through the Phoenix Park tunnel) to avoid the cost of opening Heuston (Kingsbridge) for the limited Sunday traffic demand at that time.

 

In 1966, the 50th anniversary of the Easter Rising, the station’s name was changed to Connolly Station after Irish revolutionary and socialist James Connolly. At the same time, several other main stations in the Republic were renamed after patriots executed for their roles in the Rising.

 

At the commencement of DART services in 1984, the C of D Jctn Rly entrance was refurbished and reopened for commuter traffic.

 

During the late 1990s, Connolly Station was completely renovated and partially rebuilt. An entirely new station hall was built, the roof over Platforms 1-4 was replaced, and a new bar/cafe and shops were installed. The former DART/Suburban station entrance (C of D Jctn Rly entrance) and the secondary station hall built with the DART (further north on Amiens St) were again closed, but a new entrance on the International Financial Services Centre side was opened. In 2004, the Luas Red Line (to Tallaght) began serving the station. As part of the preparation for this, the ramp which had been a bus terminus was demolished and replaced with a 2-platform tram station connected to the main concourse by escalators and lift. 

Posted in Uncategorized | Tagged: , , , , , | Leave a Comment »

C#: Bind a DropDownList to IDictionary using AjaxPro

Posted by malakablog on May 1, 2009

- Implement an AjaxMethod to return IDictionary object

 

[AjaxPro.AjaxMethod]

public IDictionary AjaxGetIDictionary()

{

//Prepare the IDictionary object

}

- Use JavaScript to request the AjaxMethod AjaxGetIDictionary

MyAjaxClass. AjaxGetIDictionary (jsAjaxGetIDictionary_Callback);

- In the JavaScript function jsAjaxGetIDictionary_Callback add the IDictionary items to the DopDownList

function jsAjaxGetIDictionary (response)

{

     try

    {

         var DictionaryItems= response.value;

         if (DictionaryItems == null || typeof(DictionaryItems) != “object”)

        {

               return;

         }

         var myDropDownList = document.getElementById(“myDropDownList”);

         myDropDownList.options.length = 0;

         for (var i = 0; i < response.value.length; ++i)

         {

             myDropDownList.options[myDropDownList.options.length] = new Option(response.value[i].Value,response.value[i].Key);

           }

    }

    catch(e)

   {

   }

}

Posted in Uncategorized | Tagged: , , , , , , , , , | Leave a Comment »

C#:Using Dictionary as DropDownList Data Source

Posted by malakablog on March 31, 2009

I have IDictionary Object called ListOptions. To use it as the data source for an ASP.NET DropDownList called objDropDownList:

 

objDropDownList.DataSource = ListOptions;

objDropDownList.DataTextField = “Value”;

          objDropDownList.DataValueField  = “Key”;

          objDropDownList.DataBind(); 

 

 

 

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , , | Leave a Comment »

T-Shirts for Software people

Posted by malakablog on March 6, 2009

1

3

4

5

6

7

8

Posted in Uncategorized | Tagged: , , , , , , , , , , , , , | Leave a Comment »