Lane Cove National Park

After three weeks continuous raining, finally it’s a sunny weekend. We can step outdoors for a small winter trip to enjoy the long waiting sun shine.

We are begin with Riverside walking track for a short bush walk.

Few weeks raining makes Lane Cove river overflow.

Ducks like swimming.

Zipping the download files on the fly ASP.Net (real-time zip and download file from server)

I am currently working on an ASP.Net web project, which allows client to download a well structured submission package. Due to security reason, web server can not create folder and write file on client side. Web server can generate a well structured zipped file and push to the client.

There could be two ways to achieve that;

Fist way:

  1. Create folders and copy files into each folder
  2. Use 3rd party tool, eg winrar, 7zip to zip the whole folder to one zipped file
  3. Send back download web address, and let client download the zipped file

If the zipped file is small and web server is powerful enough, client won’t feel any delay. However if the file is big, client side will get no any response until zip file is ready. We can put similar message, eg “Please wait… ”. But client side still don’t know how long would take. If zip file is not ready within time out period, server will get reset. This is a really awful user experience.

Second way:

  1. Create folder and zip the files on the fly (on web server’s memory)
  2. Send back zipped stream to client through Response
  3. Client download  zipping file one by one

Client can clearly feel the progress of downloading.

Here is the code for 2nd solution:

