Tuesday, June 8, 2010

Exception.ToString() vs. Exception.Message

ToString is superior than Message. Very useful for debugging purposes!


using System;
using System.Collections.Generic;
using System.Text;


namespace ExceptionToString
{
    public class MyClass {}


    public class ArgExceptionExample 
    {
        static void Main(string[] args)
        {
            MyClass my = new MyClass();
            string s = "sometext";


            try 
            {
                int i = s.CompareTo(my);
            }
            catch (Exception ex) 
            {
                Console.WriteLine("Error: {0}\n", ex.ToString());
                Console.WriteLine("Error: {0}", ex.Message);


                Console.Read();
            }
        }
    }
}

Friday, May 14, 2010

Flash Player installation instructions for OpenSolaris


Installation instructions for Solaris x86


The following assumes that you have unpacked the archive flash_player_10_solaris_x86.tar.bz2 into the top level of your user directory. Your user directory is referred to as $HOME.The Adobe Flash Player can be installed in two ways:
A. Install Adobe Flash Player system-wide, making it available to all users of the computer
-or-
B. Install Adobe Flash Player in a user account, making it available only to that user.
A. Installing Adobe Flash Player System-Wide:
  1. You will need root access to the computer to install Adobe Flash Player system-wide.
  2. Copy Adobe Flash Player (libflashplayer.so) into the Firefox/Mozilla plug-in directory (/usr/lib/firefox/plugins).
  3. Restart Firefox/Mozilla.
  4. Verify the installation by typing about:plugins in the location bar or by choosing Help > About Plugins. You should see Adobe Flash Player listed as "Shockwave Flash Player 10.0"
  5. To test Adobe Flash Player go to: http://www.adobe.com/go/flashplayerversion
B. Installing the Adobe Flash Player in a User Account:
  1. If you have not already used Firefox/Mozilla from the user account, launch Netscape/Mozilla and close it. This will create a preferences directory (/.mozilla) in your home directory.
  2. Create a directory named "plugins" in the Firefox/Mozilla preferences directory. If the mkdir command reports the error "cannot make directory: File exists", this means that the directory was already present and did not need to be created.
  3. Copy libflashplayer.so and flashplayer.xpt into the plug-in directory.
  4. Restart Firefox/Mozilla
  5. Verify the installation by typing about:plugins in the location bar or by choosing Help > About Plugins. You should see Adobe Flash Player listed as "Shockwave Flash Player 10.0"
  6. To test Adobe Flash Player go to: http://www.adobe.com/go/flashplayerversion

Wednesday, May 5, 2010

Validate contract in C# using REGEX

String strToTest;
String rePattern = "^[FGHJKMNQUVXZ][0-9]$";

Console.Write("Enter a String to Test for Contract:");
strToTest = Console.ReadLine();

Regex regexPattern = new Regex(rePattern);
Console.WriteLine(regexPattern.IsMatch(strToTest) == true ? "OK" : "KO");

strToTest = Console.ReadLine();

Wednesday, April 21, 2010

tcpdump in OpenSolaris

tcpdump -s 0 -w file.pcap -i e1000g0 port 10689

Bluetooth “Access Denied” issue and resolution

Today one of my co-workers have a problem activating her Bluetooth mouse. Here is the solution I found in this place:

  1. Open Services:

    1. To still type things out, start the on-screen keyboard by going to Start > Programs > Accessories > Accessibility > On-Screen Keyboard.  From there, you can then doStart > Run and then type services.msc
    2. To directly access Services, do Start > Control Panel > Administrative Tools > Services
  2. Find & select the Bluetooth Support Service, right click and select Properties.
  3. Click the Stop button on the General tab.
  4. Select the Log On tab, and select the radio button next toLocal System account, then click Apply.
  5. Go back to the General tab and click the Start button.
  6. Click OK to close the Properties dialog.
  7. Restart computer to make sure the change takes and things work.

Tuesday, April 13, 2010

Number of days in current Month in UNIX shell

cal | grep -v '[A-Za-z]' | wc -w

Last Sunday of the Month in UNIX shell

cal | grep '^[23]' | tail -1 | cut -d' ' -f1

Several months later I don't remember why the grep part?

cal | tail -1 | cut -d' ' -f1


AWK version:



#!/bin/bash


cal | awk '
    { last = $1 }
END { print last }'


##END##