2009-12-27

blog through mail

Test send blog content through mail.

winter in ShenYang.

?ui=2&view=att&th=125cf5daa63d2783&attid=0.1&disp=attd&realattid=ii_125cf5daa63d2783&zw

Best Regards,
Hunmr (王洪敏)

2009-09-20

推荐给用G1的朋友

将工作时的日历项自动推送到G1.

Option Explicit

Private WithEvents oCalendarItems As Outlook.Items
Private WithEvents oSentItems As Outlook.Items

Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")

'- hook the event to the Calendar folder:
Set oCalendarItems = Session.GetDefaultFolder(olFolderCalendar).Items
'- hook the event to the Sent folder:
Set oSentItems = Session.GetDefaultFolder(olFolderSentMail).Items

Set objNS = Nothing
End Sub

Private Sub oCalendarItems_ItemAdd(ByVal Item As Object)
Dim myolApp As Outlook.Application
Dim oForward As MailItem, strForwardTo As String
Dim newReq As AppointmentItem


'Make sure item is NOT a recurring appointment or provisional
If Item.RecurrenceState = olApptNotRecurring Then
If Item.Subject Like "*provisional*" Or Item.Subject Like "*Provisional*" Or Item.Subject Like "Provisional*" Then
'Do Nothing
Else
'Ensure that the item is an appointment
If TypeName(Item) = "AppointmentItem" Then

Set myolApp = CreateObject("Outlook.Application")
Set newReq = myolApp.CreateItem(olAppointmentItem)


With newReq
.Subject = Item.Subject
.Start = Item.Start
.End = Item.End
.Location = Item.Location
.Body = Item.Body

' make it a meeting request
.MeetingStatus = olMeeting
.RequiredAttendees = "xxxxxxx@gmail.com"
.Send
End With

Set myolApp = Nothing
Set newReq = Nothing
End If
End If

End If
End Sub


' disassociate global objects declared WithEvents
Private Sub Application_Quit()
Set oCalendarItems = Nothing
Set oSentItems = Nothing
End Sub

Failed to load data access DLL, 0x80004005

前一段时间在x86机器上分析一个64位机上取的dump时,遇到以下情况:

0:000> .load sos
0:000> !clrstack
Failed to load data access DLL, 0x80004005
Verify that 1) you have a recent build of the debugger (6.2.14 or
newer)
2) the file mscordacwks.dll that matches your version of
mscorwks.dll is
in the version directory
3) or, if you are debugging a dump file, verify that the
file
mscordacwks___.dll is on your
symbol path.
4) you are debugging on the same architecture as the dump
file.
For example, an IA64 dump file must be debugged on an
IA64
machine.

You can also run the debugger command .cordll to control the
debugger's
load of mscordacwks.dll. .cordll -ve -u -l will do a verbose reload.
If that succeeds, the SOS command should work on retry.

If you are debugging a minidump, you need to make sure that your
executable
path is pointing to mscorwks.dll as well.



Google了好几天,有解, 如下:



1.
.load wow64exts

2.
!sw

3.
.loadby sos mscorwks

4.
这里你可以执行sos里面的命令了。
!clrstack,
!thread,
!dumpheap -stat -type Exception //看异常比较有效
!pe, //看异常比较有效
!dso,
!do,
!GCRoot //分析ManagedHeap内在泄露比较有效。



严重推荐:
http://blogs.msdn.com/alejacma/archive/2009/08/24/managed-debugging-with-windbg-breaking-on-an-exception-part-1.aspx

2009-09-10

野性的呼唤

http://v.youku.com/v_show/id_XMjAxMzI5NDg=.html
看一下电影回味一下书

2009-05-12

键盘钢琴

http://www.alijj.net/qin.htm

我又何尝不想当一名艺术家。。。呵呵

2009-05-04

Firebug 如何提供console API到页面的window中

Firebug 如何提供console API到页面的window中?
How Firebug inject the console API to DOM window?
1. Use Components.utils.evalInSandbox and Components.utils.Sandbox

2. Register a listener to an Element in DOM window, which is created during injection phase.

3. Use attribute in precreated Element to specify the return value's type.


页面中执行的JavaScript与Firefox插件中执行的JavaScript代码是不能相互调用的。
因为各处于自己的解释器的工作范围中,运行时看不到对方定义的函数。

