Thursday, January 22, 2004 - Posts

OS bootable from a CD-ROM drive...

I like operating systems distributions that are bootable from a CD-ROM and works entirely from CD...

Linux has a lot of distributions with this feature... personally I use Knoppix (the first and for me the best!), a distribution based on Debian, that have a wonderful automatic hardware detection and support for many graphics cards, sound cards, SCSI and USB devices and other peripherals. It is not necessary to install anything on a hard disk. Due to on-the-fly decompression, the CD can have up to 2 GB of executable software installed on it.

Knoppix installation is wonderful, it detects every type of hardware you have. I install it for the first time on an old Pentium II with Number Nine Revolution 3D graphic card... Windows did not recognize it (only after the driver installation), but Knoppix was a success at the first time.

After the Knoppix success, other distributions like this are borned... now there are CD bootable Linux distributions from Mandrake (Mandrakemove), Lindows (LindowsCD), DineBolik.

And what about Windows? Would be possible in future a CD bootable distributions? I think it would be very interesting, expecially for rescue system, educational CD, or adapted and used as a platform for commercial software product demos.

I hope someone from Microsoft can read this post and think on this idea :)

Singleton Pattern for Windows Form: my implementation

Many times on forums and newsgroups there's a question like this: "How can I access a form member from another part of the program?"

A way to do this is to implement the Singleton Pattern. This is how you can do it:

1) Create a Sub Main (like this above) in a module:

Sub Main()
Application.Run(New Form1)
End Sub


2) Add a shared member to the form:

Private Shared instance As Form1

3) Add a function to your form that returns the form instance if it's already created: 

Public Shared Function InstanceObject() As Form1
If (instance Is Nothing) Then
instance = New Form1
End If
Return instance
End Function

4) In the form constructor (after the InitializeComponent) save the form instance on the shared member:

instance = Me

After that, from an other form (or from every part of your code) to access to members, methods or properties of the form instance, you can do like this:

Form1.InstanceObject.Label1.Visible = False

Suggestions or comments?

IRC on My Nokia 6600...

This morning i was trying some programs for my Nokia 6600, and i've discovered that Wireless IRC 1.80 is totally compatible with the Symbian OS 7 (the previous version of Wireless IRC doesn't work on this phone).

