Thursday, March 8, 2012

Change Windows Update Server URL

Modify the Windows Registry to change the WSUS URL:

\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUServer

Ref: http://technet.microsoft.com/en-us/library/cc708554(v=ws.10).aspx

Regexp match with GenericValidator

Just a reminder to use GenericValidator for a quick way to do regexp matching in Java.

boolean rslt = org.apache.commons.validator.GenericValidator.matchRegexp(str, "(?i)abc|def|ghi");


Wednesday, February 15, 2012

Using "define" function in Dojo

You may experienced an error message "define is not defined" when using Dojo I got this error when trying the dojo.i18n feature when I did a dojo.requireLocalization( ) call. In some occasions a pre-built version of Dojo just don't have the "define" function at all (sigh.. ridiculous!). To solve this problem, consider the following (Dojo 1.6):

<script>
dojo.ready(function() {
    var currentModule;
    define=function(d,b,c){function g(a){if(a.charAt(0)==="."){for(a=d.substring(0,d.lastIndexOf("/")+1)+a;b!==a;)var b=a,a=a.replace(/\/[^\/]*\/\.\.\//,"/");a=a.replace(/\/\.\//g,"/")}return a.replace(/\//g,".")}c||(b?(c=b,b=d):(c=d,b=typeof c=="function"?["require","exports","module"].slice(0,c.length):[]),d=currentModule?currentModule.replace(/\./g,"/"):"anon");var e=d.replace(/\//g,"."),h=dojo.provide(e);if(typeof c=="function"){for(var i=[],a,f=0;f<b.length;f++){a=g(b[f]);var j=a.indexOf("!");if(j> -1)a.substring(0,j)=="i18n"&&(a=a.match(/^i18n\!(.+)\.nls\.([^\.]+)$/),dojo.requireLocalization(a[1],a[2])),a=null;else switch(a){case "require":a=function(a){return dojo.require(g(a))};break;case "exports":a=h;break;case "module":var k=a={exports:h};break;case "dojox":a=dojo.getObject(a);break;case "dojo/lib/kernel":case "dojo/lib/backCompat":a=dojo;break;default:a=dojo.require(a)}i.push(a)}b=c.apply(null,i)}else b=c;b&&(dojo._loadedModules[e]=b,dojo.setObject(e,b));if(k)dojo._loadedModules[e]=k.exports; return b};define.vendor="dojotoolkit.org";define.version=dojo.version;define("dojo/lib/kernel",[],dojo);define("dojo/lib/backCompat",[],dojo);define("dojo",[],dojo);define("dijit",[],this.dijit||(this.dijit={}));

    dojo.require("dojo.i18n");
    dojo.registerModulePath("language", "/path_to/language");
    // OR you can try the following if you want a relative path
    // dojo.registerModulePath("language", "../../../../../../language");
    // Suppose you are using Main.js to define the language
    dojo.requireLocalization("language","Main");
});

</script>

Reference: http://dojo-toolkit.33424.n3.nabble.com/define-is-not-defined-in-dojo-build-tt3128408.html#a3241874

Wednesday, February 8, 2012

Solution for java.io.NotSerializableException error when Tomcat reloads

To solve the Tomcat restart error, add <Manager> setting in <Context> section:

<Manager className="org.apache.catalina.session.PersistentManager" 
         saveOnRestart="false">
    <Store className="org.apache.catalina.session.FileStore"/>
</Manager>


References:

Wednesday, February 1, 2012

HIde Account at Windows Login Screen


The following steps can hide user account in Windows login screen:

  1. Go to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList\, if key not exists, create them.
  2. Add DWORD registry
  3. Set name = User account name (e.g. demouser)
  4. Set value = 0

Done.

Sunday, January 29, 2012

Spatial Reference of HK

The spatial reference of Hong Kong could be found at : http://spatialreference.org/ref/epsg/2326/

There is a link "Proj4" in that page which provides the Proj4js definitions for converting EPSG:2326 (HK1980 Grid) projection to other projection using the Proj4js library:

+proj=tmerc +lat_0=22.31213333333334 +lon_0=114.1785555555556 +k=1 +x_0=836694.05 +y_0=819069.8 +ellps=intl +towgs84=-162.619,-276.959,-161.764,0.067753,-2.24365,-1.15883,-1.09425 +units=m +no_defs 



Wednesday, January 25, 2012

Command line to get installed software / windows updates information

One can use wmic command to get the list of product installed in Windows:
 c:\> wmic product

You can also specify which data fields you want to retrieve, e.g.:
 c:\> wmic product get caption

We can also use wmic command to get the list of windows updates made on the machine:
 c:\> wmic qfe list

Sunday, January 15, 2012

Solving disk offline issue in Windows

You may experienced a message "The disk is offline because it has a signature collision with another disk that is online" / "磁碟簽章發生衝突" in Windows. The case for myself is switching two RAID-1 drives back to non-RAID devices, where the two drives will become identical and cause the collision problem. The following is the solution to turn on the offline disk:

c:\>diskpart
c:\>list disk (you may see your offline disk is in the list)
c:\>select disk 1
c:\>offline disk
c:\>online disk


Reference: http://beddingmall.blogspot.com/2011/01/blog-post_04.html

Thursday, January 12, 2012

Delete Acronis Failed Task

Just tried their solution, it works:
  1. Run Schedmgr.exe and issue the following command: task zap
  2. Delete the content of the following folders:
    Windows XP, Windows 2000/2003 (32/64 bit)
    - \Documents and Settings\All Users\Application Data\Acronis\BackupAndRecovery\MMS\Policies\
    - \Documents and Settings\All Users\Application Data\Acronis\BackupAndRecovery\MMS\TasksStorage\
    - \Documents and Settings\All Users\Application Data\Acronis\BackupAndRecovery\MMS\PolicyStatistics
    Windows Vista, Windows 7, Windows Server 2008 (32/64 bit)
    - \ProgramData\Acronis\BackupAndRecovery\MMS\Policies\
    - \ProgramData\Acronis\BackupAndRecovery\MMS\TasksStorage\
    - \ProgramData\Acronis\BackupAndRecovery\MMS\PolicyStatistics
  3. Recreate the tasks
Ref: http://forum.acronis.com/forum/10652

CSP on Apache

To add CSP to root if sort of funny. The following will NOT work for most cases !!     <LocationMatch "^/$">        Header s...