Monday, April 01, 2013

Beware MochaHost

Beware MochaHost

You may have seen MochaHost advertising aggressively on the Internet and Facebook recently. In fact, their ad might be showing below/beside this post right now! Please beware. This is a real case of too good to be true.

Mochahost Never - San Jose, California

Saturday, March 30, 2013

web2py on webfaction


I've done a lot of searching on the web on how to get web2py working on webfaction, and saw a lot of forum messages with all kinds of complicated instructions that don't really get to the point.

I've been using Webfaction to host my web2py applications

Update special mention goes to PythonAnywhere which actually supports Web2Py out of the box (i.e. there is an installer for web2py available). is actually being hosted on PythonAnywhere now.

The main reason I went with Webfaction was that they had a data center in Singapore.  I've been with them for a month now, and am very happy with the features, performance and availability, as opposed to say, Heroku, or Amazon AWS. I spend $200+ dollars a week on transport alone. At $9.50 a month, and 60-day no questions asked refund policy, what more can you ask for? Sign up and try for yourself!

Python hosting is really much more flexible than most!

Webfaction Configuration

There are really only 3 major things that matter:


  • Add a domain, or use your existing one, which is like


  • Add a Custom application (listening on port) - yes, I called mine web2py.
    1. $HOME/webapps/web2py will be created
    2. cd $HOME/webapps/web2py
    3. Fetch the web2py source using Git. These commands are my personal preference; you can do whatever you are comfortable with.
      1. git remote add origin
      2. git fetch origin
      3. git checkout -B master origin/master


    1. Add these 2 separately:
      1. Normal website (http)
      2. Encrypted website (https)
    2. In the Domain field: fill in the domain that you have just created. Note: the same domain can be used for both Normal and Encrypted websites.
    3. In the Contents field: Reuse an existing Web App - choose the web2py app created earlier.
The encrypted website that you have created will allow you to access both the applications as well as the web2py admin interface.

web2py application settings; note the port number, your web2py instance will have to listen on this port.

Starting the web2py app

Webfaction's frontend (actually an Nginx proxy) will send incoming requests for your domain to the port that it has allocated for the application. This means that you can run the web2py appliance as normal, listening on the allocated port.

Let's use the following settings for the purpose of illustration:

  • export APPN=web2py
  • export PORT=12345

First run

The most straightforward way of starting the app is:
cd $HOME/webapps/$APPN; python -p $PORT
You will be asked for the admin password - enter it and let the app run.

Subsequent runs

Use the -a "" option to tell web2py to pick up and reuse the same admin password that you have entered previously.

cd $HOME/webapps/$APPN; python -a "" -p $PORT

Keeping it alive

You need to keep the app running, preferably forever. How do you keep the app running after you've logged out from the SSH shell?

Option 1 - Screen

Use the screen utility.

  • Start screen: screen
  • Start the web2py server as before.
  • Log out.

Your app will still stay up, but unfortunately, will not survive a server reboot.

Option 2 - Cron

Create a script in $HOME/bin/startweb2py (please change the PORT to your own port) This script will only start web2py when it is not detected at the allocated port.
export PORT=12345
export APPN=web2py
curl http://localhost:$PORT/ >/dev/null 2>/dev/null || {
python $HOME/webapps/$APPN/ -a "<recycle>" -p $PORT
Put this in your crontab (use the crontab -e command)

@reboot bash $HOME/bin/startweb2py # starts this when the server reboots
@hourly bash $HOME/bin/startweb2py # run every hour in case the server goes down unexpectedly

Advanced Topics

You can try running web2py with other supported servers. There might be some differences in terms of memory usage and performance. 

Look into the Servers class in currently supported options are cgi, flup, wsgiref, cherrypy, rocket, paste, fapws, gevent, bjoern, tornado, twisted, diesel, gunicorn, eventlet, mongrel2, motor, pulsar

e.g. assuming the PORT environment vairable has been set with 
export PORT=12345
  • python -p $PORT -s gunicorn
  • python -p $PORT -s eventlet
  • python -p $PORT -s tornado
The memory usage can be monitored with the ps command:
ps -u $USER -o pid,rss,cmd

Sunday, March 21, 2010

New Resolution - Pick up Distributed Version Control

I'm starting with Mercurial, because Joel Spolsky wrote a tutorial on it. I admit I had a hard time trying to pick up Git and Perforce (is that a DVCS?), but I am starting with Mercurial.

I've just started on the first chapter at

Thursday, March 18, 2010