那么Firebug是如何把console API提供给页面的window的属性中的呢?
1. API如何绑定到页面的window中.
    如果是在页面中写代码,很容易在window属性中加入一个console对象,
    但是那样的话, 又不能调用或控制Firefox插件的控件了。

    Firebug通过在插件代码中调用 evalInSandbox方法, 传入用外部页面的window构造sandbox。
    在sandbox中执行一段注入(injection)代码, 使页面的window中有了console的定义。
           
            a. 注入代码的构造         \content\firebug\consoleInjector.js [getConsoleInjectionScript]
                var script = "";
                script += "window.__defineGetter__('console', function() {\n";                                                          //[1]
                script += " return window.loadFirebugConsole(); })\n\n";
               
                script += "window.loadFirebugConsole = function() {\n";                                                                   //[2]
                script += "window._firebug =  new _FirebugConsole();";                                                                   //[3]
                script += " return window._firebug };\n";
               
                var theFirebugConsoleScript = getResource("chrome://firebug/content/consoleInjected.js");            //[4]
                script += theFirebugConsoleScript;
            
            [1] 在此处定义了console 对象
             [2] 在此处定义了loadFirebugConsole方法,其中[3]实例化一个_FirebugConsole对象
             [4] 在此处加载_FirebugConsole的定义代码,稍后会说_FirebugConsole这段代码
             到此script中就构造好了准备注入的代码了。
          b. 构造sanbox
             // Use DOM Window 用外部的DOM window构造sandbox
            sandbox = new Components.utils.Sandbox(win);        
            sandbox.__proto__ = (win.wrappedJSObject?win.wrappedJSObject:win);

            c. 执行注入代码
            result = Components.utils.evalInSandbox(scriptToEval, sandbox);

到此页面的window有console的定义了,那console的方法(如log, debug, info, error)是如何把参数传递给Firebug插件的代码中的呢?

函数调用一般有三个过程
1. 参数准备             firebug 把要调用的函数的名字设置到预先定义的页面元素的属性中; 将参数设置为window的一个
userObjects属性。  
2. 函数执行             firebug 的chrome 会在预先定义页面元素上加一个linster, addEventListener, 进行chrome代码的调用。
3. 返回结果             firebug 把结果存回window的userObjects属性中, 并将返回值类型设置为预定的页面元素的一个属性中。



2. 函数的调用
   log, debug等函数的定义在_FirebugConsole这个类中, 代码位于 consoleInjected.js中.
        
          a. 建立一个页面元素来标示返回值的类型
           window._getFirebugConsoleElement = function()  // could this be done in extension code? but only after load....
  {
    var element = document.getElementById("_firebugConsole");                                              //[5]                  
    if (!element)
    {
        element = document.createElementNS("http://www.w3.org/1999/xhtml","html:div");
        element.setAttribute("id", "_firebugConsole");
        element.firebugIgnore = true;
         
        element.setAttribute("style", "display:none");

        document.documentElement.appendChild(element);
    }
    return element;
 };

         [5] 检测当前页面是否已经创建了用来传递数据及提供事件监听的页面元素
        

        b. 函数通过事件发出去,发送事件前的准备
            
    this.notifyFirebug = function(objs, methodName, eventID)
      {
        var element = this.getFirebugElement();                                     //获得元素

        var event = document.createEvent("Events");                             //创建事件
        event.initEvent(eventID, true, false);

        this.userObjects = [];
        for (var i=0; i<objs.length; i++)
            this.userObjects.push(objs[i]);                                              //准备参数

        var length = this.userObjects.length;
        element.setAttribute("methodName", methodName);                     //设置要调用的console对象的方法名
        element.dispatchEvent(event);                                               
        
        var result;
        if (element.getAttribute("retValueType") == "array")
            result = [];

        if (!result && this.userObjects.length == length+1)                       //如果只有一个元素新增,返回那个新增元素
            return this.userObjects[length];

        for (var i=length; i<this.userObjects.length && result; i++)
            result.push(this.userObjects[i]);                                          //将返回的结果数据向上层返回

        return result;
      };
 
         c. 调用事件监听
           在firebug注入代码到页面中后,进行了对调用事件的监听
   
         因为在sandbox中执行代码后, 页面中就会有一个叫_firebugConsole的页面元素,可以通过window.getElementById来获得。
                     
             
var handler = new FirebugConsoleHandler(context, win);  
           handler.attachTo(element);                                                       //调用内部执行addEventListener
          
        d. 响应调用事件
          handle: function(event, api, win)
  {
        var element = event.target;                                                 //获得事件对应的页面元素
        var methodName = element.getAttribute("methodName");          //获得想调用的方法名
        //获得调用的参数
        var hosed_userObjects = (win.wrappedJSObject?win.wrappedJSObject:win)._firebug.userObjects;

        var userObjects = hosed_userObjects ? cloneArray(hosed_userObjects) : [];
        var subHandler = api[methodName];                                     //找到相应的function对象
        if (!subHandler)
            return false;

        element.removeAttribute("retValueType");
        var result = subHandler.apply(api, userObjects);                    //用apply 来调用相应方法
        if (typeof result != "undefined")
        {
            if (result instanceof Array)
            {
                element.setAttribute("retValueType", "array");              //设置返回值类型
                for (var item in result)
                    hosed_userObjects.push(result[item]);
            }
            else
            {
                hosed_userObjects.push(result);
            }
        }

        return true;
  }

           到现在element.dispatchEvent(event);  后面的代码可以继续执行,并将返回值传给window中对console.log等方法。

再回顾一下:Firebug是如何把console API提供给页面的window的属性中的呢?
                答: 应用监听页面事件的方式来接收调用

注:文本中代码引自firebug 1.3.3 代码,有删减。


