Friday, December 12, 2008

Javascript to close the current window

"<script language='javascript'>window.open('','_parent','');window.close();</script>"

Javascript Form Submit Using POST action Into a new Window

<form> element of html have several attributes for controlling submission

method : get or post
action : the url for the post back action
target : the target for the post back action, _blank, _parent, _self, _top, name of a window
name : name of the form

In this topic of using javascript to change POST action of a form so that it post into a new Window, action and target is the most important attribute here.

you can use javascript function window.open(url, name, param)
e.g. window.open(test.html,'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');

to post into another window, we will set the action to the url of the new window and target is the name of the new window.
e.g.

function PostToNewWindow()
{
    form.action = 'newForm.asp?action=submit&param=new'; //any valid url and query string
    form.target = 'NewPopupForm'; // name of the new form
    window.open('', 'NewPopupForm', 'height=50, width=50, resizable = no, toolbar=no, status=no');
    form.submit;

}

Wednesday, December 10, 2008

Trim a string in JavaScript using replace function and regular expression

from this article http://www.nicknettleton.com/zine/javascript/trim-a-string-in-javascript

var trimmed = str.replace(/^\s+|\s+$/g, '') ;

Tuesday, December 2, 2008

SQL SERVER SQL Query Conditional Count with CASE Clause inside COUNT

Suppose you have a master and child table in the following structure and you want to find out how many thing of each category is sold or not

Category       
Music       
Book       
Movie       


Category    Name    Sold
Music    Love Song    T
Music    Rock    T
Music    Classical    F
Book    Dictionary    T
Book    Fiction    T
Book    Textbook    F
Movie    James Bond    F
Movie    MI3    F


You will write the following query for it

Select
    Category
    ,Count(Name) as ProductCount
    ,Count(Case When Sold = 'T' Then Name Else NULL End) as SoldCount
    ,Count(Case When Sold = 'F' Then Name Else NULL End) as UnsoldCount
From Product
Group By Category

NOTE: the NULL value in the else clause is critical, if you put zero there, the query will not work.

Friday, November 7, 2008

SENNHEISER Headphone Spare Parts Online Shop

LINK : http://www.jaudio.co.nz/Earphones/Spares+Parts+Sennheiser/Sennheiser+HD555.htm?osCsid=qbpt8bvdard8t6t41421r1vt77

This online shop sale Sennheiser Headphone spare parts in NZ

Monday, November 3, 2008

College Rifles Badminton Club Booking System


original article http://www.crbad.co.nz/club_play.html

Club play:













































Hall Programme
SUN 6am-5pm

Open Booking

5pm-7pm

Auck. Tamils


7pm-10pm

Club Night
MON 9.30am-1pm

Midweek Club
1pm-4pm

Open Booking
4pm-7pm

Juniors
7pm-11pm

Open Booking
Tues 6am-4pm

Open Booking
4pm-7pm

Juniors
7.30pm-9.30pm

Balmoral Club
WED 9.30am-1pm

Midweek Club
1pm-8pm

Open Booking
8-10pm

Kohi Club
THU 6am-7pm

Open Booking
7pm-10pm

Club Night
FRI 6am-7pm

Open Booking
6pm-7.30pm

Juniors
7.30pm-11pm

Open Booking
SAT 6am-11pm

Open Booking

NB: To book a court you have to be a member. Refer to How to Join


Visitors:

Club visitors are always welcome - $10 per person for club night,
$8 per person for club day.


Use of Courts:

To enable you to book a court, you need to have sufficient funds in
your card account. Payment can be made in the coin slot or note reader
provided or to the secretary in advance.

Refer to instructions on the wall beside the booking meter.

Court Light Instructions:


TWO Club Players
Player One
  1. Swipe your card through the card reader.
  2. Select the nominated court number via the keypad.
  3. Press the ON key.
Player Two
  1. Swipe your card through the card reader.
  2. Select the same nominated court number via the keypad.
  3. Press the ON key.
The operation will time out after a period of 10 seconds - if both players have not selected the
court number and pressed the ON key within this time frame you will need to try again.

NB: Both members need to be current valid and/or paid up members to switch court lights on.

ONE Club Player and ONE Visitor
Player
  1. Swipe your card through the card reader.
  2. Press the MENU key - option 9 - player and visitor
  3. Select the nominated court number via the keypad.
  4. Press the ON key.
Lights will automatically switch off at the end of your allocated period.

Contact details:

Address:

33 Haast Street, Remuera

(Near Upland Road Shops)

PO BOX 87-447, Meadowbank

Phone/Fax: 524-4285

Email: crbad@orcon.net.nz

We are going to be using email to communicate to all members. Can all members please email the office at
crbad@orcon.net.nz to confirm that we have your correct email address.

Office hours:

Club Secretary Sherilyn Bright is in our on-site office on Monday,
Wednesday & Friday 10am - 2pm.

The office is open from the first week in February to mid-December
but may be closed in the school holidays.

Wednesday, October 29, 2008

Install Windows Media Player 11 on Windows Server 2003

Install Windows Media Player 11 on Windows Server 2003

by Zack Whittaker

1)
Download the Windows Media Player 11 setup file from here and save to disk.
2) Run the setup file - the first thing you should see if a validation checker. Just leave this up, don’t go any further.
3) Search the hard drive for “wmp11.exe” - it should be in a temporary directory somewhere. Right click the file in the search then click “Open containing folder” (and not open).
4) Open and run the wmfdist11.exe file, then umdf.exe and wmdbexport.exe. Be warned, you may need to run these files in Compatibilty Mode. Simply right click each file, click Properties. Go to the Compatibility tab, then ensure that Windows XP is selected.
5) After all these are installed, you must restart (very important.)
6) Once you’ve restarted, run the wmp11.exe file in the same directory - this also may require compatibility settings being applied to it. Restart once more.
7) Back into Windows again, go to Start, Run then type in wmplayer then OK. Configure as you like, and viola it’s done

This method has been tested on my Windows 2003 R2 server. and it works. The reason I needed media player 11 on Windows 2003 is that so I can use MediaPortal 1.0 RC3.

Configure a Windows Server 2003 VPN on the server side

original article http://articles.techrepublic.com.com/5100-10878_11-5805260.html

Configure a Windows Server 2003 VPN on the server side


Takeaway: Set up a Windows Server 2003-based PPTP virtual private network (VPN) with this step-by-step installation and configuration guide.

Sometimes, simplicity is the best choice for both a technology solution and the corresponding tutorial that explains how to use the new solution. In this document, I will provide a clear, concise, systematic procedure for getting a Windows Server 2003-based PPTP VPN up and running. I'm using Windows Server 2003 with Service Pack 1 for this guide.

Add the Remote Access/VPN Server role to your Windows Server 2003 system

To add the Remote Access/VPN Server role, go to Start | All Programs | Administrative Tools | Configure Your Server Wizard. The first screen of this wizard is for informational purposes only and, thus, is not shown here. Click Next. The same goes for the second screen, which just tells you some things you need to have completed before adding new roles to your server.

On the third screen of the wizard, entitled Server Role, you're presented with a list of available roles for your server along with column that indicates whether or not a particular role has been assigned to this machine. Figure A shows you a screen from a server on which just the IIS Web server role has been added.

Figure A

To add a new role, select the role and click Next

To add the Remote Access/VPN Server role to your server, select that role and click the Next button to move on to the next screen in the wizard, which provides you with a quick overview of the options you selected.

Figure B

