[JS] 偵測設備是否支援觸控

$(document).ready(function() {
var $body = $(‘body’);
var detectMouse = function(e){
if (e.type === ‘mousedown’) {
alert(‘Mouse interaction!’);
}
else if (e.type === ‘touchstart’) {
alert(‘Touch interaction!’);
}
// remove event bindings, so it only runs once
$body.off(‘mousedown touchstart’, detectMouse);
}
// attach both events to body
$body.on(‘mousedown touchstart’, detectMouse);
});

參考來源:http://stackoverflow.com/questions/7838680/detecting-that-the-browser-has-no-mouse-and-is-touch-only

廣告

Spring Security: Active Directory setup

基本設定:
http://javarevisited.blogspot.tw/2011/11/ldap-authentication-active-directory.html

Kerberos vs NTLM:
http://infocenter.pentaho.com/help/index.jsp?topic=%2Fpdi_admin_guide%2Ftask_manual_msad_config.html

用CURL上傳檔案

用CURL call 上傳檔案的API:

Step1: 預存cookie檔案
curl -d “username=admin&password=admin" http://1.1.1.1:8080/login -D scookie.txt
Step2: 呼叫上傳API:
curl -X POST -H “Authorization: Basic YWRtaW46YWRtaW4=" -H “Content-Type:multipart/form-data" -b scookie.txt -F file="@/filename.ext" -F  overwrite="true" http://1.1.1.1:8080/upload