Showing posts from September, 2010

Fixing my HTC Desire's wifi

I recently did an Over The Air (OTA) update of my new HTC Desire from 2.09 to 2.10. The update all seemed to run correctly. However I soon noticed that the wifi wasn't working. Looking in settings, it showed wifi was disabled and when you try and enable it, you just get "error". Seems like other people have been getting this as well. I tried following their advice, reset the factory defaults but that didn't work. I couldn't get the recovery mode to load (in order to wipe the caches) - after some brief searching it appeared that this was due to root access so I gave up on that. NOTE: it turns out I was doing it wrong. After selecting the recovery option a red triangle with an exclamation point is show. At which point you need to press volume+ and power to show the next menu. Next I tried using latest RUU (2.10) but got Error 170 Usb Connection Error . One post mentions under 'update': HTC has released a new Froyo OTA update. You can install this dire

Escaping a regex expression

I was working on a project where I needed to dynamically generate a regular expression based on some user input but the string to search for needed to be escaped. Below is the quick and dirty way to do it: /** * Utility function to replace regular expressions. * * @param input * @return */ private static String escapeRegex(String input) { String special[] = { "\\", "[", "]", "^", "$", ".", "|", "?", "*", "+", "(", ")" }; String val = input; for (String replace : special) { val = val.replace(replace, "\\" + replace); } return val; }

Tomcat DBCP: Data source is closed

After updating to the latest version of Tomcat I started getting the following error when redeploying a webapp from inside eclipse: java.sql.SQLException: Data source is closed     at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(     at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection( It seemed to be related to an updated version of DBCP that is used inside tomcat (I get Tomcat to manage my datasource). After tracing the code a bit I discovered it was because I called this, in my Filter.destroy() to do clean up: ((BasicDataSource) dataSource).close(); Older versions of Tomcat (6.0.26 and below), didn't care if you called it. When the webapp was reloaded, the datasource still worked. But as of 6.0.28, the newer version of DBCP seems to cause problems. So if you want to clean up after the webapp, use the removeAbandoned attribute in the Tomcat Configuration on the datasource, that way DBCP just clea

Portable java environments on windows

I always seem to be copying my development environment between PCs and latops which end up being time consuming. Its not the size of the data, its the number of small files (mainly javadoc & java source) that slow the whole process down. I already store the source code and workspace for my clients in a TrueCrypt Volume , to prevent my code being stolen if someone were to get hold of my laptop. All the other necessary files I need for development; such as libraries, jdk, tomcat/jboss, elcipse etc; are stored on my hard drive. In some cases on different drive letters on different computers. So to simplify this I wanted to store them in a similar way to a TrueCrypt volume but without the overhead of encryption and the hassle of mounting it. After some poking around I remember that Windows 7 came with built-in support for creating and mounting Virtual Hard Disk (VHD) straight from the Storage Manager. The VHD are used by Virtual PC. For those running Vista, Virtual PC 2007 should s