Query Xml String

DECLARE @tblXML TABLE (
UID int IDENTITY(1,1),
Software XML
)
INSERT INTO @tblXML (Software) VALUES ('<root><program><name>AAA</name></program><program><name>BBB</name></program></root>')
INSERT INTO @tblXML (Software) VALUES ('<root><program><name>CCC</name></program><program><name>DDD</name></program></root>')
INSERT INTO @tblXML (Software) VALUES ('<root><program><name>AAA</name></program><program><name>DDD</name></program></root>')
DECLARE @Software XML
DECLARE @tblAll TABLE (
Name nvarchar(max)
)
--設定指標
DECLARE tmpCursor CURSOR FAST_FORWARD FOR
SELECT TOP 100 [Software].query('//program//name') FROM @tblXML
OPEN tmpCursor --開啟指標
FETCH NEXT FROM tmpCursor INTO @Software --設定讀取變數
--迴圈讀取
WHILE @@FETCH_STATUS = 0
BEGIN
--PRINT CAST(@Software as nvarchar(max))
INSERT INTO @tblAll
SELECT n.value('.','nvarchar(max)')
FROM @Software.nodes('//name') t(n)
FETCH NEXT FROM tmpCursor INTO @Software
END
CLOSE tmpCursor --關閉指標
DEALLOCATE tmpCursor --移除指標
SELECT NAME, COUNT(NAME) 'Total' FROM @tblAll
GROUP BY NAME
view raw xmlstring.sql hosted with ❤ by GitHub

Detect User Agent


javascript - jQuery: check if user is using IE - Stack Overflow

Overlay (fx、ch、ie6~9)

jQuery.browser在1.9後就被拿掉了,為了通用性,用了另一種方式判斷ie6
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<!--[if lte IE 6]>
<script type="text/javascript">
var isIE6 = true;
</script>
<![endif]-->
<script type="text/javascript">
$(function() {
var $links = $('a');
$links.click(function(event) {
event.preventDefault(); //測試用,先把事件擋下來,避免網頁轉走
// fix IE6
if (typeof isIE6 !== 'undefined') {
$('body,html').css({'height':'100%','margin':0});
}
// 全畫面訊息
$('body').eq(0).append('<div id="myMask" style="text-align:center;background-color:#CCC;width:100%;height:100%;position: absolute;top:0;left:0;margin:0;"><span style="position:absolute;top:200px">Load Mask</span></div>');
// 透明度
$('#myMask').css({'opacity': 0.8});
});
});
</script>
view raw mask.js hosted with ❤ by GitHub

Read / Write ini

[Config]
Data=C:\data.xml
LastScan=2014/04/11 11:29:49
view raw config.ini hosted with ❤ by GitHub
MyIni.ReadIni("C:\config.ini", "Config", "Data", "")
MyIni.WriteIni("C:\config.ini", "Config", "LastScan", Now.ToString("yyyy/MM/dd HH:mm:ss"))
view raw HowToUse.vb hosted with ❤ by GitHub
Public Class MyIni
Private Declare Unicode Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringW" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringW" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
Public Shared Sub WriteIni(ByVal iniFileName As String, ByVal Section As String, ByVal ParamName As String, ByVal ParamVal As String)
Dim Result As Integer = WritePrivateProfileString(Section, ParamName, ParamVal, iniFileName)
End Sub
Public Shared Function ReadIni(ByVal IniFileName As String, ByVal Section As String, ByVal ParamName As String, ByVal ParamDefault As String) As String
Dim ParamVal As String = Space$(1024)
Dim LenParamVal As Long = GetPrivateProfileString(Section, ParamName, ParamDefault, ParamVal, Len(ParamVal), IniFileName)
ReadIni = Left$(ParamVal, LenParamVal)
End Function
End Class
view raw MyIni.vb hosted with ❤ by GitHub

Hide batch window

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("D:\MySoftware\EmptyApps.bat"), 0, True
view raw hide.vbs hosted with ❤ by GitHub