Archive for the ‘Notes’ Category

SVN is the centralized repository system that many developers should have been familiar with. Mercurial (Hg) is one of the latest distributed repository system that is gaining popularity, besides Bazaar and Git. TortoiseSVN and TortoiseHg are GUI tools to manage SVN and Hg respectively in windows. That said, this note would apply mostly to windows users.

I would demonstrate two options to the migration but the outcomes might not be the same and I would detail the difference of each.

spacer1) Using Convert extension

This method convert the whole SVN repository into a Hg repository. No worries, full history from the SVN will be copied and you will be working with your Hg repository as though nothing had changed. The Convert extension is installed by default in TortoiseHg, so you just have to enable it. To enable it, open the global settings of TortoiseHg, go to the extension tab, and put a tick beside the Convert extension.

Activate Convert ExtensionspacerspacerFor the next step, you have to use the command line. Suppose your repository is on your hard disk, you would type:

hg convert file:///path-to-svn-repo


or if it is on a server:

hg convert http://url-to-svn-repo

spacerSome additional options include:

svn.trunk – Relative path to the trunk (default: “trunk”)

svn.branches – Relative path to tree of branches (default: “branches”)

svn.tags -Relative path to tree of tags (default: “tags”)

svn.startrev -Start subversion revision (as of 963000ed8cac, > 0.9.5). Work for single branches conversions only.

spacerAnd you use it as follow:

hg --config convert.svn.trunk=whatsoever convert

spacerspacer2) Using HgSubversion

By using this method, the main repository of your project remains as an SVN repository, while you can use Hg to manage your personal addition or modification on your hard drive. You should choose HgSubversion over the Convert extension when you have no control over the main repository or when you simply couldn’t persuade others to change from SVN to Mercurial.

The method gives you a fully-functional distributed version control system, where you maintain a Hg repository on your local computer to commit your own modification before pushing them to the central SVN repository. You can also work the other way round, i.e. pull the changes from the SVN repository to your Hg repository. Push and Pull are two essential concepts in a distributed version control system, which involve moving changes from one repository to another in either direction.

Steps to use:

a) Install HgSubversion by cloning it.

hg clone C:/Users/Public/hgsubversion

spacerb) Configure Hg extension by editing the configuration file (usually %USER_HOME%/mercurial.ini). Add the following lines:

hgsubversion = C:/Users/Public/hgsubversion/hgsubversion

spacerc) Start cloning your SVN repository. For example:

hg clone gwt-hg

spacerd) Pull changes from the SVN repository as normal using hg pull.

e) Before pushing to the central SVN repository, you should use hg rebase –svn. Then hg push as normal to push the changes back to the SVN repository.


spacerYet, you might ask: Why should I migrate from SVN to Mercurial after all?

Firstly, SVN is simply sounds…outdated! SVN is a thing of the previous decade, and people in the open source world are switching to Mercurial or Git.

Using Mercurial encourages you to commit more, due to the flexibility of working with Hg remotely. Every user has a local repository, complete with project history and branches, etc. You can commit to this local repository even when not connected to the central repository. With more frequent commits, you avoid messing up with a large portion of unsaved work.

Compared to using only one central repository, you generally have more backups by using Mercurial. Every user holds a clone of the project’s repository. If your central repository is corrupted or lost, you may still recover the whole repository from every individual users.

So, finally…Should you decide on using Mercurial for your projects, below are some good tutorials to get you started:

Hg Init: a Mercurial tutorial by Joel Spolsky


Command Line Networking Tools (Windows)

Posted: August 13, 2011 in Notes

I didn’t realize that Windows has such a bunch of networking tools until recently. These tools, available on the command line and free to use, can be used to configure, test, and troubleshoot a network. Although these tools are useful mostly to those technical people, (I might say) the average PC users may also find some useful command line tips here.

