#Google Analytic Tracker

Pages

Mar 20, 2007

Some Danger of Refactoring using ReSharper

No doubt, ReSharper (2.5 specific) had helpped me a lot when coding in C#. Particularly I like its Reformat code feature which it removes redundancy in the code.

For example

private void DoSomething(object sender, EventArgs e)
{
   DoStuff(e);
}


private DoStuff(EventArgs e)
{
...
}

Resharper will suggest to remove the parameters "sender"

However, what if your function looks like the following:

private void DoSomething(object sender, EventArgs e)
{
    if (this.m_oLogGridView.InvokeRequired)
{
this.Invoke(new EventHandler(DoSomething), new object[] {this, new object()});
}
else
{
DoStuff(e);
    }
}

Resharper will suggest you to remove the parameter "sender". However, if you remove the sender parameter without fixing "this.Invoke(method target, parameters)" function, you will run into runtime error. That's because the number of parameter we are passing using the this.Invoke() doesn't match the method parameter.

So, be careful when use refactoring.

Mar 11, 2007

ASUS WL-500gP Custom Firmware Setup Experience

Introduction(In construction)

When I was traveling in Hong Kong, I know that computer hardwares are cheaper than in Canada. I knew that I need a better router than my crappy old 4 ports non-wireless router. After some research I found ASUS WL-500gP Multi-Functional Router.

WL-500gP Spec


Here are specs for all chips:
Under the big metal cover
BROADCOM BCM4704KPBG CT0542 P11 757088 M5
SPANSION S29GL06 4M90 TFIR7 0530MBM N © 04 SPANSION
HYNIX 540 A HY5DU281622ETP-5 KOR H6CC9718TQ2

on the motherboard uncovered
BROADCOM BCM5325EKQMG RD0604 P11 765129A 5
VIA VT6212L G 0552CD TAIWAN 23B7005400
DELTA LFE8731 0548
DELTA LFE8505 0549W

on the Mini-PCI board
BROADCOM BCM4318EKFBG HS0547 P20 760839 N1
SIG 2521A6 5336E

Reference

Short Coming of the ASUS Firmware

I have tried using WL-500gP firmware ver 1.9.6.9 and 1.9.7.2. Although 1.9.7.2 is an up to date version (up to the point I am typing this), 1.9.6.9 seems to work better. The major issue I have with 1.9.7.2 is the network connection speed access to my external harddrive was down to about 300kB/s instead of the usual 3MB/s. So, I went back to 1.9.6.9. In addition, Download Master (DM) doesn't properly and report of Bit Torrent status is confusing. (i.e. when BT is downloading, DM would say it is queue). Multiple BT doesn't seem to work at the same.

Custom Firmware for the Router



Installing Oleg WL500gp-1.9.2.7-7f.trx

There are 2 useful posts that had help me install the Custom Firmware

Tutorial by marcnesium on http://wl500g.info/
Follow up of the above tutorial

Basically I found that the follow up instruction is much clear on what you need to do. However, you are still require to have some Linux command-line skills and some basic understanding of the Linux OS in general.

Here is the summary of what I did by following their instruction
  1. Set your WL-500gP into recover mode
    • Power off your router
    • Use a paper clip to whole the Reset button behind your router, then plug the power back on, hold this button for 5 sec to make sure it goes into recovery mode
    • You will see the Power light blinks slowly if your router is in recover mode,

  2. Use the ASUS Utility to upload the trx file to your router
    • Make sure your firewall is off, otherwise the ASUS may give you a Invalid IP error


