Posts

Showing posts from 2012

Side notes on Android Dev

To make your subclassed ViewPager (android.support.v4.view.ViewPager) work, prepare both the constructors in your class: ViewPager(Context context) ViewPager(Context context, AttributeSet attrs) In ActionBarSherlock, if you can't get the loading icon work, i.e. setSupportProgressBarIndeterminateVisibility( ) just got no effect at all, then you are very likely have a wrong Window class (android.view.Window) imported. You should include the ActionBarSherlock Window class instead. com.actionbarsherlock.view.Window

Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver error

If you ever come up with the error using ChooserActivity with the Android emulator, you probably don't need to be worried. It's basically because you only have a single choice to start the intent (e.g. send a message, choose a audio file, choose a picture, etc., in the emulator). There is just no way to show you the option dialog, and the exception raised. Read the explanation in the following: http://stackoverflow.com/questions/11308260/chooser-activity-leak-android

Android 2.2 SDK with strings.xml having multiple %s

When building the SearchableDictionary examples using 2.2 SDK, the strings.xml contains the following which fails the compilation: <plurals name="search_results">    <item quantity="one">%d result for \"%s\": </item>   <item quantity="other">%d results for \"%s\": </item> </plurals> We need to change them to the following in order make it compiled: <plurals name="search_results">    <item quantity="one">%1$d result for \"%2$s\": </item>   <item quantity="other">%1$d results for \"%2$s\": </item> </plurals> Reference: http://be-evil.org/android-multiple-substitutions-specified-in-non-positional-format.html

Quick notes on Dojo 1.8

Just a quick notes on dojo 1.8. For example, if I want to use the Color object in dojo. I will:    var Color;    require(["dojo/_base/Color"], function(c) {       Color = c;    }); Then I can use the variable Color after the initialization is done. Am I correct? Should it be used in another way? :-)

Upgrading from ArcGIS Android API v1.1 to v2.0

If you got a ArcGIS Android Project using ArcGIS API v1.1 and switch to v2.0, you will have a runtime exception when you do a pan action in the map view.    FATAL EXCEPTION: main    java.lang.UnsatisfiedLinkError: nativeSetAnimating    com.esri.android.map.MapSurface.nativeSetAnimating(Native Method)    ... To solve this problem, you need to: Create a new ArcGIS Android project using v2.0 Copy the files "libs/armeabi/libGLMapCore.so" and "libs/armeabi-v7a/libGLMapCore.so" back to your original v1.0 project directory Very stupid right? But choose to use this product is stupid enough.

DOJO: Tab ordering in TabContainer

The tabContainer.getChildren( ) method returns a list of tab widget (ContentPane) in the container using the following way:     dijit.findWidgets(tabContainer.containerNode) However, if you did some drag and drop actions on the tab button list to rearrange the tab ordering, the tab sequence did not changed actually. To get a modified / correct ordered list, you may try to override the getChildren( ) method:     myTabContainer.getChildren = function() {         var list = this.tablist.getChildren();         var rsltList = [];         for (var idx=0; idx<list.length; idx++) {            rsltList.push(list[idx]. tab );         }         return rsltList;     } Noticed the underlined "tab" member variable in the code, you need to manually assign it when your tab page is created. Or you may find a way / method to ge...

Drag and Drop of Tab in Dojo

Image
Check the following example for a hint to do drag and drop of tab page in Dojo:

Overriding window.open( ) in Javascript

Sometimes you may want override the window.open( ) in Javascript. It's strange, but you really it occasionally. Here is how we can do it: var open_ = window.open; window.open = function(url, name, opts) {    return open_(url, name, opts); } Then you can add your own checking / modifications right before the window is opened.

ArcGIS JS: Move a graphic to top

To move a graphic in a ArcGIS JS GraphicsLayer to top: g.getDojoShape().moveToFront(); But this may breaks the onClick event of the GraphicsLayer, beware. Updated: in ArcGIS JS API version 3.8, use getShape( ) instead. ESRI... no more stupid naming please...

About OSX Lion's Apache

Just a quick notes on Lion's Apache information: Location of the httpd.conf: /etc/apache2/httpd.conf PHP: php5_module in httpd.conf Virtual hosts conf: /private/etc/apache2/extra/httpd-vhosts.conf (included in httpd.conf) Restart Apache: apachectl restart (requires root)

Filter in Wireshark

Suppose you want to monitor the HTTP request from 192.168.0.1 to 202.168.1.2 with a particular URI (e.g. saveUserInfo/) using Wireshark, you can specify the above situation using the filter below: ip.src == 192.168.0.1 and http.host = "202.168.1.2" and http.request.uri contains "saveUserInfo" Quite handy :)

JSP too large for Tomcat