To run these tools, you need a Command Prompt. Go to Start-Run and enter “cmd” to open a Command Prompt.

  1. Windows IP Configuration Tool (ipconfig)
    The Windows IP Configuration Tool (ipconfig) is used to display TCP/IP network configuration values. If you are connected to a network, it will show your all your connections along with the IP address, subnet mask, and default gateway.

    Windows IP Configuration
    Wireless LAN adapter Wireless Network Connection:
       Connection-specific DNS Suffix  . :
       Link-local IPv6 Address . . . . . : fe80::daf:1320:ac4b:4d71%11
       IPv4 Address. . . . . . . . . . . :
       Subnet Mask . . . . . . . . . . . :
       Default Gateway . . . . . . . . . :
    Ethernet adapter Local Area Connection:
       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . :

    Besides, ipconfig might output more information or functions if you provide it with options. You may see a list of valid options by running ipconfig /?

    C:\>ipconfig /?
        ipconfig [/allcompartments] [/? | /all |
                                     /renew [adapter] | /release [adapter] |
                                     /renew6 [adapter] | /release6 [adapter] |
                                     /flushdns | /displaydns | /registerdns |
                                     /showclassid adapter |
                                     /setclassid adapter [classid] |
                                     /showclassid6 adapter |
                                     /setclassid6 adapter [classid] ]
        adapter             Connection name
                           (wildcard characters * and ? allowed, see examples)
           /?               Display this help message
           /all             Display full configuration information.
           /release         Release the IPv4 address for the specified adapter.
           /release6        Release the IPv6 address for the specified adapter.
           /renew           Renew the IPv4 address for the specified adapter.
           /renew6          Renew the IPv6 address for the specified adapter.
           /flushdns        Purges the DNS Resolver cache.
           /registerdns     Refreshes all DHCP leases and re-registers DNS names
           /displaydns      Display the contents of the DNS Resolver Cache.
           /showclassid     Displays all the dhcp class IDs allowed for adapter.
           /setclassid      Modifies the dhcp class id.
           /showclassid6    Displays all the IPv6 DHCP class IDs allowed for adapter
           /setclassid6     Modifies the IPv6 DHCP class id.
  2. Ping
    Technically, to ping a host is to send Internet Control Message Protocol (ICMP) Echo Request messages to the host  and wait for an Echo Reply message from the host. You may ping a target to check the connectivity to a remote site, for example, ping By default, four packets will be sent, or you could force unlimited packet using ping /t The server should reply within fractions of a second (depending on the speed of your connection), and the output should look like below.

    Pinging [] with 32 bytes of data:
    Reply from bytes=32 time=69ms TTL=231
    Reply from bytes=32 time=70ms TTL=231
    Reply from bytes=32 time=68ms TTL=231
    Reply from bytes=32 time=69ms TTL=231
    Ping statistics for
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 68ms, Maximum = 70ms, Average = 69ms
  3. Tracert
    Tracert(traceroute) is used to determine the path taken from your PC to a destination. The path displayed is the list of near-side router interfaces of the routers in the path between a source host and a destination. The near-side interface is the interface of the router that is closest to the sending host in the path. For example, try enter tracert

    Tracing route to []
    over a maximum of 30 hops:
       1    <1 ms    <1 ms    <1 ms
       2    35 ms    19 ms    29 ms
       3    11 ms    27 ms     9 ms []
      13    81 ms    76 ms    75 ms
      14    84 ms    91 ms    87 ms
      15    76 ms   112 ms    76 ms []
    Trace complete.
  4. Pathping
    Pathping combines the functionality of ping with that of tracert. Pathping will first output the details of the path between your computer and the destination; and subsequently it will display Ping-like statistics for each node in the path based on samples taken over a time period.
    The advantages of Pathping over ping and traceroute are that each node is pinged as the result of a single command, and that the behavior of nodes is studied over an extended time period, rather than the default ping sample of four messages or default traceroute single route trace.
  5. Netstat
    Netstat displays a list of active connections on your computer, including all inbound and outbound connections. Besides, it can also display Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6 and UDP over IPv6 protocols).
    Shown below is a list of options. The options must be prefixed with a hyphen (-) rather than a slash (/).

    C:\>netstat /?
    Displays protocol statistics and current TCP/IP network connections.
    NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-t] [interval]
      -a            Displays all connections and listening ports.
      -b            Displays the executable involved in creating each connection or
                    listening port. In some cases well-known executables host
                    multiple independent components, and in these cases the
                    sequence of components involved in creating the connection
                    or listening port is displayed. In this case the executable
                    name is in [] at the bottom, on top is the component it called,
                    and so forth until TCP/IP was reached. Note that this option
                    can be time-consuming and will fail unless you have sufficient
      -e            Displays Ethernet statistics. This may be combined with the -s
      -f            Displays Fully Qualified Domain Names (FQDN) for foreign
      -n            Displays addresses and port numbers in numerical form.
      -o            Displays the owning process ID associated with each connection.
      -p proto      Shows connections for the protocol specified by proto; proto
                    may be any of: TCP, UDP, TCPv6, or UDPv6.  If used with the -s
                    option to display per-protocol statistics, proto may be any of:
                    IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.
      -r            Displays the routing table.
      -s            Displays per-protocol statistics.  By default, statistics are
                    shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;
                    the -p option may be used to specify a subset of the default.
      -t            Displays the current connection offload state.
      interval      Redisplays selected statistics, pausing interval seconds
                    between each display.  Press CTRL+C to stop redisplaying
                    statistics.  If omitted, netstat will print the current
                    configuration information once.
  6. Nslookup
    Known as Name Server Lookup in full, this tool is available to query the Domain Name System (DNS) to obtain the domain name or IP address of any specific DNS record. To run a query, type nslookup followed by the domain to query and the name server (optional). For example:

    Non-authoritative answer:
  7. Netsh
    Netsh is a powerful tool to perform the following task:

    • Configure interfaces.
    • Configure routing protocols.
    • Configure filters.
    • Configure routes.
    • Configure remote access behavior for Windows-based remote access routers that are running the Routing and Remote Access Server (RRAS) Service.
    • Display the configuration of a currently running router on any computer.
    • Use the scripting feature to run a collection of commands in batch mode against a specified router.

    The features available apply mostly to system administrators and are beyond the scope of this article. More information is available at Microsoft’s web site here.

