<?php $rfc = date(‘r’, time()); ?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Time on server</title>
</head>
<body>
<div id=”server_time”>Loading…</div>
<script type=”text/javascript”>
var rfc = new Date(‘<?php echo $rfc; ?>’);
function countUp() {
document.getElementById(‘server_time’).innerHTML = rfc;
rfc.setTime(rfc.getTime() + 1000);
setTimeout(‘countUp()’, 1000);
}
countUp();
</script>
</body>
</html>
Category Archives: Chỉ dẫn lập trình
TIMESTAMP vs DATETIME in MySQL

SELECT CURRENT_TIMESTAMP
SELECT CURRENT_DATE
SELECT CURRENT_TIME
SELECT NOW()
Get all users in your computer
‘VBS – Windows
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set colUserList = objWMIService.ExecQuery _
(“Select * from Win32_Account WHERE SIDType=1”)
For Each objUser in colUserList
WScript.Echo objUser.Name
Next
Dealing with Duplicates When Inserting Rows
Trong một số trường hợp, khi thêm mới một bản ghi vào MySQL, bạn cần xử lý nếu dữ liệu bị trùng lặp.
In MySQL, there are basically three ways where you can insert data into a table where a duplicate might happen.
1. INSERT IGNORE INTO TABLENAME(col1, col2) VALUES (’xxx’, ‘yyy’)
INSERT IGNORE dùng khi nếu trùng thì không chèn nữa
Ví dụ: mỗi con chỉ do một mẹ đẻ ra child_id, mother_id
2. REPLACE INTO TABLENAME(col1, col2) VALUES (’xxx’, ‘yyy’)
REPLACE dùng khi chèn dữ liệu nếu có rồi thì cập nhật các trường ko phải key
Ví dụ: mẹ có số con thay đổi mother_id, number_child
3. INSERT INTO TABLENAME(col1, col2) VALUES (’xxx’, ‘yyy’) ON DUPLICATE KEY UPDATE col1 = ‘zzz’
INSERT … ON DUPLICATE KEY UPDATE dùng khi chèn dữ liệu: nếuchưa có thì chèn, nếu có rồi thì cập nhật gì đó (giữ nguyên thì có thể dùng mẹo)
Ví dụ: thời gian truy cập gần nhất của một client tới server client_id, client_location, last_visited_time
Terminate a process
File: terminate-notepad.vbs
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set colProcessList = objWMIService.ExecQuery _
(“Select * from Win32_Process Where Name = ‘Notepad.exe'”)
For Each objProcess in colProcessList
‘objProcess.ExecutablePath
objProcess.Terminate()
Next