//prepare response header
Response.Clear();
//set Response Content Type
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition", "attachment; filename=Download.zip");
ZipOutputStream zipOutput = new ZipOutputStream(Response.OutputStream);
try
{
            zipOutput.IsStreamOwner = false;
            //set compress level
            zipOutput.SetLevel(9);

            ArrayList fileList = functions.GetFileList();
            foreach (string fileName in fileList)
            {
                string folderName = "folder1" + @"";

                zipEntry = new ZipEntry(folderName + fileName);
                zipOutput.PutNextEntry(zipEntry);
                            
                byte[] file = functions.GetFile(fileName);
                //zip file
                zipOutput.Write(file, 0, file.Length);
                 //send to client for downloading
                Response.Flush();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
        finally
        {
            zipOutput.Finish();
            zipOutput.Close();
            Response.End();
        }

CeBIT Australia at Sydney Darling Harbour

CeBIT is the world’s largest and most international computer expo, and is a traditional computer show held every year. As it grows quickly, CeBIT Australia becomes bigger and bigger. Lots of IT equipment suppliers join this trade show, eg DELL, Samsung, Hitachi, D-Link, etc. This year, CeBIT 2011 starts yesterday and is held for 3 days.

Samsung huge LCD display and show stand

D-Link and its Ethernet router

NEC and DELL

Motorola

Pronto software

CSRIO is displaying their 3D detect system

Waterproof LCD monitor

Other stands

 

 

The only disappointing is  no world-wide largest IT manufacture, eg IBM, Intel, NVidia. I didn’t see many emerging technologies.

Woolworth Everyday Reward promotion activation link

If  you have registered Woolworth Everyday Rewards Card, sometimes it will send you their weekly promotion email. If you active the offer, it will credit you either fuel saving offer or Qantas bonus points when your shopping spend is over certain amount.

My friend is always receiving such email but I didn’t. Are they randomly picking up some valued customer or targeting someone? I don’t know, but I just want to be treated fairly same as others. Let’s make my own promotion offer.

Here is a example of activation link in their recent promotion email:

http://everydaypromos.com.au/wowactivation/23625.do?email=yourname@hotmail.com&everyDayRewardsNo=9344435941223&formForward=LOAD

  • The first 23625 is event ID, and it increment for each promotion event by one.
  • yourname@hotmail.com is your registered email address
  • 9344435941223 is your Everyday Reward Card number

If you can replace the above parameters with your own one, and copy&paste into your web browser, you also can enjoy Woolworth’s promotion.

I also wrote a small tool and you can download here. Please ensure .Net Framework is installed on your computer.

Unlock Huawei E585 WCDMA 3G modem

My colleague brought two PocketWifi 3G Modems to my desk and asked me to see if possible to unlock them. I found out that they are actually E585 WCDMA 3G Modem OEM by Huawei. It will normally cost you $25 each to unlock if you ring up the customer service.

After few hours attempting, I finally found a way to unlock them for free without any cost. If you like DIY, here are the outlines to share.

Preparation: a USB Cable, locked SIM card, and internet access

  • Connect 3G Modem to PC with USB Cable and install windows modem driver (ensure not WIFI connection)
  • Download RevSkills from http://psas.revskills.de/?q=node/6 and install on your computer
  • Run RevSkill from your desktop and select “QC+AT-Cmd”

  • Select correct 3G modem COM port from the list and Baud Rate

  • Go to DIAG tab, and click “Send”, if success, you will see your 3G Modem Version information comes out

  • Select “Save NVItems to file” and click “Lets go”. It will pop a window to ask you where to save the NVItems

  • Use Notepad to open the saved file and search “PST”. The number behind “PST” is the unlock code. After you enter this unlock code, your device is free to use any WCDMA 3G network.

 

 

A funny joke application makes your window dance

These days I am so busy with work, and haven’t got time to write anything.

This is a funny joke application I wrote long time back. It will make your front window dance. If you press any key, this application will exit.

You can download here
This is the code, in case if you want to make your own.

#include "stdafx.h"
#include "math.h"
#include "windows.h"
#include "time.h"
#include "conio.h"

int _tmain(int argc, _TCHAR* argv[])
{
	RECT rect;
	int offset;
	while(!kbhit())
	{
		HWND hWnd = GetForegroundWindow();
		GetWindowRect(hWnd,&rect);
		offset = sin((float)rand())*10;
		rect.left += offset;
		rect.bottom += offset;
		rect.right += offset;
		rect.top += offset;
		MoveWindow(hWnd,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,true);
		Sleep(20);
	}
	return 0;
}

Install APK into new HTC smart phone

Today, my colleague asked me how to install downloaded *.apk into his new HTC phone. As HTC doesn’t come with file manager, you have to enable USB debug mode. Here are the steps to install

  • Enable HTC USB Debug mode

  • You will see the application is in your Android smart phone

Day trip – the Circular Quay

After few rainy weeks, finally we have a sunny day today. Like a imprisoned bird, we can go out and enjoy the sunshine.  The Sydney ferry took us to the Circular Quay. We saw some lots of people were dancing there and they told us today is May Day. May Day is England traditional day of festivities throughout the centuries. They were dancing to celebrate harvest festival and waked up the Sun.

Then we followed Pitt street and saw this stunning red Ferrari parked at curbside.

Web (HTTP) based remote PC monitor

VNC and Microsoft RemoteDesktop both provide remote control software which lets you see and interact with desktop applications across any network, however either software requires to install a client application on control side.

Here I have developed a small tool, WebPCMonitor. It will allow you to see and interact with your own PC desktop through HTTP protocol. It means that on client side, you don’t need install any 3rd party tool but a internet browser. Simply type your remote PC’s name or IP address, and you will see your PC’s desktop. You even can remote control your PC through PDA or SmartPhone (eg iPhone, iPad, Android, etc) as long as you have internet access. This tool works with Win98, Win2000, WinXP, and Win7.

You can download here.

Run the application, and open your browser and type “http://localhost:8000“. If you know your PC’s IP address, you can remote access through PDA or SmartPhone by typing “http://address:8000

Create customized .Net Component – CircularListBox in C#

This post originated from my previous question. In previous question, I was asking how to create a circular list box control. A list box, if scroll down to the last element and continue scroll down, it will appear first element; if scroll up to the first element and keep scroll up, it will appear last element. It looks like IPhone alarm setting function. Here is my solution.

public class CircularListBox : System.Windows.Forms.ListBox
{
    private System.ComponentModel.Container components = null;
    const int WM_VSCROLL = 0x0115;
    const int WM_KEYDOWN = 0x0100;

    const int SB_LINEUP = 0x0000;
    const int SB_LINEDOWN = 0x0001;

    const int VK_DOWN = 0x0028;
    const int VK_UP = 0x0026;
    const int VK_NEXT = 0x0022;
    const int VK_PRIOR = 0x0021;

    public CircularListBox()
    {
        // This call is required by the Windows.Forms Form Designer.
        InitializeComponent();

        // TODO: Add any initialization after the InitializeComponent call

    }

    ///  
    /// Clean up any resources being used.
    /// 
    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            if (components != null)
            {
                components.Dispose();
            }
        }
        base.Dispose(disposing);
    }

    #region Component Designer generated code
    ///  
    /// Required method for Designer support - do not modify 
    /// the contents of this method with the code editor.
    /// 
    private void InitializeComponent()
    {
        components = new System.ComponentModel.Container();
    }
    #endregion
    protected int offset = 0;

    public new int TopIndex
    {
        get { return (this.Items.Count + offset + base.TopIndex) % this.Items.Count; }
        set
        {
            if (value > this.Items.Count - 1)
                return;
            Message m = new Message();
            m.Msg = WM_KEYDOWN;
            m.WParam = (System.IntPtr)VK_DOWN;
            while (value != this.TopIndex)
                WndProc(ref m);
        }
    }

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == WM_VSCROLL || m.Msg == WM_KEYDOWN)
        {
            if (this.SelectedIndex == -1)
                this.SelectedIndex = 0;

            switch ((int)m.WParam)
            {
                case VK_PRIOR:
                case VK_UP:
                case SB_LINEUP:
                    if (this.SelectedIndex == 0)
                    {
                        offset = (this.Items.Count + offset - 1) % this.Items.Count;
                        this.Items.Insert(0, this.Items[this.Items.Count - 1]);
                        this.Items.RemoveAt(this.Items.Count - 1);
                        this.SelectedIndex = 0;
                    }
                    else
                    {
                        this.SelectedIndex--;
                    }
                    break;
                case VK_DOWN:
                case SB_LINEDOWN:
                case VK_NEXT:
                    if (this.SelectedIndex == this.Items.Count - 1)
                    {
                        offset = ++offset % this.Items.Count;
                        this.Items.Add(this.Items[0]);
                        this.Items.RemoveAt(0);
                        this.SelectedIndex = this.Items.Count - 1;
                    }
                    else
                    {
                        this.SelectedIndex++;
                    }
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }
        else
            base.WndProc(ref m);
    }
}