Mercurial is a modern, open source, distributed version control system, and a compelling upgrade from older systems like Subversion. In this user-friendly, six-part tutorial, Joel Spolsky teaches you the key concepts.

Wednesday, March 17, 2010

Collection of Code Snippets

Why do programmers/developers bother to rewrite the same code skeletons all the time? Do it once (or not at all), share it, and benefit from others' contributions!

Monday, March 15, 2010

JQueryUI - Superb GUI Toolkit

There are a lot of tool-kits and software that are purportedly very powerful, flexible, feature-packed etc. But most of them are rather difficult to setup, or have a steep learning curve, or lots of documentation to read,

... ... or ... ...

all of the above.

JQueryUI is the first tool-kit I've used that has instructions in a few succinct lines that I can easily understand, use, and just get it to work!

Highly recommend JQueryUI (and of course, JQuery) for all web GUI development work.

Thursday, March 11, 2010

Python Tools for Web Form Interaction

If you are like me, who, needs to write custom automated testing software to interact with devices with web interfaces, the tools you choose will definitely make a big difference to your productivity.

I've discovered ClientForm
... a Python module for handling HTML forms on the client side, useful for parsing HTML forms, filling them in and returning the completed forms to the server.
that is very good news for me, since I have to automate several tasks working with devices that provide only an interactive web interface. Activities like logging in, updating code, resetting the device, etc, that require more complicated mechanisms like cookies, hidden fields, and random nonces, prohibit the use of statically configured form submissions.

I had started off sniffing and dissecting web pages to manually discover the required information to submit dynamic forms. This activity can take me a whole day for just a simple user interface login. ClientForms, by doing all the hard work of parsing the form, has enabled me to cut this down to 15 minutes. I guess the only difficulty remaining is with forms being manipulated by Javascript during submission. I am still learning more about ClientForms but there is much more in the Python community (and for that, Perl) that can be harnessed to make life for programmers more productive.

I shall leave you here. In a subsequent post, I shall share some of the other tools that I have found, and also some history of my programming experience.

Thursday, February 18, 2010

Dell Internal Wireless Channel Problems

I've had a hair-pulling week trying to setup a couple of new wireless access points in the office.

Using the default of auto-channel selection on the AP, it selected channel 1 to be the cleanest channel. However, all our Dell Latitudes D610/D620/D630 did not manage to "connect" to the AP when using the internal wireless card.

My mobile phone could connect fine, so did an external adapter. Only the internal wireless didn't work.

I brought the AP back home, and it could connect flawlessly. I brought it back to the service center, and it worked too.

Then I tried changing the AP channel to some other channels and I was able to connect. Is there something with older Dell Latitudes with working on channel 1?

Sunday, January 10, 2010

Canon P-150

Despite the 'P' Prefix, this is a scanner, not a printer.

I just bought this from Challenger yesterday instead of ordering it from Amazon and having it shipped. The difference is about $80, good enough for a cool date night out in town.

Change default input method on Windows Mobile

Changed the default input method on my Omnia2 (WM6.5) from the Samsung keyboard to Swype.

Set HKEY_CURRENT_USER\ControlPanel\Sip:DefaultIM to "{7D51A54F-14D0-4eda-AC8D-0AE175C344E8}".

Follow the link in the title for the post where I first saw this information. I'm going to reproduce it here:
  1. Run registry editor on the Windows Mobile device.
  2. Navigate to the following registry key:


  3. Locate a registry entry named DefaultIM. Change the string value data for DefaultIM to the following CLSID according to your preference of input method.

    To make Letter Recognizer as default input method

    To make Block Recognizer as default input method

  4. Soft reset the device after change to make the new default input method effective.
  5. To revert and change back to the default original Keyboard input method, the value data of DefaultIm for keyboard is {42429667-ae04-11d0-a4f8-00aa00a749b9}.

If you have other input method, most of its CLSID is stored at HKEY_CLASSES_ROOT\CLSID registry key branch. Locate the full complete CLSID for the input method, and change the “DefaultIM” value data accordingly to set different input method as default to use and activate in Windows Mobile device.

How to disable "message sent" bubble in Omnia2

Omnia2 from M1, Singapore, running Windows Mobile 6.5. Searched high and low on the Internet, but all the forum postings are copied from the same two sources, including the typos.

Tried setting these keys to '1' but still to no avail.


Somehow, Samsung's own messaging application is not reading these settings.


Omnia2 Tweaks + FAQs

Click on the link in the title ...

This is a comprehensive list of very useful tips for the Omnia2. Start here for more information.