Notes to Self

Posted: August 13, 2011 in Notes

One of the wonderful things about programming is that you are constantly learning and dealing with something new. Once in a while I would figure out how to install or use a new piece of software, how to troubleshoot a computer or software bug, how to integrate a new API, etc. It is always tempting to jot down what that I have learned. It helps both to serve as a reference in the future and to consolidate the knowledge that I have attained.

Previously, I’ve always written these little notes on the papers. I found it difficult to keep track of the notes I’ve produced over the years, besides being inconvenient for reference because I always work on my computer. Meanwhile, I love the joy of sharing it with others and therefore I am now putting aside this category named “Notes” in my blog for all the notes I would write to myself.

Finally, it’s my hope that you, the reader, will benefit from the little notes I wrote.

I’ve kept a Ubuntu Server installed on my laptop for almost a year. Only until recently that I have tried to connect the server through the wireless networking card. Indeed, I’ve been through some hard times, searching and trying desperately to get the wireless card to work. The server doesn’t have a desktop manager, i.e no GUI, so everything has to be done in the terminal. So here I am to explain the whole process to ease others who would also wish to configure their networks using the command line.

  1. The first step is to check that you have the appropriate tools installed. In the command line, type in the following.
    sudo apt-get install wireless-tools

    This will install the Wireless Tool package containing the following tools:

  2. Next find out the chipset of your wireless card. To do this, type in
    lspci | grep Network


    lsusb | grep Network

    depending on whether you use a pci or usb card. The output will be like

    02:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g (rev 01)
  3. Now you know your chipset. Some wireless chipsets work out of the box. In my case, it’s a Broadcom chipset and it’s not supported by default. For this step try google for the appropriate drivers, or you may use ndiswrapper if your Wifi card comes with a Windows driver.
  4. After installing the driver, make sure the card can be detected.

    The command will list your wireless card. For example:

    lo        no wireless extensions.
    eth0      no wireless extensions.
    eth1      unassociated  ESSID:off/any
              Mode:Managed  Channel=0  Access Point: 00:00:00:00:00:00
              Bit Rate=0 kb/s   Tx-Power:off
              Retry:on   RTS thr:off   Fragment thr:off
              Power Management:off
              Link Quality:0  Signal level:0  Noise level:0
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:0  Invalid misc:0   Missed beacon:0
    virbr0    no wireless extensions.
    pan0      no wireless extensions.

    Sometimes, the wireless card is disabled so you get “no wireless extensions” for every device.
    You can activate your card by typing

    sudo ifconfig eth1 up

    Then re-execute iwconfig to make sure it is okay.

  5. Issue the following command to scan for wireless network.
    sudo iwlist eth1 scan

    and the output:

    eth1      Scan completed :
              Cell 01 - Address: 00:22:6B:6A:3E:85
                        Frequency:2.437 GHz (Channel 6)
                        Quality:5/5  Signal level:-50 dBm  Noise level:-90 dBm
                        Encryption key:off
                        Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                                  24 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 9 Mb/s
                                  12 Mb/s; 48 Mb/s
  6. Connect to the access point of your own choice. The ESSID is the identification name given to an access point. Identify the ESSID you wish to connect.
    sudo iwconfig eth1 essid "FKMWifi"
    sudo iwconfig eth1 mode managed
    sudo iwconfig eth1 commit
  7. For WEP or WPA encrypted network, you need to input the key. For WEP encrypted networks, the following two commands applies. Use the first command if you have an ASCII key and it will translate the key to its hexadecimal form.
    sudo iwconfig eth1 key s:password
    sudo iwconfig eth1 key 70617373776f7264

    For WPA encrypted network, you have to generate the WPA-PSK key using the essid and your password.

    wpa_passphrase <your_essid> <your_ascii_key>

    And the output will be something like


    Notice the last line of hex gibberish. Use that as your WPA-PSK key and issue the command

    sudo iwconfig eth1 key b51f838d5e7ea198d2dc141350687f6ea7b1995215c9b40b302dc6ca96c94537
  8. Obtain an IP address from the DHCP server by issuing the command
    sudo dhclient eth1

    The output similar to the below will be printed.

    Listening on LPF/eth1/00:21:00:b7:db:2d
    Sending on   LPF/eth1/00:21:00:b7:db:2d
    Sending on   Socket/fallback
    DHCPREQUEST of on eth1 to port 67
    DHCPACK of from
    bound to -- renewal in 240 seconds.
  9. Ping an publicly known address to check that everything works.
  10. Additionally, you might want to save the hassle by configuring your network to connect automatically once your computer starts. Modify /etc/network/interfaces by adding the following lines.
    sudo vim /etc/network/interfaces

    For WEP encrypted network:

    auto wlan0
    iface wlan0 inet dhcp
    wireless-essid   <your_essid>
    wireless-key     <your_password>

    For WPA encrypted network:

    auto wlan0
    iface wlan0 inet dhcp
    wpa-ssid <your_essid>
    wpa-psk <your_wpa_psk_key>

Other resources:
WifiDocs – Ubuntu Official Documentation
Configuring encrypted wireless network