参考资料:
[1] JavaScript: The Definitive Guide, 5th
Edition ,
By David Flanagan
 注:作者写书时想把此书写成一本相当全面的JavaScript书,我认为,他做到了。
 作者书中对JavaScript的评价

Because JavaScript is interpreted instead of compiled, it is
often considered a scripting language instead of a true programming language.
The implication is that scripting languages are
simpler and that they are programming languages for nonprogrammers. The fact
that JavaScript is loosely typed does make it somewhat more forgiving for
unsophisticated programmers. And many web designers have been able to use
JavaScript for limited, cookbook-style programming tasks.


Beneath its thin veneer of simplicity, however, JavaScript is a
full-featured programming language, as complex as any and more complex than
some. Programmers who attempt to use JavaScript for nontrivial tasks often find
the process frustrating if they do not have a solid understanding of the
language. This book documents JavaScript comprehensively so that you can develop a sophisticated
understanding. If you are used to cookbook-style JavaScript tutorials, you may
be surprised at the depth and detail of the chapters ahead.

 [2] Firebug Console API, http://getfirebug.com/console.html
[3]https://developer.mozilla.org/en/Code_snippets/Interaction_between_privileged_and_non-privileged_pages

2009-03-30

firefox插件Mouseless Browsing

这个插件好啊,
这样真是可以不用鼠标来浏览网页啦.

Mouseless Browsing (MLB) enables you to browse the web entirely with the keyboard. The basic principle is to add small boxes with unique ids behind every link and/or form element. You just have to type in the id and press enter (there is also an automatice mode available) to trigger the corresponding action i.e. following a link, pressing a button or selecting a textfield.

学习Microsoft Office project的一个地方

http://office.microsoft.com/en-us/training/CR102140061033.aspx

2009-03-29

外语学习 BBC CNN NHK

mms://rj-wmt.gekimedia.net/rj28

mms://livewmstream-ws.bbc.co.uk.edgestreams.net/reflector:47971

mms://wm.nhk.or.jp/rj/on_demand/wma/japanese.wma

mms://a1181.l3760631180.c37606.n.lm.akamaistream.net/D/1181/37606/v0001/reflector:31180

2009-03-25

推荐一个Firefox插件, 将收藏夹备份

Foxmarks is the essential bookmarking add-on.

Install Foxmarks on each computer you use, and it works silently in the background to keep your bookmarks and (optionally) passwords backed up and synchronized. If you're away from your computer, Foxmarks allows you to access your bookmarks online by logging into my.foxmarks.com. Foxmarks' Suggested Tag feature helps you stay organized by recommending relevant tags as you add bookmarks in Firefox 3.


Foxmarks Add-on

RemoteControl

被WebSense限制郁闷了,总想着有这么一个软件, 但是越想越像木马.

这个软件用来远程控制Windows操作系统,程序与远程用户是基于邮件沟通的,

程序提供一系统的命令供远程用户通过发邮件调用.

这里称受控制的系统为服务端,控制端为控制端.

功能概览:

  1. 服务端系统启动以后会启动一个服务程序RemoteControl Service”

  2. 控制端发送邮件到指定的邮箱,邮件以约定的格式发送

  3. 服务端定期(间隔可以由上一次间隔设定邮件更新)接收邮箱中约定格式的邮件,
    解析邮件中的命令,
    以邮件发送命令的操作结果.

  4. 命令的操作结果可以包含文字或附件形式的文件.

下面图是命令执行的过程:




Figure
1 RemoteControl
中命令执行的过程


待续.

2009-02-21

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

Windows Server 2003下安装了完整版的Oracle9i后,用C#程序连接Oracle时出现奇怪现象.

同样的代码编成console application后可以找Oracle的驱动.
但是当编译成Web 站点,部署到IIS6.0后提示"System.Data.OracleClient requires Oracle client software version 8.1.7 or greater"

后来google,找到一个帖子原来是权限问题.
http://social.msdn.microsoft.com/forums/zh-TW/233/thread/51e8076a-66be-45da-aeb3-da9b83394d70/

具体步骤:
* Log on to Windwos as a user with Administrator privileges.
以管理员身份登录windows
* Start Window Explorer and navigate to the ORACLE_HOME folder.
浏览到ORACLE_HOME目录
* Choose properties on the ORACLE_HOME folder.
选择属性
* Click the “Security” tab of the “Properties” window.
选择安全
* Click on “Authenticated Users” item in the “Name” list.
* Uncheck the “Read and Execute” box in the “Permissions” list under the “Allow” column.
* Re-check the “Read and Execute” box under the “Allow” column
设置Authenticated Users的权限为读和执行.
* Click the “Advanced” button and in the “Permission Entries” verify that “Authenticated Users” are listed with permission = “Read & Execute”, and Apply To = “This folder, subfolders and files”. If not, edit that line and make sure that “Apply To” drop-down box is set to “This folder, subfolders and files”. This should already be set properly but it is important that you verify it.
* Click the “Ok” button until you close out all of the security properties windows. The cursor may present the hour glass for a few seconds as it applies the permissions you just changed to all subfolders and files.
应用权限到所有的子目录
* Reboot, to assure that the changes have taken effect.
重启电脑