Wednesday, August 24, 2011

HP Touch Pad Price Slash, may rebirth webOS

All HP Touch Pad had been sold out in 48 hours after HP launches it price slash, this is a surprise of the market reaction, I believe the webOS would be reborn along the increment of users.

The popularity of Pad depends on operation system + number of applications
Number of applications  is depends on number of developers in the world who do development on the OS
Number of developers depends on the demand of device & the profit they can get

It is a very satisfactory tactics to slash the price to dominate the market to bring more users, then more programmers will join & more application there will be.

webOS may rebirth

Saturday, August 20, 2011

Let your computer say hello

CreateObject("SAPI.SpVoice").Speak "Hello"

Output into a .wav file

set x = createobject("SAPI.SpVoice")set ofs = createobject("SAPI.SpFileStream")ofs.Open "msg.wav", 3, vbFalseset x.AudioOutputStream = ofsx.Speak "Try me"

Output what you input

Dim message, sapimessage=InputBox(“Enter the text you want spoken”,”Speak This”)Set sapi=CreateObject(“sapi.spvoice”)sapi.Speak message

Saturday, August 13, 2011

Http Download with Python

Simple download

import urlliburllib.urlretrieve ("", "mp3.mp3")

Download with progress

 import urllib2url = ""file_name = url.split('/')[-1]u = urllib2.urlopen(url)f = open(file_name, 'wb')meta = = int(meta.getheaders("Content-Length")[0])print "Downloading: %s Bytes: %s" % (file_name, file_size)file_size_dl = 0block_sz = 8192while True:    buffer =    if not buffer:        break    file_size_dl += len(buffer)    f.write(buffer)    status = r"%10d  [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)    status = status + chr(8)*(len(status)+1)    print status,f.close()

Friday, August 12, 2011

Best web browser for old computer

If you have a old computer like mine (1.6GHZ, 512 Memory & 30GB) & looking for a decent web browser. I strongly recommend Opera 11, this version is much faster than any modern browser, firefox 5, ie 9, google chrome even safari.

This was really surprised me yet after test all those browsers on my computer, Opera is the fastest web browser that I have tested.

Thursday, August 11, 2011

Recursive syntax check with php command line

find . -name \*.php -exec php -l “{}” \;

.Net Assembly Redirection

Sometimes, we need redirect an assembly to a different version, we can do it like this:

<?xml version="1.0" encoding="utf-8" ?><configuration>    <runtime>        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">            <probing privatePath="libs"/>            <dependentAssembly>                <assemblyIdentity name="MathLibrary"                    publicKeyToken="8210BDCE54DAB3C2"/>                <bindingRedirect oldVersion=""                    newVersion=""/>            </dependentAssembly>        </assemblyBinding>    </runtime></configuration>


In element “probing, “privatePath” is additional seraching path for assemblies.

In element “assemblyIdentity“, “name” is the assmebly you want to redirect, “publicKeyToken” is its public key. So the assembly must be strong-named to make a redirection.

After set the assembly, you can make your redirection. In element “bindingRedirect“, use “oldVersion” & “newVersion” to redirect it.


Friday, August 5, 2011

Connect to mysql database using python with MySQLdb cursor

import sysimport MySQLdbimport MySQLdb.cursorsconn = MySQLdb.Connect(    host='localhost', user='vroom',    passwd='vroom', db='vroom',compress=1,    cursorclass=MySQLdb.cursors.DictCursor)cursor = conn.cursor()cursor.execute("SELECT * FROM posts")rows = cursor.fetchall()cursor.close()conn.close()for row in rows:    print row['title'], row['create_date']

Tuesday, August 2, 2011

Execute PHP script in background mode in Windows

Create a .vbs file

Dim objshellSET objshell = WScript.CreateObject ("WScript.Shell") "c:\php5\php.exe YourPHP.php", 0SET objshell=Nothing

And execute this vbs file in windows schedule task manager