It's a nice tool, with interesting features like:

  • DCC file receive & send (requires a DCC relay proxy)
  • Basic IRC commands available through menus
  • Separate window per channel
  • Notification-"bubble" keeps you updated when WirelessIRC is in background
  • Simple file-browser
  • Monitor consumed traffic (real GPRS data counter)
  • Status window with network info (IRC & GSM LAC/CellID)
  • Audio notifications for different events (messages, going online/offline, ...)
  • Fullscreen-mode
  • Charset mappings + custom charsets (ISO-8859-x, Win125x, KOI8-R ...)
  • Supports IRC color codes and text-formatting
  • SSL for secure connections to certain IRC servers
  • Auto-backlight, history for input field (10 lines), ...

     

    It seems to work good... I've tried to connect at the Azzurra IRC Server (irc.azzurra.net) and the connection was OK... I've only tried to send messages, but not DCC session (maybe I'll do it soon).

    I think however that the best Instant Messaging tool for this phone is Agile Messenger, that is completely FREE and supports instant messaging services such as ICQ®, AOL®, Yahoo!® and MSN® very well.

    If you have a Nokia 6600, you have to install it absolutely!!!

    RSS Feed creation via classic ASP pages

    Yesterday i was trying to create a RSS feed for my ASP pages and my idea was to use a script like this:

    <%

    Response.ContentType = "text/xml"

    %>

    <?xml version="1.0" encoding="iso-8859-1"?>

    <!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">

    <rss version="0.91">

    <channel>

    <title>RSS Feed creation</title>

    <link>http://www.demiliani.it/</link>

    <description>Trying to create a RSS Feed via ASP...</description>

    <language>it</language>

    <%

    ' Here I estract the Data from my Database

    Set objConn = Server.CreateObject ("ADODB.Connection")

    objConn.Open strConn

    set rs = objConn.execute("SELECT TOP 10 * FROM MyTable ORDER BY Data DESC")

    Do while rs.eof

    response.write " <item>" &VbCrLf

    response.write " <title>"& rs("Title") &"</title>" &VbCrLf

    response.write " <link>" & rs("URL") &"</link>" &VbCrLf

    response.write " <description>"& rs("Description") &"</description>" &VbCrLf

    response.write " </item>" &VbCrLf

    rs.movenext

    loop

    rs.close

    set rs = nothing

    objConn.close

    set objConn = nothing

    %>

    </channel>

    </rss>

    It seems to work quite good... I've obtained a simple RSS Feed. Do you know other scripts to create RSS Feeds via classic ASP that works better? If yes, I'm really interested :)

    Connections with HttpWebRequest

    The .NET Framework has a HttpWebRequest object in the System.Net namespace. This object allows you to talk to HTTP Servers.

    Usually, people forget that the underlying connection created by the request is not freed up, unless you call Close() on the response. So, you hit the connection limit and no more web requests will go through.

    This is illustrated in the following example:

    for(int i=0; i < 3; i++) {
    HttpWebRequest r = WebRequest.Create(“http://www.demiliani.it“) as HttpWebRequest;
    using (HttpWebResponse w = r.GetResponse() as HttpWebResponse)
    {
    ... do something with the response ...
    }
    }

    This code works not good, because the third request is going to hang in GetResponse().
    If you close the response, by calling Response.Close() , then the underlying connection gets freed up, and the request will succeed.
    P.S. Since HttpWebResponse implements IDisposable, we use the USING syntax.

    Testing BlogJet

    I have now downloaded and installed an interesting application - BlogJet. It's a Windows-client for my blog tool (as well as some for other tools).

    Actually, it was not me who wrote this text: when I launched BlogJet for the first time, it's edit window already contained this text and the program asked me to click Post and Publish button to post this text to my blog in order to test the connection (yes, and the text above is not mine too! :-)... So, I did.

    Now I'm gonna learn all that cool features of BlogJet (don't ask me, there are too much - go to their website and read).

    Generate Thumbnail Images from PDF Documents

    I've just check this good article from Jonathan Hodgson on Generating Thumbnail Images from PDF Documents using VB.NET... interesting!

    Convert a DataReader to a DataSet

    Many applications that retrieves data from a database use the Datareader to return results or bind to a datagrid due to performance gains.

    Web Services however cannot return a Datareader... readers will need to be converted in order to return the results to the client of your service.

    The conversion method to return a dataset to the client from our service can be implemented as follow:

    Public Function ConvertDataReaderToDataSet(ByVal reader As SqlDataReader) As DataSet

    Dim dataSet As DataSet = New DataSet()

    Dim schemaTable As DataTable = reader.GetSchemaTable()

    Dim dataTable As DataTable = New DataTable()

    Dim intCounter As Integer

    For intCounter = 0 To schemaTable.Rows.Count - 1

    Dim dataRow As DataRow = schemaTable.Rows(intCounter)

    Dim columnName As String = CType(dataRow("ColumnName"), String)

    Dim column As DataColumn = New DataColumn(columnName, _

    CType(dataRow("DataType"), Type))

    dataTable.Columns.Add(column)

    Next

    dataSet.Tables.Add(dataTable)

    While reader.Read()

    Dim dataRow As DataRow = dataTable.NewRow()

    For intCounter = 0 To reader.FieldCount - 1

    dataRow(intCounter) = reader.GetValue(intCounter)

    Next

    dataTable.Rows.Add(dataRow)

    End While

    Return dataSet

    End Function

    What we do in this method is accept the reader that we want to convert to a dataset. We then declare a new dataset to store our values from the reader object and then structure our dataset with a table.

    Once a table is created then go through the schema of the reader and create our data table structure based on the reader's structure by looping through the columns and adding them to our new table. Once the structure of the new table is defined we then iterate through the rows in the reader and add the data that is contained within the reader. Finally add the new table to the dataset and then return the newly created dataset.

    This is my solution and i think it's good :)