Archive for August, 2007

Tar in combination with find

When you want to add a selection of files to a tar archive you could do this:

find . -type f -name "*.jpg" | xargs tar rvf my.tar

Unix rules!

No Comments »

Adding data from an Array to a combobox in VB.NET

Add this Class:

Public Class ValueDescriptionPair

    Public Value As Object
    Public Description As String

    Public Sub New(ByVal NewValue As Object, ByVal NewDescription As String)
        Value = NewValue
        Description = NewDescription
    End Sub

    Public Overrides Function ToString() As String
        Return Description
    End Function

End Class

This is the way to add items to a combobox:

Dim Test_Array As New ArrayList

For i = 0 To someArrayWithData.GetLength(0) - 1
    Test_Array.Add(New ValueDescriptionPair(i, someArrayWithData(0)))
Next i

With ComboBox1
    .DisplayMember = "Description"
    .ValueMember = "Value"
    .DataSource = Test_Array
End With

1 Comment »

Unable to cast object of type ‘System.String[*]‘ to type ‘System.String[]‘

I was using some DLL and got this error. I found this out that the DLL was returning a 1-based Array. VB.NET only has 0-based arrays. The following VB.NET script converts the 1-based Array to a 0-based Array.

Dim destArray() AS String
Dim counter AS Integer
counter = 0
For Each str As String In someDLLComponent.getStuffAsArray
    ReDim destArray(counter + 1)
    destArray(counter) = p
    counter += 1
Next

destArray now contains a 0-based Array.

No Comments »

Creating a TLS/SSL certificate for Cyrus Imapd

If you want to enable Cyrus' TLS/SSL facilities, you have to create a certificate first. This requires an OpenSSL installation

openssl req -new -nodes -out req.pem -keyout key.pem
openssl rsa -in key.pem -out new.key.pem
openssl x509 -in req.pem -out ca-cert -req \
-signkey new.key.pem -days 999 

mkdir /var/imap

cp new.key.pem /var/imap/server.pem
rm new.key.pem
cat ca-cert >> /var/imap/server.pem

chown cyrus:mail /var/imap/server.pem
chmod 600 /var/imap/server.pem # Your key should be protected

echo tls_ca_file: /var/imap/server.pem >> /etc/imapd.conf
echo tls_cert_file: /var/imap/server.pem >> /etc/imapd.conf
echo tls_key_file: /var/imap/server.pem >> /etc/imapd.conf


Thanx to http://www.delouw.ch/linux/Postfix-Cyrus-Web-cyradm-HOWTO/html/cyrus-config.html

1 Comment »