2013年9月27日 星期五

javax.xml.ws.WebServiceException: 無法建立 JAXBContext

使用 web service 時如果有 throw exception 的話,會遇到 "javax.xml.ws.WebServiceException: 無法建立 JAXBContext" 的錯誤

java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions java.lang.StackTraceElement does not have a no-arg default constructor.

把 throw exception 拿掉,改用 try..catch 就可以了

2013年9月26日 星期四

javascript 執行減法運算


在 javascript 執行 float 相減時,可能會發生 9.700000000000001 的情形
為防止這個情形發生,必需加上 .toFixed()

例如:
var i = 9.8;
i = (i - 0.1).toFixed(1); // i => 9.7

2013年9月18日 星期三

備份系統安全性記錄檔


參考來源: http://jojochen.blog.ithome.com.tw/post/2529/77642
參考來源: http://msdn.microsoft.com/en-us/library/aa394593%28v=VS.85%29.aspx

以下為 vbs 內容:

=============================

'定義變數BackupName備份事件檢視器檔案
Dim BackupName
Set Fso = CreateObject("Scripting.FileSystemObject")

'定義當日年,月,日
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay

'設定 WMI 取得 NameSpace 為 root\cimv2 的 Backup 方式
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Backup,Security)}!\\.\root\cimv2")

'WQL 取得 Win32_NTEventLogFile 為安全性記錄檔 security
Set colLogFiles = objWMIService.ExecQuery("Select * from Win32_NTEventLogFile Where LogFileName='security'")
For Each objLogfile in colLogFiles
BackupName = "c:\" & strBackupName &  "_security.evt"
if (Fso.FileExists(BackupName)) then
objLogFile.BackupEventLog("c:\" & strBackupName &  "_security2.evt")
objLogFile.ClearEventLog()
WScript.Echo "File saved: " & strBackupName &  "_security2.evt"
else
objLogFile.BackupEventLog("c:\" & strBackupName &  "_security.evt")
objLogFile.ClearEventLog()
WScript.Echo "File saved: " & strBackupName &  "_security.evt"
end if
Next

Set colLogFiles = Nothing
Set objWMIService = Nothing
Set Fso = Nothing

=============================

更新:
在 windows 2000 執行時遇到 SWbemObject: Access denied 存取遭到拒絕
將 impersonationLevel=impersonate,(Backup) 改成 impersonationLevel=impersonate,(Backup,Security)


2013年9月14日 星期六

解決 sencha touch 2.2.x 在 Chrome 29.x 執行時,textfield 無法顯示的問題


參考來源:http://druckit.wordpress.com/2013/08/22/sencha-touch-2-x-and-google-chrome-29/
There’s a bug in Google Chrome 29 that prevents Sencha Touch 2.2.x apps from displaying properly. While this shouldn’t affect mobile browsers (yet), it will affect you if you use Chrome to debug your apps.
You can patch your Sencha Touch 2.2.x apps by modifying the /touch2/resources/themes/stylesheets/sencha-touch/base/mixins/_Class.scss file, replacing the st-box mixin with the following code:
1
2
3
4
5
6
7
8
9
10
11
@mixin st-box($important: no) {
    @if $important == important {
        display: flex !important;
        display: -webkit-box !important;
        display: -ms-flexbox !important;
    } @else {
        display: flex;
        display: -webkit-box;
        display: -ms-flexbox;
    }
}