Wednesday, November 10, 2021

 Test

Thursday, January 24, 2019

Dynamic and Static Programming Language

Static and Dynamic Programming Language

According Wikipedia, there are thousands of programming languages and new ones are created every year. Below is the list of common used languages (I used most of them):

  • ALGOL60 (ALGOrithmic Language, 1960) [Application]
  • BASIC (Beginner's All-purpose Symbolic Instruction Code. 1964) - Philosophy emphasizes ease of use

  • Assembly language - Low-level programming language
  • C (1972) - low-level operations [Application, System]
  • C++ (1983)
  • C# (2000)
  • COBOL (COmmon Business-Oriented Language, 1959)
  • Java (1995)
  • JacaScript (1995)
  • LISP(LISt Processing, 1958)

  • Pascal (1970)
  • PERL (Practical Extraction and Reporting Language, 1987)
  • PHP (Personal Home Page, 1995) - Numeric computation and scientific computing.

  • PL/I (Programming Language One, 1964)
  • Prolog(1972)
  • Python (1991)
  • Tcl (Tool Command Language, 1988)
  • Fortran (Formula Translating System, 1957)




In a statically typed language, every variable name is bound both
  • to a type (at compile time, by means of a data declaration)
  • to an object.
The binding to an object is optional — if a name is not bound to an object, the name is said to be null.
Once a variable name has been bound to a type (that is, declared) it can be bound (via an assignment statement) only to objects of that type; it cannot ever be bound to an object of a different type. An attempt to bind the name to an object of the wrong type will raise a type exception.
In a dynamically typed language, every variable name is (unless it is null) bound only to an object.
Names are bound to objects at execution time by means of assignment statements, and it is possible to bind a name to objects of different types during the execution of the program.

Regular Expression Comparison - Python, C#, Java

Regular Expression Comparison - Python, C#, Java


Evens and Delegates in C#

A nice article describes the events and delegates in http://www.codeproject.com/Articles/4773/Events-and-Delegates-Simplified. Here I give a summary of using events and delegates in C#.


A delegate is a class, it's just a function pointer.


  • Every delegate has a signature, for example: Delegate int MyDelegate(string s, bool b);
  • Consider the following function: private int MyFunc1(string str, bool boo) { ... }
  • You can pass a function and register: var md = new MyDelegate(MyFunc1);
  • Then use the registered function: md("mystring", true);

An event is a message sent by an object to signal the occurrence of an action. 

  • The action could be caused by user interaction such as a button click, or it could be raised by some other program logic, such as changing a property’s value.


https://estore.canon.ca/en-CA/catalog/product-accessories/eos-digital-slr-camera-accessories/batteries-chargers-grips

Wednesday, July 27, 2016

Name :

Hello {{name}}

Tuesday, January 27, 2015

About Microsoft UI-Automation

UI Automation Client Side Provider

A provider extracts information from a specific control and hands that information to UI Automation. Providers can exist either on the server side or on the client side. In this article, we introduce a mix method, which is mainly implemented on client side but also a small piece of code is added on server side in order to provide more useful functions.

1. Define an Register Provider

public class UIAutomationClientSideProviders
{
    public static ClientSideProviderDescription[]  ClientSideProviderDescTable = 
    {
        new ClientSideProviderDescription(
            GridProvider.Create,      // Method that creates the provider object.
            "MFCGridCtrl")               // Class of window that will be served by the provider.
    };
}

ClientSettings.RegisterClientSideProviders(UIAutomationClientSideProviders.ClientSideProviderDescTable);

2. Implement the Provider

In this example, we create a provider for custom defined UI-component MFCGrifCtrl.

class GridProvider : IRawElementProviderSimple
                                IRawElementProviderFragment
                                IRawElementProviderFragmentRoot
{

    //  SendMessage communicates between client side provider and the program using MFCGridCtrl 
    [System.Runtime.InteropServices.DllImport("user32.dll")]
  public static extern int SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, IntPtr lParam);

    const int WM_USER = 0x0400;
    private IntPtr providerHwnd;
    public int SendMessage(IntPtr wParam, IntPtr lParam)
    {
        return SendMessage(providerHwnd, WM_USER, wParam, lParam);
    }

    // self-defined message code for communication with MFCGridCtrl  
    public const int GET_GRID_ROWS = 1;
    public const int GET_GRID_COLS = 2;

    public int rows = 0;
    public int cols = 0;
    public GridCellProvider[] cellArray = null;


    internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild, int idObject)
    {
        return Create(hwnd, idChild);
    }

    private static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
    {
        if (idChild != 0) return null;
        return new GridProvider(hwnd);
    }

    public GridProvider(IntPtr hwnd)
    {
        providerHwnd = hwnd;
        // get related information from MFCGrifCtrl
        rows = SendMessage((IntPtr)GET_GRID_ROWS, IntPtr.Zero);
        cols = SendMessage((IntPtr)GET_GRID_COLS, IntPtr.Zero);
        cellArray = new GridCellProvider[rows*cols];
    }

    // The followings are IRawElementProviderSimple methods (total 4)
    ProviderOptions IRawElementProviderSimple.ProviderOptions
    {
        get { return ProviderOptions.ClientSideProvider; }
    }
    IRawElementProviderSimple IRawElementProviderSimple.HostRawElementProvider
    {
       get { return null; }
    }
    object IRawElementProviderSimple.GetPropertyValue(int aid)
    {
        if (property == AutomationElementIdentifiers.HelpTextProperty)
        {
            return rows + "," + cols + " (rows,columns)";
        }
        return null;
     }
     object IRawElementProviderSimple.GetPatternProvider(int iid)
     {
         return null;
     }

     // The followings IRawElementProviderFragment methods (total 6)
     public Rect BoundingRectangle
     {
            get { return rect; }
     }
     public IRawElementProviderFragmentRoot FragmentRoot
     {
         get { return this; }
     }
     public IRawElementProviderSimple[] GetEmbeddedFragmentRoots()
     {
         return null;
     }
     public void SetFocus()
     {
         return;
     }
     public int[] GetRuntimeId()
     {
         return null;
     }

     public IRawElementProviderFragment Navigate(NavigateDirection direction)
     {
         switch (direction)
         {
              case NavigateDirection.FirstChild:
                   if (cellArray[0] == null) cellArray[0] = new GridCellProvider(this, 0, 0);
                   return (IRawElementProviderFragment)cellArray[0];
                   break;
         }
         return null;
    }

    // The followings are IRawElementProviderFragmenRoot methods (total 2)
    public IRawElementProviderFragment ElementProviderFromPoint(double x, double y)
    {
        return null;
    }
    public IRawElementProviderFragment GetFocus()
    {
        return null;
    }
}