The summary screen is pretty basic for this role

Take note: This selection just starts another wizard called the Routing and Remote Access Wizard, described further below.

The Routing and Remote Access Wizard component

Like most wizards, the first screen of the Routing and Remote Access wizard is purely informational and you can just click Next.

The second screen in this wizard is a lot meatier and asks you to decide what kind of remote access connection you want to provide. Since the goal here is to set up a PPTP-based VPN, select the "Virtual Private Network VPN and NAT" selection and click Next.

Figure C

Select the VPN option and click Next

The next screen of the wizard, entitled VPN Connection, asks you to determine which network adapter is used to connect the system to the Internet. For VPN servers, you should install and use a separate network adapter for VPN applications. Network adapters are really cheap and separation makes the connections easier to secure. In this example, I've selected the second local area network connection (see Figure D), a separate NIC from the one that connects this server to the network. Notice the checkbox labeled "Enable security on the selected interface by setting up Basic Firewall" underneath the list of network interfaces. It's a good idea to enable since option it helps to protect your server from outside attack. A hardware firewall is still a good idea, too.

Figure D

Select the network adapter that connects your server to the Internet

With the selection of the Internet-connected NIC out of the way, you need to tell the RRAS wizard which network external clients should connect to in order to access resources. Notice that the adapter selected for Internet access is not an option here.

Figure E

Select the network containing resources needed by external clients