A long JSP just worked in Tomcat 6.0.29. Somehow when we put it in 6.0.35, it got error "Unresolved compilation problem". It seems that the new Jasper (/lib/ecj-3.7.jar) just not work for large JSP. One of the solution will be using the Jasper from 6.0.29 (/lib/jasper-jdt.jar) instead. Or.. keep using the 6.0.29 for some while...

Secure the ArcGIS Server

References for securing the ArcGIS server: http://blogs.esri.com/esri/arcgis/2010/06/23/five-things-to-consider-when-securing-arcgis-server/ http://geochalkboard.wordpress.com/2010/12/13/using-a-proxy-page-with-the-arcgis-server-api-for-javascript/ http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jshelp/ags_proxy.htm#webprint

Small HTTP servers for Windows

Some mini size HTTP server software for Windows: QuickPHP Abyss nginx For nginx, if you want to add an alias which point to another location which is not under the root directory, you can put the following in the nginx.conf: location /web {     alias   d:/Code/nginx_web; }          This means for locations http://yourhost/web , it is pointing to d:\Code\nginx_web actually. So what about ProxyPass in nginx? I will try on it tomorrow. Keep update soon.

Editors for MacOS

Just need some nice text editor to code, here I found some nice stuff: Kod TextWrangler Carbon Emacs macvim For TextWrangler, if we want to add color themes to it, we can put bbedit theme files to ~/Library/Application Support/TextWrangler/Color Schemes/

Good notes on Eclipse + Android SDK

Just found a nice page summarizing problem we may encountered during development: Eclipse + Android SDK bugs and workarounds, common mistakes | Hello Android

CSS DropShadown in IE9

Reference  http://www.useragentman.com/blog/2011/04/14/css3-text-shadow-can-it-be-done-in-ie-without-javascript/ A good way to perform text shadow in IE9: background-color: 'white' ; filter: progid:DXImageTransform.Microsoft.Chroma(Color= 'white' )         progid:DXImageTransform.Microsoft.DropShadow(OffX=3, OffY=3, Color='white'); The point is to make use of Chroma filter and set a proper background-color. So great!

Java encoding : UTF-8, Big5, x-MS950-HKSCS

Suppose you got a file in Big5 containing some HKSCS characters (e.g. 深水埗, 赤鱲角, etc). When your environment (Ref: Charset.defaultCharset( ) ) is either UTF-8 / Big5, you will never get the things work. The proper encoding should be "x-MS950-HKSCS" This situation happens when I'm try the same pieces of code in Java console / Eclipse console and JSP @ Tomcat. While JSP works fine, but sucks in console mode. Finally I found the JSP is actually using encoding "x-MS950-HKSCS". To set environment charset in Eclipse: Right click on the file that you are going to execute (e.g. Testing.java), then "Properties" → "Run/Debug Settings" → "Common" → "Encoding". Type "x-MS950-HKSCS" in the field. What a pity!

YUI LayoutUnit collapse

One can use layout.getUnitByPosition('left').collapse() and  layout.getUnitByPosition('left').expand() to the layout units (except 'center' layout unit) in YUI's Layout. Once the layout unit is collapsed, the size is determined by the attribute 'collapseSize'.

Should I read some more about HTML5?

Let's read some more then... http://www.hksilicon.com/kb/articles/58634/HTML5 http://blog.othree.net/log/2011/01/22/html5-2011-01/ http://www.sitepoint.com/real-world-accessibility-html5-aria-and-the-modern-web/#fbid=liED5trl79M

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");

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...

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: http://blog.csdn.net/forandever/article/details/4553447 http://stackoverflow.com/questions/4232222/cannot-resolve-this-error-notserializableexception

JavaScript libraries list

Just wanna to find some list for JavaScript libraries collection, I only got one at this moment: JS Dev Tools -- A roundup of Javascript development tools and libraries

HIde Account at Windows Login Screen

The following steps can hide user account in Windows login screen: Go to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList\, if key not exists, create them. Add DWORD registry Set name = User account name (e.g. demouser) Set value = 0 Done.

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

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

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

Delete Acronis Failed Task

Just tried their solution, it works: Run Schedmgr.exe and issue the following command: task zap 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 Recreate the tasks Ref:  http://forum.acronis.com/forum/10652

Column aggregation in Oracle

Suppose we have a table (TBL) in Oracle with columns (CATEGORY, ATTR). Consider the following: CATEGORY ATTR 1 A 1 B 1 C 2 D 2 E 2 F 3 X 3 Y 3 Z We want to convert the table as follows: CATEGORY ATTR 1 A,B,C 2 D,E,F 3 X,Y,Z This can be done via the SQL below: select CATEGORY,         xmlagg(xmlelement(c, ATTR || ',')).extract('//text()')  from TBL  group by CATEGORY

Determine user in Tomcat

To determine user authentication info in Tomcat, we can use the following: getRemoteUser() isUserInRole(String role) Both methods are under javax.servlet.http.HttpServletRequest.