I am using Fujitsu 100GB External harddrive (2.5" size), which seems to work very well. I don't need any power adapter for the harddrive because the power is supplied by the router via USB port.


Make Partition to your harddrive using Linux fdisk command

part1 - Win95 partition -- "I don't know what Partition magic did"
part2 - Linux swap partition
part3 - Linux data ext2 partition -- mount to /opt
part5 - Linux old_data ext2 partition

Note: Busybox seems to do automount, and a process call stupid-ftp cause me lot able to write the system table to the harddrive. It turns out that I have to disable FTP Server though the ASUS configuration


One good thing with ipkg is that is has an update function which update the list of available pkg online.

dropbear Setup
for some reason I have 2 dropbear initialization code written on the post-

Samba Setup
Your router must have a LAN HOSTNAME, you can set it up thought the ASUS Web Interface.
Not too sure why, I have the following setup in the post-boot file, but it doesn't seems to take affect:

#Set hostname
hostname your.host.name

Reference: http://samba.org/samba/docs/man/Samba-HOWTO-Collection/


Install (c)Torrent
ipkg install ctorrent
ipkg install torrent

Follow marcnesium's ctorrent installation step

In the "/opt/etc/torrent.conf", set the source and target to the share drive as your samba for easier access to the torrent files.


Notice that if you just install ctorrent, you

ipkg install libstdc++
ipkg install ctorrent
ipkg install torrent

If you follow marcnesium, it seems like the post-mount script never gets run.

Tips and Things that Learn about Linux Embedded System

Useful configuration paths to know:
post boot script : "/usr/local/sbin/post-boot"
samba-config-file: "/opt/etc/samba/smb.conf"
cgi-script: httpd configuration file: "/usr/local/root/httpd.conf"
http daemon start-scripts: "/usr/local/sbin/post-mount"
ctorrent configuration: "/opt/etc/torrent.conf"

Useful Log file paths:
DHCP log: "/tmp/dnsmasq.log"
Samba log: "/var/log/smb", ""/var/log/nmb"




Here is my smb.conf setting: (Note, you need to have an LAN Hostname, I didn't have it and I have lot of trouble of setting Samba to work. I pretty much turn off the security for now. Then I will start tuning the parameters

Samba Reference

Samba Reference 2

[global]
workgroup = home
netbios name = WL-500gP_Computer
server string = WL-500gP
security = share
browseable = yes
local master = no
guest ok = yes
guest only = no
log level = 1
max log size = 100
public = yes

[ASUS_share]
comment = WL500gP share folder
path = /opt/smbshare
public = yes
writeable = yes
guest ok = yes


Create these directory for your torrent

mkdir /opt/share/torrent
mkdir /opt/share/torrent/source
mkdir /opt/share/torrent/work
mkdir /opt/share/torrent/target


Comment


Isn't it cool you have a embedded Linux System running as a router for your home or office! I have been using Windows all of my life, expect during University year where I have to play around with Linux and Unix system. Most often I installed Linux on a dual boot system, but I rarely do anything with my Linux system because I do most of my work on a Window System due to software compatibility that I comfortable of using.

Feb 28, 2007

Finding an Accounting Software

My dad's friend who own a store is in the US wants to use a accounting software to bill invoices automatically. However, she has 2 major requirements that has to be done. 1. The invoice number will automatically increment ... all accounting software does that 2. The statement (a summary of invoices) has a unique statement number... never hear that before I thought that, hey, it shouldn't be hard to find a software that does that. However, my dad's friend told me that she had paid money to other people before and no one able to come up with a good solution. She even paid someone to write a custom software but it didn't work out. She also fax me the invoices and the statement (Customer Statement). Indeed, the customer statement has a unique number on it.

Researching

So, I went off the do some accounting software research. With a little background that I know about accounting. I checked the following software: a. Quicken b. QuickBook c. Simply Accounting d. MS Accounting e. Other invoice billing program However, I finally realized why she has fail to find a suitable accounting software, it is because no accounting software will generate a unique incremental statement number.

What is a customer statement?

The customer statement represent a customer transaction activities in a specific period. It usually list billed invoice, amount the customer paid and the account balance. It also so the period of these activities, usually monthly The practice that my dad's friend is doing is that instead of billing her customers invoices, she bill them using a customer statement (which shows a list of invoices number). I can see the advantage of billing a summary of invoice, and with a unique statement number, it helps communicate with the customers by using the statement number, instead of date.

More Researches

So, I start looking at Quicken, Quickbook and Simply Accounting to see if I can add a statement number on it. Unfortunately none of the software able to create a statement number I even called to Intuit to see if Quickbook able to print a statement number. Although they keep telling me Quickbook has many customization you can do, they don't really know what a statement number is, and all they try to do is sell the product to me. Feeling unsatisfied, I installed all the mentioned software trial. I realized that the only software that allow me greatly customize the software is Microsoft Accounting 2007 Express.

Experimenting with Microsoft Accounting 2007

Although I am not an accountant, and I don't own a business, I like the MS Accounting interface. It is very simple and it is not like other Office software like Words and Excels, it is intuitive to do the simple activities small business owner need. Of course, this is just my unprofessional opinions, you have to try it out yourself to judge. The good thing I like about this software is that i use MS Word document as a temple for printing out Custom Statement (other report and invoices also use MS Word). For people who use MS Words would find it easily to customize the format and feel of any kind of report and statement. However, using MS Accounting 2007 alone will not help me to print the statement number that I want. So I think of a solution. By setting up a MS Access database that keep track on Statement number and do some Words VBA, this should solve my problem. Well... not quiet.....

Simple Thought

As a newbie in Words VBA programming. I started doing my study on how Words VBA works. My idea is that whenever MS Accounting print the Customer Statement, it will get the statement number from a mdb (MS Access file) and put it on the Customer Statement. Once it print, the statement number will increment and store it back into MS Access.

Testing the Idea

Well, it turns out that the only event that I can capture from MS Word is user command, such as "File->print". I can't use macro to capture a print event if MS Accounting to print a Word document. So, I wonder can I run a macro whenever the Word document. 1st, I can't find an event that would fire a macro whenever word open (I guess it is a security issue). 2nd, I beginning to realize that it is MS Words that runs the macro, and MS Accounting wouldn't able to execute Word's macro. How silly I am.

Given Up!

It is not the problem of MS Accounting or another other software, it is a fundamental issue of accounting. There isn't a thing call "Statement Number". My dad's friend introduced this "Statement Number" doesn't really make sense and only add confusion in the future. Think about database design. Your Customer Statement is identify by the period and the customer. If there is a unique statement number, what happen if you want to print the same statement (program wise it is hard, because you have to keep track what statement number to use for a specific period). What if someone corrected an entry in the pass, and print out another customer statement to customer? Now, you may have a conflict of using a statement number representing the same period of customer's activity. Well, I guess you have to tell the customer to discard the old statement and use the new one.

Another try?

Nah, I will explain to my dad's friend able what I find. Unless she want someone to write the software, otherwise I suggest her to give up the idea of having a unique customer statement number unless it is required due to law compliance.