Archive for August, 2009



上網, 睇戲, 整下野咁…


要訓多D先, 又要開工喇…

No Comments

Duplicating images using the Bitmap and BitmapData classes


<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:Application xmlns:mx=""

            import mx.collections.ArrayCollection;

            private var arrColl:ArrayCollection = new ArrayCollection();

            private function dupeImage(source:Image):void {
                var data:BitmapData = Bitmap(source.content).bitmapData;
                var bitmap:Bitmap = new Bitmap(data);

                arrColl.addItem({image:bitmap, label:"item #" + (arrColl.length + 1)});

        <mx:Panel title="Source image">
            <mx:HBox verticalAlign="middle" horizontalAlign="center" width="100%" height="100%">
                <mx:Image id="img1" source="assets/logo.png" />

                <mx:Button label="Copy image" click="dupeImage(img1)" />

        <mx:TileList id="tileList" dataProvider="{arrColl}" width="300" height="200" columnCount="4" verticalScrollPolicy="on">
                        <mx:Image source="{data.image}" />
                        <mx:Label text="{data.label}" />


No Comments

Crop image in Flex

Crop image in Flex using BitmapData


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=""
    layout="absolute" initialize="initNew()"
    width="320" height="370">
            import mx.controls.Image;

            private const image_path:String = "fxr.png";
            private var loader:Loader;
            private var request:URLRequest;  

            private var loadBD:BitmapData;
            private var cropBD:BitmapData;  

            private var startPoint:Point;
            private var posPoint:Point;
            private var square: int;
            private var mtrx: Matrix;

            private function initNew():void
                loader=new Loader();
                request=new URLRequest(image_path);

            private function onComplete(event:Event):void {
                loadBD = Bitmap(event.currentTarget.content).bitmapData;

      , 0,
                    loadBD.width, loadBD.height);

                //make initial image


             private function drawImage():void
                 //crop square
                startPoint = new Point(xSelector.value,    ySelector.value);
                square = sizeSelector.value;

                //resize image and show it

             private function cropImage(startPoint:Point, squareSize:int):void
                 // Make a new bitmap data using square size
                cropBD = new BitmapData(squareSize, squareSize, true, 0x00000000);
                // Position where will be dispayed in the new object, in our case (0,0)
                posPoint = new Point(0,0);
                // copy pixels from loaded bitmap data to our new object
                    new Rectangle(startPoint.x, startPoint.y, squareSize, squareSize),

                //draw crop area selected
      , 0xFFFFFF,0.5);
      , 0, cropBD.width, cropBD.height);


             private function resizeImage():void
                // make scale matrix
                mtrx = new Matrix();

                // Fill in image
      , 0, imageView.width, imageView.height);


    <mx:Canvas id="imageView"   x="210" y="10" width="100" height="100" />
    <mx:Canvas id="imageHolder" x="10" y="120" width="300" height="240" />
    <mx:Canvas id="imageCrop"   x="0" y="0" width="0" height="0" /> 

    <mx:Label x="10" y="15" width="60" text="X position"/>
    <mx:HSlider id="xSelector" x="80" y="10" width="120"
            minimum="0" maximum="290" snapInterval="10" enabled="true"
            value="170" change="drawImage()" />

    <mx:Label x="10" y="55" width="60" text="Y position"/>
    <mx:HSlider id="ySelector" x="80" y="50" width="120"
            minimum="0" maximum="230" snapInterval="10" enabled="true"
            value="20" change="drawImage()" />

    <mx:Label x="10" y="95" width="60" text="Area size"/>
    <mx:HSlider id="sizeSelector" x="80" y="90" width="120"
            minimum="10" maximum="240" snapInterval="10" enabled="true"
            value="100" change="drawImage()" />


No Comments

How to set a static IP in Ubuntu from the shell

Edit /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
        script grep
        map eth0

# The primary network interface
auto eth0
iface eth0 inet static

No Comments

Ubuntu VNC Config (/home/user/.vnc/xstartup)


# Uncomment the following two lines for normal desktop:
#exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &

gnome-session &

No Comments

Remove workflow history which is 60 days before

To remove the history which is 60 days before.

But, pleas kindly notice this potential issue is if Workflow history is filled with huge data, Workflow Auto Clean up job may not be able to clean it. This is because of the Workflow Auto Clean up job consumes huge resource of SQL server to delete the huge data. Under this situation, you can back up the list and then delete the lists using the following steps:

1. Get the list of workflow history list and task list associated with list libraries.

Select id, name, listid, tasklistid, historylistid, tasklisttitle, historylisttitle, autocleanupdays
from workflowassociation

2. Run the below query with either tasklisttitle or historylisttitle.

select tp_ID, tp_title from dbo.alllists
where tp_title=’

3. Get tp_ID from above query and replace with below queries, it will give you the list of items and number items to delete.

select top 1 tp_Dirname from dbo.alluserdata where tp_listid=’< tp_ID >‘
select count (*) from dbo.alluserdata where tp_listid=’< tp_ID >‘
Select * from dbo.alluserdata where tp_listid = ‘< tp_ID >‘

To Clean data browse to the list http://servername/, delete all the entries, make sure it is been deleted from recycle bin also. It will reduce the items in AllUserData and improve the Workflow Auto Cleanup process performance. We can the following STSADM command to delete list items

STSADM -o forcedeletesite -url http://server/lists/

No Comments