Omnia2 - Enabling the Lunar Calendar

Edit registry key: Hkey_Local_Machine\Software\Microsoft\Calendar

Set "ShowLunarCalendar" to 1

Open your calender program and click the on right-bottom Menu -> View -> Lunar

Windows Mobile /WinCE Registry Editor

On my Omnia2 running Windows Mobile 6.5, I am using Schap's Registry Editor for WinCE (click link in the title of this post). This is good for editing registry keys which remote editors are not allowed to access/change, probably denied by ActiveSync.

CERegEditor runs on the desktop PC connected to the Windows Mobile phone (I'm doing this via ActiveSync/USB). This is very useful for "downloading" large sections of the registry to find where certain configuration settings are stored.

Omnia2 - Change Touch Vibration Strength

Omnia2 (GT-I8000) running Windows Mobile 6.5 has a vibration feedback for taps on the screen. It happened to me suddenly, that the vibration was gone, even when I enabled it in the Settings, Sound Settings, Touch Alert, Alert (set to "Vibration" or "Sound + Vibration").

Searching the Internet for this turned up more noise than signal. So, digging into the registry, I found this key HKEY_CURRENT_USER\ControlPanel\VibeTonz.

It turned out that the strength of the vibration could be configured, and it was set to 0.

TouchVibeStrength (DWORD:0-5) controls the strength of the vibration.
TouchSoundOn enables sound feedback.
TouchVibeOn enabed vibration feedback.

Disable Threaded SMS on Omnia 2

Device: Omnia2 (GT-I8000)
OS: Windows Mobile 6.5

Get a registry editor (I used CERegEditor by mdSoft)

Open the key HKEY_LOCAL_MACHINE\Software\Samsung\JINBOX. Samsung's messaging application are stored inside here.

Set "ThreadedViewDisabled"=dword:00000001

Friday, December 25, 2009

Mobile Transition - Nokia E65 to Samsung Omnia2

Traded in my Nokia E65 for the Samsung Omnia2 (GT-I8000) on Christmas day 2009. Switched to M1 from Singtel.

Original contract price: $398
SunSaver Plus discount: -$100
Data Plan discount: -$100
Switching from Singtel: -$100
E65 Trade-in: -$100
Final amount paid for handset: $0.

Still getting used to the phone and applying numerous registry hacks. It's not all that bad actually ... getting an iPhone just ties you in to a fixed user experience. I still prefer some flexibility and the ability to get under the hood.

I'm quite sure you can get under the hood for the iPhone and Andriod phones as well. And I agree: Windows Mobile is slow and laggy, but somehow, only on Samsung handsets. HTC phones with lesser hardware specs seem to run circles around my Omnia2. Sigh.

Tuesday, June 23, 2009

Speed Up SSH Logins

  1. Disable UseDNS
  2. Give the -u0 option in /etc/default/ssh

Monday, March 30, 2009

DD-WRT on DIR-300

I wanted a standalone AP-client/Ethernet converter/Wireless bridge. I couldn't find a suitable product on the market (with my budget of < US$50). The products I did manage to find were either too expensive, too old, not available, or too over-featured (remember you heard this term here!).

Well, there were a few: like the Zyxel G-570S which cost S$99 (too expensive), Engenius ECB-1220R which was not yet available (but the price seems alright at S$75). Asus WL-320gE/WL-330-gE looked like they fit the bill too, but was too expensive.

The Linksys WGA54 was an obsolete, EOL product. Last firmware was in 2005, and it doesn't support WPA. I bought 3 of them only to find out that they worked quirky too. There was no way to get the signal strength, for example.

I came back to something that I've overlooked for a while, because the published product specs didn't support an AP client mode - the Dlink DIR-300. It was based on an Atheros AR2317 which IS supported by DD-WRT, which had client mode wireless, which was a full linux distribution (something which I was right at home with), and it was both CHEAP (S$50) and readily available. So I popped over to Challenger on the weekend, bought one unit, and brought it into the office today to get it converted.

It wasn't too daunting after all. It took me a few tries and reboots to get the DD-WRT firmware properly flashed onto the board, and a couple more steps later we are in business. I got my wireless AP client up and running.

I was able to connect to an AP using WPA2-PSK via the webpages. The only complaint I had about the interface was that it put the onus of knowing the security settings on the user, and did not detect the suitable configuration for the AP. It had telnet (how about SSH?), but the username and password did not match the web-based login. AP scanning works well. I could use the iwconfig and iwlist commands to scan for access points and get the signal strengths. Just perfect for my wireless testing. I could even do performance testing from the router itself.


Thursday, February 19, 2009


This is what I have always been talking about (but failed to achieve/implement/convince). It's way overdue that application programmers use a common library API to manage configuration settings instead of having to reinvent the wheel a million times. I have heard all the arguments before, and I have an explanation for each and every one. So come on and flame me, but of course I would rather have an engaging discussion.

If Elektra were a girl, she'd be the one I'd marry. (based on first impressions till date)

Overview of the Elektra Initiative

Elektra is a universal hierarchical configuration store, with related goals like GConf and the Windows Registry. It allows programs to read and save their configurations with a consistent API, and allows them to be aware of other applications' configurations, leveraging easy application integration. The whole point of it is to tie applications together, so that they can co-operate and share their user-preferences.

The developers are associated to unix philosophy and the very practical point consists of writing a configuration library. Every software needs this functionality, it is not easy to do it right and performant and we want to avoid any unnecessary code duplication.

major focal points

  1. API implementation to access the key/value pairs namespace with a variety of Backends and Bindings
  2. Definition of a standard key/value pair hierarchy, namespaces and semantics
  3. Produce quality patches for popular softwares as, Samba, KDE's KConfig XT and Gnome's GConf

Sunday, January 04, 2009

AVG Antivirus Accidentally Kills Windows

Saw this on OSNews.Com. Users of AVG Anti-Virus beware:

Dutch, French, Italian, Portuguese, and Spanish users of the popular anti-virus software AVG have discovered a nasty surprise. AVG has mistakenly identified a core Windows system file, user32.dll, as a Trojan, and summarily deletes it, b0rking Windows. AVG has announced they're working on a fix.
Interestingly, I cannot find this on AVG's website, neither in the News or Updates section. So judge for yourself.

The Brains and Bones of my NAS

I've just found this article on AnalogZone featuring the custom ASIC (IT3107) of my Netgear ReadyNAS Duo, which contains a SPARC-based core along wth integrated NAS circuitry. Apparently the IT3107 supports 4 SATA controllers (argh, I should have gotten a 4-bay NAS instead, but the cost would be prohibitive at this stage).

Here is an excerpt from the article on some of its major features (I didn't know this before):

Infrant's basic concept is to integrate all the functions required to support a small RAID array with the electronics required to put the data on a 10/100/1000BaseT network, and to throw in a print server function for good measure. They've already rolled out a product to address the higher-priced SMB-level market which supports up to eight SATA drives. They're now introducing the ExpandaNAS IT3107, a consumer-grade device with half the SATA drives for the SoHo and consumer market. Depending on what works best for your needs, Infrant will happily sell you either the raw chip or a complete OEM-able board that only requires a case, power supply and disks. And power won't be too much of a problem since power consumption for the IT307 is only 5 W.

Powered by a 32-bit SPARC-based RISC core (with several extensions that we'll look at shortly) the chip supports RAID 0/1/5 operation for up to four SATA drives. Its network connection is a single Gbit Ethernet port. A PCI host interface and a pair of USB interfaces for supporting peripherals such as printers complete the I/O complement.

Rather than pass disc data through the CPU, its disc interface bypasses the PCI bus and uses DMA to shove blocks of data from the drives to the on-chip 64 bit DRAM controller. This leaves most of the SPARC's processing power available to manage the disks, handle the print serve tasks, and support its GbE connection at full rate. Infrant has also enhanced the chip's performance by beefing up the SPARC processor's instruction set. While its instruction set is still SPARC v8-compatible, the processor has had the way it executes several instructions optimized to keep critical segments in the fast lane. They also equipped the CPU with additional hardware logic including a hardware table walk-through for lookups, a lock-down cache, and a 3DES encryption core.

For Sale - Asus Pundit-R Barebone

I'm letting go of my Asus Pundit-R barebone of 3 years (see the specs on the right).

It is basically working, but intermittently does not POST (I found that taking out the cover helps), probably due to a loose SDRAM chip or slot.

Make me a reasonable offer (my reserved price is SGD$150), and I will include a ViewSonic 15" CRT monitor (needs 5mins to warm up), Western Digital Jumbo Buffer (8MB) 60GB and Pioneer DVD Rewritable into the bundle. Make me a good offer and I will throw in my Canon D646ex flatbed scanner.

Note, there is no bundled Windows OS. I can install and update Ubuntu for you if you like. I have been running the machine as my Linux workhorse.

Please leave a comment or email me privately at cohawk (at) yahoo (dot) com.