Just like every other client out there, your external VPN clients will need IP addresses that are local to the VPN server so that the clients can access the appropriate resources. You have two options (really three รข€" I'll explain in a minute) for handling the doling out of IP addresses.

First, you can leave the work up to your DHCP server and make the right configuration changes on your network equipment for DHCP packets to get from your DHCP server to your clients. Second, you can have your VPN server handle the distribution of IP addresses for any clients that connect to the server. To make this option work, you give your VPN server a range of available IP addresses that it can use. This is the method I prefer since I can tell at a glance exactly from where a client is connecting. If they're in the VPN "pool" of addresses, I know they're remote, for example. So, for this setting, as shown in Figure F below, I prefer to use the "From a specified range of addresses" option. Make your selection and click Next.

Figure F

Your choice on this one! I prefer to provide a range of addresses

If you select the "From a specified range of addresses" option on the previous screen, you now have to tell the RRAS wizard exactly which addresses should be reserved for distribution to VPN clients. To do this, click the New button on the Address Range Assignment screen. Type in the starting and ending IP addresses for the new range and click OK. The "Number of addresses" field will be filled in automatically based on your entry. You can also just enter the starting IP address and the number if IP addresses you want in the pool. If you do so, the wizard automatically calculates the ending IP address. Click OK in the New Address Range window; your entry appears in the Address Range Assignment window. Click Next to continue.

Figure G

You can have multiple address ranges, as long as they are all accessible

The next screen asks you to identify the network that has shared access to the Internet. This is generally the same network that your VPN users will use to access shared resources.

Figure H

Pick the network adapter that gives you access to the Internet

Authenticating users to your network is vital to the security of your VPN infrastructure. The Windows VPN service provides two means for handling this chore. First, you can use RADIUS, which is particularly useful if you have other services already using RADIUS. Or, you can just let the RRAS service handle the authentication duties itself. Give users access to the VPN services by enabling dial-in permissions in the user's profile (explained below). For this example, I will not be using RADIUS, but will allow RRAS to directly authenticate incoming connection requests.

Figure I

Decide what means of authentication you want to provide

That's it for the RRAS wizard! You're provided with a summary screen that details the selections you made.

Figure J

The RRAS wizard summary window

This also completes the installation of the Remote Access/VPN Server role.

User configuration

By default, users are not granted access to the services offered by the VPN; you need to grant these rights to each user that you want to allow remote access to your network. To do this, open Active Directory Users and Computers (for domains) or Computer Management (for stand alone networks), and open the properties page for a user to whom you'd like to grant access to the VPN. Select that user's Dial-In properties page. On this page, under Remote Access Permissions, select "Allow access". Note that there are a lot of different ways to "dial in to" a Windows Server 2003 system; a VPN is but one method. Other methods include wireless networks, 802.1x, and dial-up. This article assumes that you're not using the Windows features for these other types of networks. If you are, and you specify "Allow access", a user will be able to use multiple methods to gain access to your system. I can't go over all of the various permutations in a single article, however.

Figure K

Allow the user access to the VPN

Up and running

These are the steps needed on the server to get a VPN up and running. Of course, if you have devices such as firewalls between your VPN server and the Internet, further steps may be required; these are beyond the scope of this article, however.


AND ALSO ROUTER CONFIGURATION


from this article http://www.computernetworkinghelp.com/content/view/41/1/1/1/


Section 2: Configuring the router for VPN passthru.

  • Step 1: First we need to enable PPTP pass through on a screen similar to the one in the image below in Figure 2-A.

Figure 2-A
PPTP Passthru

 

NOTE: I'm not going into a lot of detail here because there are so many different routers and so many different versions of firmware. This specific explaination is for a Linksys model router, not all Linksys model routers will look the same depending on the version of firmware as well. PPTP uses TCP over port 1723, this type of VPN also requires GRE (Generic Routing Encapsulation) for the data stream. The NAT engine in the router must have support for GRE in order for this to function properly but most newer routers won't have a problem with this.

 

  • Step 2: Now we need to enable PPTP port fowarding on a screen similar to the one in the image below in Figure 2-B.

Figure 2-B
PPTP port Forwarding


NOTE: The IP address needs to be the address of the PC that you configured the VPN server on. Its a good idea to have statically defined addresses on devices that perform specific functions like a VPN server.

 

  • Step 3 (Optional): If you are running windows firewall on the VPN server interface you will need to allow PPTP (TCP Port 1723) to pass through. You can do this by going to "Add Port" under the "Exceptions" tab in the Windows Firewall configuration similar to the screen in Figure 3-B below. You can name it PPTP, put in 1723 in the "Port Number" field and select the TCP radio button and then select OK. You should see PPTP checked in the Programs and Services list afterwards.

 

Figure 3-B
PPTP Port Windows Firewall

 

NOTE: You will need to make sure that "Don't allow exceptions" is NOT checked on the General tab of the Windows Firewall configuration screen.

Wednesday, October 22, 2008

XML Schema XSD Optional vs Not Required

Greg Collins






The Difference Between Optional and Not Required

original article http://www.infopathdev.com/blogs/greg/archive/2004/09/16/The-Difference-Between-Optional-and-Not-Required.aspx



When
creating an InfoPath form from an external schema, you might
encounter an issue where InfoPath still requires that the field be
filled in even though the element or attribute was specified as
optional. The solution comes from a proper understanding of the
difference between "optional" and "not required".

To verify
whether a field is truly optional, you can open your form template in
the InfoPath designer, choose Form Options from the Tools menu and then
click Edit Default Values. In the Edit Default Values dialog box you
will see that any schema element specified as optional has an active
check box next to it. To include this optional field as part of the
default XML for a new form, leave the box checked. To exclude it, clear
the check box. All of the non-optional elements have a grayed-out check
box, meaning you cannot clear the check box.

The confusion
happens when InfoPath still requires that an optional field be filled
in. This field may be optional, but it is still required. Required is
different from optional. Optional means that the field does not need
to be present in the XML. You can have a field that is optional and
required, meaning that if it is present in the XML then it must be
filled in. To clarify:

Optional: Does not need to be present in the XML.

Not Required: Does not need to have a value.

You can have any combination:

  • Optional + Not Required
  • Optional + Required
  • Not Optional + Not Required
  • Not Optional + Required

There
are differences in how to establish these combinations in your schema
depending on whether you have an element or an attribute. Attributes
have an additional restriction that could force it to always be
required--but there is a workaround.

Schema Elements:

In order to set a schema element as optional, you include the minOccurs="0" attribute. In order to set a schema element as not required, you include the nillable="true"
attribute. String data types are not required by default, though you
can force them to be required. Other data types, such as Boolean,
Integer, Date, Time, etc. are all required by default. In order to make
one of these data types not required, you must set the nillable attribute equal to true for the element in the schema. Following are a few examples:

An optional + not required element of type date:

<xsd:element name="Date" type="xsd:date" nillable="true" minOccurs="0"/>

A not optional + required element of type string:

<xsd:element name="Name" type="xsd:string" nillable="false"/>

A not optional + not required element of type anyURI:

<xsd:element name="Email" type="xsd:anyURI" nillable="true"/>

Schema Attributes:

In
order to set a schema attribute as optional, you do not need to add
anything as attributes are optional by default; but you might prefer to
include the use="optional" attribute. In order to set a schema attribute as not optional, you must include the use="required" attribute. Attributes have no equivalent to the nillable attribute
on elements. If you want an attribute to be not required, you must
specify the string data type. All other data types will require the
attribute to have a value. Following are a couple of examples:

An optional + required attribute of type integer:

<xsd:attribute name="number" type="xsd:integer" use="optional"/>

A not optional + not required attribute of type string, to be used as type dateTime:

<xsd:attribute name="dateTime" type="xsd:string" use="required"/>

Sunday, October 19, 2008

MAC OS X equivalent of host file (on Windows)

You can find the answer from this apple support doc http://support.apple.com/kb/TA27291?viewlocale=en_US

This advanced document explains how to
configure host information in cases where you do not have a domain name
server (DNS) on the network, but need to resolve hostnames. For
example, when two computers are connected with a crossover cable or a
standalone hub and need to resolve hostnames, but one of the computers
does not support Bonjour (formerly "Rendezvous," also known as
Multicast DNS).





Products Affected


Mac OS X 10.2, Mac OS X 10.0






Mac OS X 10.2 or later


Edit the /private/etc/hosts file. For more information on how to use the hosts file, open Terminal and type: man hosts



Note: Editing this file requires root privileges.


The MAC os x Hosts file is very similar / identical to the Windows version. You can find the windows version in c:/windows/system32/drivers/etc/hosts .


Friday, October 17, 2008

Optimise Windows XP - Make Your Windows Xp Run Faster

Make Your Windows Xp Run Faster Than Never Before!








Fri, 06/07/2007





DISABLE INDEXING SERVICES

Indexing
Services is a small little program that uses large amounts of RAM and
can often make a computer endlessly loud and noisy. This system process
indexes and updates lists of all the files that are on your computer.
It does this so that when you do a search for something on your
computer, it will search faster by scanning the index lists. If you
don't search your computer often, or even if you do search often, this
system service is completely unnecessary. To disable do the following:


1. Go to Start
2. Click Settings
3. Click Control Panel
4. Double-click Add/Remove Programs
5. Click the Add/Remove Window Components
6. Uncheck the Indexing services
7. Click Next


OPTIMISE DISPLAY SETTINGS


Windows XP can look sexy but displaying all the visual items can waste system resources. To optimise:


1.Go to Start
2. Click Settings
3. Click Control Panel
4. Click System
5. Click Advanced tab
6. In the Performance tab click Settings
7. Leave only the following ticked:
- Show shadows under menus

- Show shadows under mouse pointer
- Show translucent selection rectangle
- Use drop shadows for icons labels on the desktop
- Use visual styles on windows and buttons


DISABLE PERFORMANCE COUNTERS


Windows XP has a performance monitor utility which monitors several
areas of your PC's performance. These utilities take up system
resources so disabling is a good idea.


To disable:


1. download and install the Extensible Performance Counter List(http://www.microsoft.com/windows2000/remove404.mspx
)
2.Then
select each counter in turn in the 'Extensible performance counters'
window and clear the 'performance counters enabled' checkbox at the
bottom.button below.


SPEEDUP FOLDER BROWSING


You may have noticed that everytime you open my computer to browse
folders that there is a slight delay. This is because Windows XP
automatically searches for network files and printers everytime you
open Windows Explorer. To fix this and to increase browsing
significantly:


1. Open My Computer
2. Click on Tools menu
3. Click on Folder Options
4. Click on the View tab.
5. Uncheck the Automatically search for network folders and printers check box
6. Click Apply
7. Click Ok

8. Reboot your computer


IMPROVE MEMORY USAGE


Cacheman Improves the performance of your computer by optimizing the disk cache, memory and a number of other settings.


Once Installed:


1.Go to Show Wizard and select All
2.Run all the wizards by
selecting Next or Finished until you are back to the main menu. Use the
defaults unless you know exactly what you are doing.
3.Exit and Save Cacheman
4.Restart Windows


OPTIMISE YOUR INTERNET CONNECTION


There are lots of ways to do this but by far the easiest is to run TCP/IP Optimizer.


1. Download(www.speedguide.net/files/tcpoptimizer.exe) and install
2. Click the General Settings tab and select your Connection Speed (Kbps)

3. Click Network Adapter and choose the interface you use to connect to the Internet
4. Check Optimal Settings then Apply
5. Reboot


OPTIMISE YOUR PAGEFILE


If you give your pagefile a fixed size it saves the operating system from needing to resize the page file.


1. Right click on My Computer and select Properties
2. Select the Advanced tab
3. Under Performance choose the Settings button
4. Select the Advanced tab again and under Virtual Memory select Change
5.
Highlight the drive containing your page file and make the initial Size
of the file the same as the Maximum Size of the file.


Windows XP sizes the page file to about 1.5X the amount of actual
physical memory by default. While this is good for systems with smaller
amounts of memory (under 512MB) it is unlikely that a typical XP
desktop system will ever need 1.5 X 512MB or more of virtual memory. If
you have less than 512MB of memory, leave the page file at its default
size. If you have 512MB or more, change the ratio to 1:1 page file size
to physical memory size.


RUN BOOTVIS - IMPROVE BOOT TIMES download from(www.majorgeeks.com)
BootVis will significantly improve boot times


1. Download and Run
2. Select Trace
3. Select Next Boot and Driver Trace
4. A Trace Repetitions screen will appear, select Ok and Reboot
5.
Upon reboot, BootVis will automatically start, analyze and log your
system's boot process. When it's done, in the menu go to Trace and
select Optimize System
6. Reboot.
7. When your machine has
rebooted wait until you see the Optimizing System box appear. Be
patient and wait for the process to complete


REMOVE THE DESKTOP PICTURE
Your
desktop background consumes a fair amount of memory and can slow the
loading time of your system. Removing it will improve performance.


1. Right click on Desktop and select Properties
2. Select the Desktop tab
3. In the Background window select None
4. Click Ok


REMOVE FONTS FOR SPEED


Fonts, especially TrueType fonts, use quite a bit of system
resources. For optimal performance, trim your fonts down to just those
that you need to use on a daily basis and fonts that applications may
require.


1. Open Control Panel
2. Open Fonts folder
3. Move fonts you
don't need to a temporary directory (e.g. C:\FONTBKUP?) just in case
you need or want to bring a few of them back. The more fonts you
uninstall, the more system resources you will gain.


DISABLE UNNECESSARY SERVICES


Because Windows XP has to be all things to all people it has many
services running that take up system resources that you will never
need. Below is a list of services that can be disabled on most
machines:


Alerter
Clipbook
Computer Browser
Distributed Link Tracking Client
Fast User Switching
Help and Support - (If you use Windows Help and Support leave this enabled)
Human Interface Access Devices

Indexing Service
IPSEC Services
Messenger
Netmeeting Remote Desktop Sharing (disabled for extra security)
Portable Media Serial Number
Remote Desktop Help Session Manager (disabled for extra security)

Remote Procedure Call Locator
Remote Registry (disabled for extra security)
Remote Registry Service
Secondary Logon
Routing & Remote Access (disabled for extra security)
Server
SSDP Discovery Service - (Unplug n' Pray will disable this)

Telnet
TCP/IP NetBIOS Helper
Upload Manager
Universal Plug and Play Device Host
Windows Time
Wireless Zero Configuration (Do not disable if you use a wireless network)
Workstation
To disable these services:


Go to Start and then Run and type "services.msc"
Doubleclick on the service you want to change
Change the startup type to 'Disable"


TURN OFF SYSTEM RESTORE


System Restore can be a useful if your computer is having problems,
however storing all the restore points can literally take up Gigabytes
of space on your hard drive. To turn off System Restore:


Open Control Panel
Click on Performance and Maintenance
Click on System
Click on the System Restore tab
Tick 'Turn off System Restore on All Drives'
Click 'Ok'


DEFRAGMENT YOUR PAGEFILE


Keeping your pagefile defragmented can provide a major performance
boost. One of the best ways of doing this is to creat a separate
partition on your hard drive just for your page file, so that it
doesn't get impacted by normal disk usage. Another way of keeping your
pagefile defragmented is to run PageDefrag. This cool little app can be
used to defrag your pagefile, and can also be set to defrag the
pagefile everytime your PC starts. To install:


Download(www.sysinternals.com) and Run PageDefrag
Tick "Defrag at next Reboot",
Click "Ok"
Reboot


SPEEDUP FOLDER ACCESS - DISABLE LAST ACCESS UPDATE


If you have a lot of folders and subdirectories on your computer,
when you access a directory XP wastes a lot of time updating the time
stamp showing the last access time for that directory and for ALL sub
directories. To stop XP doing this you need to edit the registry. If
you are uncomfortable doing this then please do not attempt.


Go to Start and then Run and type "regedit"
Click through the file system until you get to "HKEY_LOCAL_MACHINE\System\Cur rentControlSet\Control\FileSys tem"
Right-click in a blank area of the window on the right and select 'DWORD Value'

Create a new DWORD Value called 'NtfsDisableLastAccessUpdate'
Then Right click on the new value and select 'Modify'
Change the Value Data to '1'
Click 'OK'


DISABLE SYSTEM SOUNDS


Surprisingly, the beeps that your computer makes for various system
sounds can slow it down, particularly at startup and shut-down. To fix
this turn off the system sounds:


Open Control Panel
Click Sounds and Audio Devices
Check Place volume icon in taskbar
Click Sounds Tab
Choose "No Sounds" for the Sound Scheme
Click "No"
Click "Apply"

Click "OK"


IMPROVE BOOT TIMES
A
great new feature in Microsoft Windows XP is the ability to do a boot
defragment. This places all boot files next to each other on the disk
to allow for faster booting. By default this option in enables but on
some builds it is not so below is how to turn it on.


Go to Start Menu and Click Run
Type in "Regedit" then click ok
Find "HKEY_LOCAL_MACHINE\SOFTWARE\M icrosoft\Dfrg\BootOpt imizeFunction"
Select "Enable" from the list on the right

Right on it and select "Modify"
Change the value to "Y to enable"
Reboot


IMPROVE SWAPFILE PERFORMANCE


If you have more than 256MB of RAM this tweak will considerably
improve your performance. It basically makes sure that your PC uses
every last drop of memory (faster than swap file) before it starts
using the swap file.


Go to Start then Run
Type "msconfig.exe" then ok
Click on the System.ini tab
Expand the 386enh tab by clicking on the plus sign
Click on new then in the blank box type"ConservativeSwapfileUsage =1"

Click OK
Restart PC


MAKE YOUR MENUS LOAD FASTER


This is one of my favourite tweaks as it makes a huge difference to
how fast your machine will 'feel'. What this tweak does is remove the
slight delay between clicking on a menu and XP displaying the menu.


Go to Start then Run
Type 'Regedit' then click 'Ok'
Find "HKEY_CURRENT_USER\Control Panel\Desktop\"
Select "MenuShowDelay"
Right click and select "Modify'

Reduce the number to around "100"
This
is the delay time before a menu is opened. You can set it to "0" but it
can make windows really hard to use as menus will open if you just look
at them - well move your mouse over them anyway. I tend to go for
anywhere between 50-150 depending on my mood


MAKE PROGRAMS LOAD FASTER


This little tweak tends to work for most programs. If your program doesn't load properly just undo the change. For any program:


Right-click on the icon/shortcut you use to launch the program
Select properties
In the 'target' box, add ' /prefetch:1' at the end of the line.
Click "Ok"
Voila - your programs will now load faster.


IMPROVE XP SHUTDOWN SPEED


This tweak reduces the time XP waits before automatically closing
any running programs when you give it the command to shutdown.


Go to Start then select Run
Type 'Regedit' and click ok
Find 'HKEY_CURRENT_USER\Control Panel\Desktop\'
Select 'WaitToKillAppTimeout'
Right click and select 'Modify'

Change the value to '1000'
Click 'OK'
Now select 'HungAppTimeout'
Right click and select 'Modify'
Change the value to '1000'
Click 'OK'
Now find 'HKEY_USERS\.DEFAULT\Control Panel\Desktop'

Select 'WaitToKillAppTimeout'
Right click and select 'Modify'
Change the value to '1000'
Click 'OK'
Now find 'HKEY_LOCAL_MACHINE\System\Cur rentControlSet\Control\'

Select 'WaitToKillServiceTimeout'
Right click and select 'Modify'
Change the value to '1000'
Click 'OK'


SPEED UP BOOT TIMES I


This tweak works by creating a batch file to clear the temp and
history folders everytime you shutdown so that your PC doesn't waste
time checking these folders the next time it boots. It's quite simple
to implement:


1. Open Notepad and create a new file with the following entries:


RD /S /q "C:\Documents and Settings\"UserName without quotes"\Local Settings\History"
RD /S /q "C:\Documents and Settings\Default User\Local Settings\History"
RD /S /q "D:\Temp\" <รƒ¢รข‚¬รข€ล“"Deletes temp folder, type in the location of your temp folder"


2. Save the new as anything you like but it has to be a '.bat' file e.g. fastboot.bat or deltemp.bat


3. Click 'Start' then 'Run'


4. Type in 'gpedit.msc' and hit 'ok'


5. Click on 'Computer Configuration' then 'Windows Settings'


6. Double-click on 'Scripts' and then on 'Shutdown'


7. Click 'Add' and find the batch file that you created and then press 'Ok'


SPEED UP BOOT TIMES II


When your PC starts it usually looks for any bootable media in any
floppy or cd-rom drives you have installed before it gets around to
loading the Operating System from the HDD. This can waste valuable
time. To fix this we need to make some changes to the Bios.


1. To enter the bios you usually press 'F2' or 'delete' when your PC starts


2. Navigate to the 'Boot' menu


3. Select 'Boot Sequence'


4. Then either move your Hard drive to the top position or set it as the 'First Device'


5. Press the 'Escape' key to leave the bios. Don't forget to save your settings before exiting


Note: Once this change has been made, you won't be able to boot from
a floppy disc or a CD-rom. If for some strange reason you need to do
this in the future, just go back into your bios, repeat the steps above
and put your floppy or CD-rom back as the 'First Device'


SPEED UP BOOT TIMES III


When your computer boots up it usually has to check with the network
to see what IP addresses are free and then it grabs one of these. By
configuring a manually assigned IP address your boot time will improve.
To do this do the following:


1. Click on 'Start' and then ''Connect To/Show All Connections'


2. Right-click your network adapter card and click 'Properties'.


3. On the 'General' tab, select 'TCP/IP' in the list of services and click 'Properties'


4.I n the TCP/IP properties, click 'Use the following address' and
enter an IP address for your PC. If you are using a router this is
usually 192.168.0.xx or 192.168.1.xx. If you are not sure what address
you could check with your ISP or go to 'Start/run' and type 'cmd' and
then 'ipconfig/all'. This will show your current IP settings which you
will need to copy.


5. Enter the correct details for 'Subnet mask', 'Default gateway'
and 'DNS Server'. Again if you are not sure what figures to enter use
'ipconfig/all' as in stage 4.


FREE UP MEMORY
I found
this useful app via FixMyXP. ClearMem Is an Excellent Tool for speeding
up your XP Computer (especially if your system has been on for awhile
and you have a lot of applications open). What it does, is it Forces
pages out of physical memory and reduces the size of running processes
if working sets to a minimum. When you run this tool, the system pauses
because of excessive high-priority activity associated with trimming
the working sets. To run this tool, your paging file must be at least
as large as physical memory. To Check your Paging File:


1. Go to your control panel, then click on 'System', then go to the
'Advanced' Tab, and Under 'Performance' click 'Settings' then the
'Advanced' Tab


2. On the Bottom you should see 'Virtual Memory' and a value. This
is the value that must be at least as large as how much memory is in
your system.


3. If the Virtual Memory Value is smaller than your system memory,
click Change and change the Min Virtual Memory to a number that is
greater than your total system memory, then click 'Set' and Reboot.


4. Once you have rebooted install ClearMem


ENSURE XP IS USING DMA MODE


XP enables DMA for Hard-Drives and CD-Roms by default on most ATA or
ATAPI (IDE) devices. However, sometimes computers switch to PIO mode
which is slower for data transfer - a typical reason is because of a
virus. To ensure that your machine is using DMA:


1. Open 'Device Manager'


2. Double-click 'IDE ATA/ATAPI Controllers'


3. Right-click 'Primary Channel' and select 'Properties' and then 'Advanced Settings'


4. In the 'Current Transfer Mode' drop-down box, select 'DMA if Available' if the current setting is 'PIO Only'


ADD CORRECT NETWORK CARD SETTINGS


Some machines suffer from jerky graphics or high CPU usage even when
a machine is idle. A possible solution for this, which, can also can
help network performance is to:


1. RightClick 'My Computer'


2. Select 'Manage'


3. Click on 'Device Manager'


4. DoubleClick your network adaptor under 'Network Adapters'


5. In the new window, select the 'Advanced' tab


6. Select 'Connection Type' and select the correct type for your card and then Reboot


REMOVE ANNOYING DELETE CONFIRMATION MESSAGES


Although not strictly a performance tweak I love this fix as it
makes my machine 'feel' faster. I hate the annoying 'are you sure?'
messages that XP displays, especially if I have to use a laptop
touchpad to close them. To remove these messages:


1. Right-click on the 'Recycle Bin' on the desktop and then click 'Properties'


2. Clear the 'Display Delete Confirmation Dialog' check box and click 'Ok'


If you do accidently delete a file don't worry as all is not lost. Just go to your Recycle Bin and 'Restore' the file.


DISABLE PREFETCH ON LOW MEMORY SYSTEMS


Prefetch is designed to speed up program launching by preloading
programs into memory - not a good idea is memory is in short supply, as
it can make programs hang. To disable prefetch:


1. Click 'Start' then 'Run'


2. Type in 'Regedit' then click 'Ok'


3. Navigate to 'HKEY_LOCAL_MACHINE\SYSTEM\Cur rentControlSet\Control\Session Manager\Memory Management\PrefetchParameters\ '


4. Right-click on "EnablePrefetcher" and set the value to '0'


5. Reboot.

Saturday, September 20, 2008

How to change the Volume Licensing product key running Windows XP

If you ever need to change volume license key on a Windows XP machine, you can use the following script , see Microsoft article http://support.microsoft.com/kb/328874

'
' WMI Script - ChangeVLKey.vbs
'
' This script changes the product key on the computer
'
'***************************************************************************

ON ERROR RESUME NEXT


if Wscript.arguments.count<1 vol_prod_key =" Wscript.arguments.Item(0)" vol_prod_key =" Replace(VOL_PROD_KEY," impersonationlevel="impersonate}" result =" Obj.SetProductKey"> 0 then
WScript.Echo Err.Description, "0x" & Hex(Err.Number)
Err.Clear
end if

Next


Use a script
You can create a WMI script that changes the volume licensing product key, and then deploy this script in a startup script. The sample ChangeVLKey2600.vbs script and the sample ChangeVLKeySP1 script that are described in this section use the new volume licensing key that you want to enter, in its five-part alphanumeric form, as a single argument. Microsoft recommends that you use the ChangeVLKey2600.vbs script on Windows XP-based computers that are not running Windows XP SP1 or a later version of Windows XP and that you use the ChangeVLKeySP1.vbs script on Windows XP-based computers that are running Windows XP SP1 or a later versions of Windows XP. These scripts perform the following functions:
• They remove the hyphen characters (-) from the five-part alphanumeric product key.
• They create an instance of the win32_WindowsProductActivation class.
• They call the SetProductKey method with the new volume licensing product key.
You can create a batch file or a cmd file that uses either of the following sample scripts, together with the new product key as an argument, and either deploy it as part of a startup script or run it from the command line to change the product key on a single computer.

Example
The following example shows how to use the ChangeVLKeySP1.vbs script from a command line:
1. Click Start, and then click Run.
2. In the Open box, type the following command, where AB123-123AB-AB123-123AB-AB123 is the new product key that you want to use, and then click OK:
c:\changevlkeysp1.vbs ab123-123ab-ab123-123ab-ab123

Sunday, September 7, 2008

Hong Kong is no longer a place for cheap electronic goods?

I have recently been to Hong Kong. I was wishing I can find some electronic gadget bargains. But after browse around a little in the major electronic stores and even the back streen sellers. I am a little disappointed, the price is only comparable to what I can get at home (Auckland). Not really much cheaper, maybe more models and variety, but not cheaper.

Friday, August 8, 2008

.NET Web Service request timeout setting

There are 3 timeout in play:
  1. Proxy timeout
  2. Client executionTimeout
  3. Server executionTimeout

Proxy timeout can be set programmatically on the client side when create proxy object

MyWebService svr = new MyWebService();
svr.Timeout = 100;

The timeout setting is in seconds and default is 100 seconds, if you want to set it to indefinite then set it to -1.

ExecutionTimeout setting is found in the web.config or machine.config on both client and server side

following can be found in the web.config
<configuration>
<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100" />
</system.web>
</configuration>



following can be found in the machine.config
<httpRuntime
executionTimeout="90"
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100" />

The default for executionTimeout is 90 seconds.

NOTE: it is recommanded (best practice ) to set proxy timeout greater than executionTimeout

Wednesday, July 23, 2008

Remove .DS_Store .Trash and ._* system file from non HFS volume

Will try the following command

find . -name .DS_Store -o -name .Trashes -o -name ._* -exec rm -rf {} \; -prune


Mac OS X: How to prevent .DS_Store file creation over network connections

This how to article describe prevent create of DS store files on network shares

I tried this method on 10.5 and seems to work

Summary

This article contains advanced material intended only for those who are looking for information on .DS_Store files. If you do not already have an opinion on this matter, you can disregard this article.

Products Affected

Mac OS X Server 10.4, Mac OS X 10.4

To configure a Mac OS X user account so that .DS_Store files are not created when interacting with a remote file server using the Finder, follow the steps below.
Note: This will affect the user's interactions with SMB/CIFS, AFP, NFS, and WebDAV servers.

  1. Open the Terminal.
  2. Type:
    defaults write com.apple.desktopservices DSDontWriteNetworkStores true
  3. Press Return.
  4. Restart the computer.

If you want to prevent .DS_Store file creation for other users on the same computer, log in to each user account and perform the steps above—or distribute a copy of your newly modified com.apple.desktopservices.plist file to the ~/Library/Preferences folder of other target users.

These steps do not prevent the Finder from creating .DS_Store files on the local volume. These steps do not prevent previously existing .DS_Store files from being copied to the remote file server. Please note that disabling the creation of .DS_Store files on remote file servers can cause unexpected behavior in the Finder (click here for an example).

Mac OS X: How to prevent .DS_Store file creation over network connections

This how to article describe prevent create of DS store files on network shares

Summary

This article contains advanced material intended only for those who are looking for information on .DS_Store files. If you do not already have an opinion on this matter, you can disregard this article.

Products Affected

Mac OS X Server 10.4, Mac OS X 10.4

To configure a Mac OS X user account so that .DS_Store files are not created when interacting with a remote file server using the Finder, follow the steps below.
Note: This will affect the user's interactions with SMB/CIFS, AFP, NFS, and WebDAV servers.

  1. Open the Terminal.
  2. Type:
    defaults write com.apple.desktopservices DSDontWriteNetworkStores true
  3. Press Return.
  4. Restart the computer.

If you want to prevent .DS_Store file creation for other users on the same computer, log in to each user account and perform the steps above—or distribute a copy of your newly modified com.apple.desktopservices.plist file to the ~/Library/Preferences folder of other target users.

These steps do not prevent the Finder from creating .DS_Store files on the local volume. These steps do not prevent previously existing .DS_Store files from being copied to the remote file server. Please note that disabling the creation of .DS_Store files on remote file servers can cause unexpected behavior in the Finder (click here for an example).

Monday, July 21, 2008

Media Portal and Codecs

Been playing around with various PVR software for Windows,

Tried GB-PVR, it is not very user friendly, kind of difficult to setup channel lineup. And tried to setup client server type relationship on 2 computers and did not work out.

Sage TV sounded very promising until tried its setup for a DVB-S and DVB-T setting. Well I did not manage to get far, after a search of their support forum, I found to get DVB-S or DVB-T setup work, it is quite involved. I am actually have high hope for this one as it charge so much.

I had been using PVR software snapstream / Beyong TV for years. It is very good, the only problem is it does not support DVB cards. That is why the need to try all these different PVR software.

I think I will settle for Media Portal for now, it is flexible, it got promising feature (does not all work). It got a lot of interest and support. And it is free. It works for me except analog video; and is not the most stable.

I think some of my problem with media portal can be solved by finding out a perfect set of codec to use. Will need to investigate the setting and combination of all of codec pages below. Unfortunately, I did install one of those codec pack on my machine, so it is somewhat contaminated with codec. Nedd to figure of somehow clean it up short of install the whole system.

http://wiki.team-mediaportal.com/UserGuides/codecs_and_containers
http://wiki.team-mediaportal.com/Using_Codecs_Part_2
http://www.avsforum.com/avs-vb/showthread.php?t=719041
http://forum.team-mediaportal.com/general-development-no-feature-request-here-48/codec-guide-30191/
http://wiki.team-mediaportal.com/Postprocessing


Thursday, July 17, 2008

Error, "...Installer Database is Corrupt..." when you install Adobe Creative Suite CS3

Got an error when tried to reinstall adobe creative suit today, well, it is a little frustrating and hairy when this Error, "...Installer Database is Corrupt..." showed up when click on the install button on the installer DVD autorun popup.

Luckily this is a known issue and this is a support article from adobe solve the problem.

Essentially, you need to clean uninstall the adobe suit before you reinstall, and make sure you have removed these files:


Delete the Caps folder if you are unable to delete the Adobe Creative Suite 3 product or they are not listed.


    • On Windows:
      Program Files\Common Files\Adobe\caps\caps.db
      Program Files\Common Files\Adobe\backup\caps.db

    • On Mac OS:
      /Library/Application Support/Adobe/caps
      /Library/Application Support/Adobe/backup


Tuesday, July 15, 2008

XMLTV EPG Plug-in Information

There are most PVR support EPG but a good EPG source seem to be very hard to come by outside of US or Europe. XMLTV is a common xml based plug in for EPG by gathering data (some even do web scrape) and compile into a standard xml, here are source for XMLTV EPG found in my source for a perfect PVR software.

From this Wiki Page from gbpvr, good information on XMLTV source the part interest me most is the Oceania section.

for NZ there are Djkxml it sounds like it is using web scraping to get the data? for freeview there is a EPG stream along with the program so it is good or to use http://www.av1.co.nz/


Good Information Site about chinese Satellite TV

http://www.cintv.net/ got good information on chinese Satellite TV information
http://www.dvbs.org.cn/
http://www.asiatvro.com/

Thursday, July 10, 2008

Start/ Stop IIS Service locally and remotely use IISReset command

This is a quite useful command if you ever want to remotely deploy any new website,
here is the microsoft link

IISReset [computername] [option flags]

computername is not required for local.

flags include
/noforce do not force disconnect client
/stop stop iis
/start start iis
/reboot reboot the computer
/restart restart iis
/status display status
/enable
/disable

Sunday, July 6, 2008

Build Another PVR Server for TV recording, researching Winodws based PVR Software

Have been searching for an alternative PVR software, compare to BTV (Snapstream). I have used BTV for several years now since I first discovered PC based PVR solution. BTV is a good software, but it is too resource intensive, and requirement for its client software is quite high. I want to find something simpler and works better in older PC.

I have found this page on wikipedia, which is a great source of information. Comparing the specs and features, I think I will try to follwoing 2 solution.

GB-PVR, made in NZ??
Media Portal looks very comprehensive.

best of all unlike BTV, these 2 are freeware under GNU license. Nothing beats good FREE staff.

Friday, July 4, 2008

Apple Airport Extreme Firmware Update 7.3.2 - Simply Not Working

I recently tried to update the firmware of Apple Airport Extreme base station, since Airport utility tell me there is a update. So you will think the latest is always the best, you know fixing exisiting issues and bug. But not this instance, this update seens more like in its alpha stage. It broken existing functionality of APE. I had problem with wired ethernet LAN, APE simply can not see any other LAN device upstream. By this I mean, computers connected to a switch connected to Uplink port of APE and also ADSL router.

I spent hours try to figure out why it suddenly stop working while it worked perfectly fine before. Well you wont suspect the very latest "FIX" and "UPDATE" do you.

It turn out that there are lots of problem with update 7.3.2, you only need to visit the apple discussion forum to find tons of them. More specifically this post

I manage to revert back to previous version of firmware 7.3.1 which is working for me. (and lucky I can do the rollback as some ppl do not seem to have the option).

Conclusion, wait and see before launch head on to install the latest "FIX AND UPDATE"?

Wednesday, July 2, 2008

WCF Application Service Deployment Problem with IIS 404 Error

I have to deploy a WCF service application on IIS 6 at work. I get 404 error even though the service file .SVC file is obvious there. After searching the net a little, I found this article

It is possible the .NET Framework 3 is not installed properly. To make sure IIS's meta base is correctly configured for WCF and .svc extension, run following. It might save you hours.

"%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" /r /y


Monday, June 30, 2008

Regular Expression Parse CSV Code

/// <summary>
/// Helper Class for tokenise CSV files using mainly regular expression
///
/// </summary>
public class CSVStringTokeniser
{
/// <summary>
/// This expression says
///if found double quote or single quote then //(?(?=[\x22\x27])
///{
/// match column and strip quotes and commas //(?:[\x22\x27]+)(?<column>[^\x22\x27]*)(?:[\x22\x27]+)
///}
///else
///{
/// match column and strip commas //(?<column>[^,\r\n]*))(?:,?)
///}
///
/// This expression have the problem of putting extra empty match at the end when not needed
/// </summary>
public static readonly string _expression =
@"((?(?=[\x22\x27])(?:[\x22\x27]+)(?<column>[^\x22\x27]*)(?:[\x22\x27]+)|(?<column>[^,\r\n]*))(?:,?))";

/// <summary>
/// this simple case one can not handle comman with in the column, e.g "abc,efg",hijk
/// </summary>
public static readonly string _expressionSimple =
@"[^,\x22\x27]*";

/// <summary>
/// this expression is similar to _expression but this one do not put extra empty match at the end
/// however this one can not handle consecutive empty columns e.g. abc,,,efg
/// </summary>
public static readonly string _expressionTrial =
@"(?(?=[\x22\x27])(?:[\x22\x27]+)(?<column>[^\x22\x27]*)(?:[\x22\x27]+)(?:,?)|((?<column>[^,\r\n]+)(?:,?)|(?<column>\W*)(?:,)))";

/// <summary>
/// static method to tokenise a CSV (comma separated value) string
/// The limitation of this method is that it can not handle quoted empty columns, e.g. "abc","","","efg"
/// </summary>
/// <param name="inputStr">CSV String</param>
/// <returns>list of values in the CSV with quotes and comma removed</returns>
public static List<string> Tokenise(string inputStr)
{
// here we use _expression because it is most generic and can handle most situation
Regex reg = new Regex(_expression);

List<string> rs = new List<string>();

foreach (Match match in reg.Matches(inputStr))
{
if (match.Success)
{
foreach (Capture capture in match.Groups["column"].Captures)
{
if (capture.Index < inputStr.Length)
rs.Add(capture.Value);
else // ignore last match if the end charater is not another comma, hence an empty column at the end
{
string lastCharacter = inputStr.Substring(inputStr.Length - 1, 1);
if (lastCharacter == ",")
{
rs.Add(string.Empty);
}
}
}
}
}
return rs;
}
}

Regular Expression for parsing a CSV file with C#

I have to parse CSV (Comma Separated Value) files regularly. It is quite surprising alot of information exchange is still done in CSV format. I have also googled for a efficient way to parse a CSV file. A median performance solution for small CSV file is using regular expression. Regular expression used to parse CSV file has been quite complex.

After a few trial and error, I found a regular expression tokenise the CSV line quite nicely. It is surprisingly simple

[^,"]*

It says ignor comma and quote in your match, hence it will only match other characters. BUT NOTE, this simple expression can only handle very simple situation only, if it is possible there are comma (Separater) in a token, e.g. "abcd,efg"; the simple expression is not adaquate.

A more complex and comprehensive expression can be found from OmegaMan's Blog page. On his page you can find some very useful tips about using regular expression in C#.

Based on OmegaMan's expression for tokenise CSV, to parse a single line of CSV

((?(?=[\x22\x27])(?:[\x22\x27]+)(?[^\x22\x27]*)(?:[\x22\x27]+)|(?[^,\r\n]*))(?:,?)) #\x22 is double quote ", \x27 is single quote '

This expression says
if found double quote or single quote then //(?(?=[\x22\x27])
{
match column and strip quotes and commas //(?:[\x22\x27]+)(?[^\x22\x27]*)(?:[\x22\x27]+)
}
else
{
match column and strip commas //(?[^,\r\n]*))(?:,?)
}

I am yet to figure out one final problem, the above regular expression will alway return an empty match at the end. Need to figure out how to stop it from happening?

Update: I figure out what make it to do an extra match at the end of line if I modify the expression as following this problem will not occur

((?(?=[\x22\x27])(?:[\x22\x27]+)(?[^\x22\x27]*)(?:[\x22\x27]+)|(?[^,\r\n]+))(?:,?))

The problem is then how to make sure that empty columns are handle, the original one can hande empty columns such as "abc",,"efg". But the new one will ignor the empty column, if the regular expression represent some tabular data then we need to make the empty columns are handled.

One way to handle this might be using Match.Groups["column"].Captures[0].Index property and using the original expression. The index of match will equal to the length of input string, i.e. inputstring.lastIndex + 1 or inputstring.length.

Update: OK I finally got it, a expression:
(?(?=[\x22\x27])(?:[\x22\x27]+)(?[^\x22\x27]*)(?:[\x22\x27]+)(?:,?)|((?[^,\r\n]+)(?:,?)|(?\W*)(?:,)))

This one will handle empty column too. FINALLY.

UPDATE, damn, unfortunately the previous one is not perfect either, it can not handle 2 consecutive empty column e.g. "abc",,,"efg".
it will miss the second empty one. Still need to figure this one out.

AFTER much of try for couple of days, I think I will give up the idea of a pure regular expression solution to this problem. a combination of regular expression and C# code logic is need to solve this problem comprehensively.

Regular Expression for parsing a CSV file with C#

I have to parse CSV (Comma Separated Value) files regularly. It is quite surprising alot of information exchange is still done in CSV format. I have also googled for a efficient way to parse a CSV file. A median performance solution for small CSV file is using regular expression. Regular expression used to parse CSV file has been quite complex.

After a few trial and error, I found a regular expression tokenise the CSV line quite nicely. It is surprisingly simple

[^,"]*

It says ignor comma and quote in your match, hence it will only match other characters. BUT NOTE, this simple expression can only handle very simple situation only, if it is possible there are comma (Separater) in a token, e.g. "abcd,efg"; the simple expression is not adaquate.

A more complex and comprehensive expression can be found from OmegaMan's Blog page. On his page you can find some very useful tips about using regular expression in C#.

Based on OmegaMan's expression for tokenise CSV, to parse a single line of CSV

((?(?=[\x22\x27])(?:[\x22\x27]+)(?<column>[^\x22\x27]*)(?:[\x22\x27]+)|(?<column>[^,\r\n]*))(?:,?)) #\x22 is double quote ", \x27 is single quote '

This expression says
if found double quote or single quote then //(?(?=[\x22\x27])
{
match column and strip quotes and commas //(?:[\x22\x27]+)(?<column>[^\x22\x27]*)(?:[\x22\x27]+)
}
else
{
match column and strip commas //(?<column>[^,\r\n]*))(?:,?)
}

I am yet to figure out one final problem, the above regular expression will alway return an empty match at the end. Need to figure out how to stop it from happening?

Update: I figure out what make it to do an extra match at the end of line if I modify the expression as following this problem will not occur

((?(?=[\x22\x27])(?:[\x22\x27]+)(?<column>[^\x22\x27]*)(?:[\x22\x27]+)|(?<column>[^,\r\n]+))(?:,?))

The problem is then how to make sure that empty columns are handle, the original one can hande empty columns such as "abc",,"efg". But the new one will ignor the empty column, if the regular expression represent some tabular data then we need to make the empty columns are handled.

One way to handle this might be using Match.Groups["column"].Captures[0].Index property and using the original expression. The index of match will equal to the length of input string, i.e. inputstring.lastIndex + 1 or inputstring.length.

Update: OK I finally got it, a expression:
(?(?=[\x22\x27])(?:[\x22\x27]+)(?<column>[^\x22\x27]*)(?:[\x22\x27]+)(?:,?)|((?<column>[^,\r\n]+)(?:,?)|(?<column>\W*)(?:,)))

This one will handle empty column too. FINALLY.

Sunday, June 29, 2008

Regular Expression for parsing a CSV file with C#

I have to parse CSV (Comma Separated Value) files regularly. It is quite surprising alot of information exchange is still done in CSV format. I have also googled for a efficient way to parse a CSV file. A median performance solution for small CSV file is using regular expression. Regular expression used to parse CSV file has been quite complex.

After a few trial and error, I found a regular expression tokenise the CSV line quite nicely. It is surprisingly simple

[^,"]*

It says ignor comma and quote in your match, hence it will only match other characters. BUT NOTE, this simple expression can only handle very simple situation only, if it is possible there are comma (Separater) in a token, e.g. "abcd,efg"; the simple expression is not adaquate.

A more complex and comprehensive expression can be found from OmegaMan's Blog page. On his page you can find some very useful tips about using regular expression in C#.

Based on OmegaMan's expression for tokenise CSV, to parse a single line of CSV

((?(?=[\x22\x27])(?:[\x22\x27]+)(?<column>[^\x22\x27]*)(?:[\x22\x27]+)|(?<column>[^,\r\n]*))(?:,?)) #\x22 is double quote ", \x27 is single quote '

I am yet to figure out one final problem, the above regular expression will alway return an empty match at the end. Need to figure out how to stop it from happening?



Friday, June 27, 2008

OSX Keyboard shortcuts, Way of doing things

This is just a reminder for myself

OS:
Shutdown osx ctrl + option + cmd + eject
Restart ctrl + cmd + eject
Force Quit Screen option + cmd + esc

Finder:
Empty trash can cmd + shift + backspace
simple item info cmd + i
multiple item info cmd + option + i

VMWare Fusion 1.X.X Windows XP Pro x64 Problem

I have VMWare Fusion installed on my MacBook Pro to run Windows XP so that I can do Visual Studio C# Development on my Mac (best of both world?) While most of time it works well, but there are problems.

I have some problem with running Visual Studio 2008 and SQL Management Studio 2005 on Windows XP Pro x64 edition. I constantly getting memory access violation message from .NET Framework. And Visual Studio 2008 will quit randomly.

VMWare support suggested a flag in setting file mainmem.useNamedFile = "FALSE"; I tried it, it seem to have some effect but does not solve the problem at all.

I installed another instance of Windows XP 32 bit edition, and there are no problems.

Well I would think it indicate something is not right in Fusion for Windows XP Pro X64?

Wednesday, June 25, 2008

Vodafone NZ HSDPA Broadband XU870 on MAC OS X

I use Vodafone NZ Mobile Broadband (HSDPA) service with a Novatel Merlin XU870 ExpressCard, with my MacBook Pro OS X 15.3. For majority of times, the connection has been somewhat unstable.

When I first move to OS X 15 Leopard, Vodafone NZ does not support it the new OS X operating system. I have to resort to reading tones of forums and trial and error to figure out a way to make it work. I did manage to get it working just using Leopard's build in software and driver for the XU870.
Go to system preference -> network -> select XU870 -> Advance Option -> WWAN tab -> Select Novatel in Vendor drop down list, then click apply (important otherwise next option will not appear), then select GSM in model drop down list, then enter www.vodafone.net.nz into APN textbox , leave CID as default (1). Click Apply.
Back to general setting page and click on connect, you should be able to connect. After this, you will be able to see signal strength and connect and discount from task bar icon.

The above work around approach works, but it is not very stable (at least for me), the connect sometimes just hang, you can send requests (upload traffic) to server but does not seem to be any reply (download traffic), you will need to discount and remove the XU870 card and reinsert it then reconnect to make it work again. This is rather annoying. Not entirely sure if this problem is due to hacked way of set it up or it is simply because of Vodafone NZ's crappy service. One way to keep it working (connected) is to open something constantly using the internet connection; e.g. remote desktop, radio player.

Then May 2008 Vodafone NZ finally supported OS X 15 with new software Version: 2.08.05.04; 6 month after launch of Leopard .(Link to download vodafone software) I thought it might be better to use the Mobile Connect software, and it might solve the unstable connection problem. However, I am hoping too much, it is not the case. it make things worse than before, it is still unstable as before, (maybe a little better but not much), the connection still hang every so often. And it is more difficult to connect and disconnet, to do these you will need to go to the system preference network page.

Then today I come across this Launch2Net software. It suppose to be really good by reading the reviews, such as this one. But it cost 75 euros just for a single license. Very expensive, is it too much to spend just for more convenience? Have to think again

Tuesday, June 24, 2008

Windows XP Update Failed After Refresh Install (upgrade on top of existing system)

In this CNET Forum Post , you can find a very simple and effective solution to Windows Update Failed problem.

I had some problem with my Windows XP instance. After a refresh install (reinstall Windows XP using upgrade option); the Windows Update reports fail to apply updates. There is no obvious reason. I had this problem several times before. After lots of search, I finally come across this effective and simple solution.

Windows XP updates fail to install

by fnlvn2 - 28/07/07 00:16
In reply to: Windows Update KB928366 by jackfrost64

This sounds like a problem that I have after I've performed a repair installation. It's taken me about 6 months of research through tech sites including Microsoft's to find a repair that always works. In summary all if my updates would download but, all failed to install.
The solution is to register the dll files associated with the Windows Update Program. To do this do the following
Go to the start button then then the run button and type the following:

regsvr32 wuapi.dll (enter) you will recieve a confirmation message
regsvr32 wuaueng.dll
regsvr32 wuaueng1.dll
regsvr32 wucltui.dll
regsvr32 wups.dll
regsvr32 wups2.dll
regsvr32 wuweb.dll

Reboot and go to the windows update site and try to install your security update. I do understand that my problem was somewhat different than yours. However, one of the items that I was attempting to update was the same as yours. Therefore I'm quite confident that the solution is the same.

First Blog

Nothing to say really, just started a blog and try it.

I think I am going to use it to record interesting things (mainly IT technical) around the web that I want to remember.