MFCGridCtrl Grid Cell Provider

class GridCellProvider : IRawElementProviderSimple, 
                                       IRawElementProviderFragment, 
                                       IInvokeProvider
{
    private GridProvider parent;
    private int rowId;
    private int colId;

    public GridCellProvider(GridProvider parent, int row, int col)
    {
         columnId = col;
         rowId = row;
         this.parent = parent;
     }


    // IRawElementProviderSimple methods (total 4)
    ProviderOptions IRawElementProviderSimple.ProviderOptions
    {
        get { return ProviderOptions.ClientSideProvider; }
    }
    IRawElementProviderSimple IRawElementProviderSimple.HostRawElementProvider
    {
        get { return null; }
    }
    object IRawElementProviderSimple.GetPropertyValue(int aid)
    {
        var property = AutomationProperty.LookupById(aid);
        if (property == AutomationElementIdentifiers.ClassNameProperty)
        {
            return "Cell" + rowId + "." + columnId;
        }
        else if (property == AutomationElementIdentifiers.AutomationIdProperty)
        {
            return "#" + rowId + "." + columnId;
        }
        else if (property == AutomationElementIdentifiers.NameProperty)
        {
            return "...";
        }
        else if (property == AutomationElementIdentifiers.HelpTextProperty)
        {
            return  "...";
        }
        return null;
    }
    object IRawElementProviderSimple.GetPatternProvider(int iid)
    {
        if (iid == InvokePatternIdentifiers.Pattern.Id)
        {
            // Return an object that implements IInvokeProvider.
            return this;
        }
        else
        {
            return null;
        }
    }

    // IRawElementProviderFragment methods
    public Rect BoundingRectangle
    {
        get { return rect; }
    }
    public IRawElementProviderFragmentRoot FragmentRoot
    {
        get { return parent; }
    }
    public IRawElementProviderSimple[] GetEmbeddedFragmentRoots()
    {
        return null;
    }
    public void SetFocus()
    {
        return;
    }
    public int[] GetRuntimeId()
    {
     return new int[] { AutomationInteropProvider.AppendRuntimeId, (rowId << 16) + columnId };
    }
    public IRawElementProviderFragment Navigate(NavigateDirection direction)
    {
        switch (direction)
        {
            case NavigateDirection.Parent:
                return parent;
            case NavigateDirection.NextSibling:
           if (rowId + 1 < parent.rows || rowId + 1 == parent.rows && columnId + 1 < parent.cols)
                {
                    int next = rowId * parent.cols + columnId + 1;
                    if (parent.cellArray[next] == null)
                        parent.cellArray[next] = new GridCellProvider(parent, next / parent.cols, next % parent.cols);
                    return parent.cellArray[next];
                }
                break;
            case NavigateDirection.PreviousSibling:
                break;
            }
            return null;
        }

        public void Invoke()
        {
             ....
        }
    }

}


3. Modify the Class in Source Code

GridCtrl.h


private: std::string cellText;                  // SLX@Dec03'12 (1 of 2)

       afx_msg LRESULT OnUserMsg(WPARAM wParam, LPARAM lParam);             // SLX@Dec03'14 (2 of 2)


GridCtrl.cpp
#include "GridCellCheck.h"                         // SLX@Dec04'12      (1 of 3)


ON_MESSAGE(WM_USER,OnUserMsg)                      // SLX@Dec03'14 (2 of 3)

// SLX@Dec03'14 (3 of 3) - begin
LRESULT CGridCtrl::OnUserMsg(WPARAM wParam, LPARAM lParam)
{
       if (wParam==0)
       {
              if (lParamreturn (int)cellText[lParam];
                     return 0;
       }

       if (wParam==1) return GetRowCount();
       if (wParam==2) return GetColumnCount();

       int row = (lParam>>16);
       int col = (lParam&0xffff);
       CGridCellBase * cell = GetCell(row,col);

       switch (wParam)
       {
              case 3:                    // Form the cell text and return its length
                     if (cell!=NULL) cellText = cell->GetText();
                     else cellText="";
                     return cellText.length();
              case 4:                    // Is CGridCellCheck ?
                     if (cell==NULL) return -1;
                     if (dynamic_cast(cell) !=0) return 1;
                     return 0;
              case 10:             // Cell left
              case 11:             // Cell top
                     {
                           POINT p;
                           if (!GetCellOrigin(row,col, &p)) return -1;
                             CRect rect;
                             ClientToScreen(rect);
                           if (wParam==10) return p.x+rect.left;
                           else return p.y+rect.top;
                     }
              case 12:             // Cell width
                     return GetColumnWidth(col);
              case 13:             // Cell height
                     return GetRowHeight(row);

              case 40:             // IsCheck ?
              case 41:             // Check
              case 42:             // Uncheck
                     if (cell==NULL) return -1;
                     if (dynamic_cast(cell) !=0)
                     {
                           if (wParam==40) return ((CGridCellCheck*)cell)->GetCheck();
                           if (wParam==41) return ((CGridCellCheck*)cell)->SetCheck(1);
                           if (wParam==42) return ((CGridCellCheck*)cell)->SetCheck(0);
                     }
                     return -1;
       }
    return 0;
}
// SLX@Dec03'14 (3 of 3) - end


Tuesday, September 4, 2012

Test html console.log


console.log("Test console.log");

Thursday, April 19, 2012

Red/Leaf Lily Beetle



Reference [Scarlet lily beetle] in Wikipedia

Watch http://www.youtube.com/watch?v=TZRyj44AjEY

From [http://www.veseys.com/ca/en/learn/reference/lilybeetleinfo]
Origin:
The red lily leaf beetle (Lilioceris lilii) is an insect native to Europe and Asia which rapidly spread through New England from Eastern Massachusetts and which has been also been found in Northern New York State. The original infestation in New England was detected in 1992 in Cambridge, Massachusetts, although the beetle has been active in the Montreal, Canada, area since 1945.
Damage:
If uncontrolled, the beetle will completely defoliate and ultimately kill all true lilies (Lilium species, such as Asiatic, Oriental, Easter, Tiger and Turk’s Cap lilies). It will also feed on Fritillaria species, and many other plants, although the primary targets are Lilium and Fritillaria species.
Description:
The adult beetle is bright scarlet red, with black legs, head, antennae and undersurface. It is 1/4" to 3/8" long and is a strong flyer. The beetle reportedly will squeak if squeezed gently (however, few gardeners are willing to be gentle to this beetle). The adult lays reddish-orange eggs which hatch into particularly unpleasant larvae, which look like 3/8" long slugs; colored orange, brown, yellow or green with black heads. The larvae cover themselves with their own excrement (known as a fecal shield) which apparently repels predators, including gardeners who are generally very reluctant to handle the larvae. The larvae eventually become fluorescent orange pupae.
Life Cycle:
The adult beetle overwinters in the soil or plant debris and emerges in early spring looking for food and a mate. After mating, the female lays eggs in lines on the underside of Lilium or Fritillaria leaves. Some damage is done by the adults at this time, but the major damage comes when the eggs hatch into larvae in 7-10 days. The larvae voraciously consume all leaves within reach and may then start on flower buds. This continues for 2 to 3 weeks, when the larvae then drop into the soil and begin to pupate. In another 2 to 3 weeks the adult beetles emerge to start eating again. This process occurs from early spring to mid-summer. Reportedly the beetles won’t mate and lay eggs until the next spring.
If you suspect the beetles may be lurking around your lilies but you don't see any, carefully dig in the top half inch of the soil - no deeper! They hide just under the surface, so be ready to get them when they pop out.

Biological Control:
There are no known natural predators in this country, although the beetle is well under control in Europe, where at least six parasitoids attack it. Researchers at the University of Rhode Island are actively engaged in releasing parasitic wasps in this country and seem to be confident that biological control can eventually be established here as well.
Active Control:
First of all, if you’re in an infested area, avoid sending any lilies or other plants to anyone else, and carefully inspect any plants you receive.
Hand-picking should be the first level of control if possible. Constant vigilance and quick removal and disposal of beetles, eggs and larvae can control an infestation on a small number of plants. Make sure the critters are actually dead! If you squash them, don't leave the squashee in the garden. Some gardeners drop them into a can of water with vegetable oil on the top. Please note: The adults are easily spooked when you try to pick them by hand, and if you miss them, they tend to drop to the ground where THEY LAND UPSIDE DOWN, and since their tummies are black, they effectively vanish. A suggestion is to place a light-colored cloth under the plant before you hand-pick in order to be able to see them if they fall.
Neem: If hand-picking isn’t feasible, then treatment with Neem is the next choice. Neem will repel beetles and kill young larvae, but must be applied every 5 to 7 days after the eggs hatch.
Merit (imidacloprid) is a systemic insecticide which may work if applied to the soil in early spring. Many New England gardeners are also reporting good results from the use of products containing imidacloprid when applied later in the season. Bayer manufactures several products containing systemic insecticides, both in spray and in granular form.
Other chemicals of relatively low toxicity include the following:
10% household ammonia applied to the newly emerging lily sprouts and surrounding soil (reported by northerner on of Ontario, Canada).
Pyrethroid insecticides (Permethrin is one) kill adult beetles (reported by the UMass Extension).
Spinosad insecticides kill larvae (reported by the UMass Extension).

Sunday, October 16, 2011

EF24-105/4L IS USM price today

Futureshop $1499.99
henrys.com $1499.99
cameracanada.com $1298.97 On Sale

EOS 5D Mark II w/ 24-105mmL IS $2799.99 On Sale


cameracanada.com
EOS 60D Digital SLR Camera with 15-85
Our Price: $1,799.00
Sale Price: $1,489.97

EOS 60D Digital SLR Camera Body
Our Price: $1,149.00
Sale Price: $879.97

downtowncamera.com
Canon EOS 60D
$1,099.00 Sale: $884.00

Canon EOS 60D + Canon EF-S 15-85mm IS Lens.
$1,759.00 Sale $1,480.00

Sunday, October 9, 2011

二十八星宿 与 星座



东方苍龙
星宿 对应星座
角———室女
亢———室女
氐———天秤
房———天蝎
心———天蝎
尾———天蝎
箕———人马



北方玄武
星宿 对应星座
斗———人马
牛———摩羯
女———宝瓶
虚———宝瓶/小马
危———飞马/宝瓶
室———飞马
壁———仙女/飞马



西方白虎

西宫白虎
星宿 对应星座
奎———仙女/双鱼
娄———白羊
胃———白羊
昴———金牛
毕———金牛
觜———猎户
参———猎户 南方朱雀

南宫朱雀
星宿 对应星座
井———双子
鬼———巨蟹
柳———长蛇
星———长蛇
张———长蛇
翼———巨爵
轸———乌鸦


Sunday, February 27, 2011

Satellite info screen from a Garmin Nuvi

[From http://www.gpsreview.net/satellite-info-screen/]



All of the vertical bars correspond to a satellite that the GPS is listening to. The numbers at the bottom refer to a specific satellite number. Here the GPS is listening to 2, 4, 5, 10, 12, 13, 17, 20, 23, and 30. Note that most of the bars are blue. On this GPS that means that the GPS is listening to that satellite and the information being received is good enough to be able to use in the calculation of your current position.

Sometimes you might see a “hollow” bar or a slot for a bar but no bar itself. This is the case with satellite #20. Data from that satellite is not being used to calculate your position. Taller bars indicate better data coming from that satellite. Number 30, 23, and 5 in this case are providing the best reception.

On the left side of the picture is a “map” of the satellites. Think of this as looking down at Earth (the big circle) with North at the top, and your current location centered in the circle. Now thinking of yourself centered in the middl, the outer circle represents the horizon, and the inner circle is looking up at an angle of about 45°.

Satellite #2 is to our West, a little bit North, and fairly high in the sky. (More than 45°.) Similarly, satellite number 4 is to the Northeast and also fairly high in the sky. Number 12 is just about 45° (half way from the horizon to vertical) and is to our Northwest. Number 20, which we are getting little to no reception from, is the furthest away, to the Northeast, and is just about on the horizon.

You can also see the current moon position in this view, and the current location of the sun which is about to set to the Southwest. There is also a little red dot which indicates our last calculated direction of travel.

Monday, January 3, 2011

Saturday, January 1, 2011

The Top 7 Best Linux Distributions for You


[from: http://www.linux.com/learn/docs/ldp/282996-choosing-the-best-linux-distributions-for-you]


Best Linux Desktop Distribution - For early 2010, that distro has to be Canonical's Ubuntu (http://www.ubuntu.com/).


Best Linux Laptop Distribution - the best laptop distribution is openSUSE

Best Linux Enterprise Desktop - SUSE Linux Enterprise Desktop (SLED)

Best Linux Enterprise Server - comes down to two main contenders: Red Hat Enterprise Linux (RHEL) and SUSE Linux Enterprise Server (SLES).

Best Linux LiveCD - In this class of distribution, KNOPPIX is hands-down the most complete and useful distro. Loaded on a CD or USB storage device, KNOPPIX will let you recover from nearly any rare Linux system crash as well as the much-less-rare Windows breakdowns.


Best Linux Security-Enhanced Distribution - BackTrack Linux

Best Linux Multimedia Distribution - Ubuntu Studio

Tuesday, December 28, 2010

Canon EOS Camera








EuropeanUSJapanAnnouncedReleasedmegapixeldesc.
Canon EOS 300DRebelKissAug 20, 2003 6.37 focus pt
Canon EOS 350D Rebel XTKiss NFeb 17, 2005 8.07 focus pt, 475g(body)
Canon EOS 400DRebel XTiKiss XAug 24, 200610.110 AF pt, 510(body)
Canon EOS 450DRebel XSiKiss X2Jan 23, 2008Mar/Apr12.29 AF pt, 475g(body),ISO100-1600
Canon EOS 500DRebel T1iKiss X3Mar 25, 2009May15.19 Af pt,480g(w/o battery),ISO100-3200
Canon EOS 550DRebel T2iKiss X4Feb 08, 2010Feb/Mar18.09 AF pt, 530g(w/ battery), ISO100-6400

Saturday, December 12, 2009

address

万成摄影器材
九龙旺角通菜街 106 号地下 2396 2996

永成摄影器材
九龙旺角西洋菜街 57 号地下 2396 6886
2396 6961

Tuesday, December 8, 2009

Fraunhofer Lines


英国的化学家威廉·海德·沃拉斯顿(William Hyde Wollaston, 1766–1828)是在1802年第一位注意到有一定数量的黑暗特征谱线出现在太阳光谱中。
夫朗和斐(Joseph von Fraunhofer, Geman physicist 1787–1826)独立的再度发现这些谱线,并且开始系统性的研究与测量这些谱线。最后,他绘出了570条的谱线,并且以字母A到K标示出主要的特征谱线,较弱的则以其他的字母标示。
后来基尔霍夫(Gustav Kirchoff,Geman physicist 1824–1887) 和本生(Robert Bunsen, Geman chemist 1811–1899)确认了每一条谱线所对应...的化学元素,并推论在太阳光谱中的暗线是由于......造成的。
---
双D线 (D1,D1) 为钠(Na)的光谱 (589.592nm,588.995nm)











Wednesday, November 25, 2009

Photo Sharing Website Reviews













http://www.starreviews.com/photo-sharing-reviews.aspx [2009-11-29]

Wednesday, November 18, 2009

Camera Focus Length

Canon A700 5.8-34.8mm (x6 eq. 35-210mm) F2.8-4.8, 6x zoom
Canon PowerShot S3 IS 6–72mm (x6 eq. 36-432mm) F2.7-3.5, 12x zoom
Sony W55 6.3-18.9mm (x6 eq. 38-114mm) f2.8-5.2, 3x zoom
Sony F717 9.7-48.5mm (x4 eq. 38-190mm) F2-2.4, 5x zoom
Canon EF-S 18-55mm (x1.6 29-88mm) F/3.5-5.6, (3.0x zoom)
Canon EF 28-105mm (x1.6 45-168mm) F/3.5-4.5 (3.7x zoom)
Canon EF 70-200mm (x1.6 112-320mm) F/4.0L (2.9x zoom)
Canon EF-S 55-200mm (x1.6 88-400mm) F/4.0-5.6 (3.6x zoom)

Followers