Tips
View Androids emulator log from Eclipse
by ricardoz on Nov.19, 2009, under Android, Tips
Sounds like it should be quite straightforward, right? Well, it is, but for some reason it took me more than a few minutes (maybe I need to get more sleep :P). Anyway, to view Androids emulator log from Eclipse go to Window / Show View / Other… / Android / LogCat
Get a web page programatically from Android
by ricardoz on Nov.18, 2009, under Android, Tips
The Google folks were kind enough to include a version of the Apache HTTP Client in the Android SDK, ergo loading a web resource/page from our Android apps is really simple:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet("http://www.spartanjava.com"); HttpResponse response = httpClient.execute(httpGet, localContext); String result = ""; BufferedReader reader = new BufferedReader( new InputStreamReader( response.getEntity().getContent() ) ); String line = null; while ((line = reader.readLine()) != null){ result += line + "\n"; } // Now you have the whole HTML loaded on the result variable |
Obovweb source code – a Google Appengine sample
by ricardoz on Oct.20, 2009, under Security, Tips, Web related
Someone asked me about the implementation details of the Google Appengine sample I published a few weeks ago (http://obovweb.appspot.com/). Well, you can get a hold of the source code here.
There’s not much to tell, apart from the specific HMAC-SHA1 implementation (which you can check out in Obovs source code) it’s a very simple JSP/DWR application.
Enabling “Enter” in a form without a submit button
by ricardoz on Oct.13, 2009, under JavaScript, Tips
I find it quite annoying when I can’t post/confirm a web form using the Enter key.
Here is a nifty little javascript trick to do it when you do not need/want a submit input in your html.
(continue reading…)
Java application as a MS Windows service
by ricardoz on Jul.29, 2009, under Tips
It’s really annoying to run something interactively on MS Windows when you know deep inside it should be an OS Service. Doing this on a *nix system is quite simple (most of the times you just need to write a short shell script), but on MS Windows it’s not so easy.
(continue reading…)
Reload resource bundles on the fly, finally!
by ricardoz on May.13, 2009, under Tips
Ever since the very first time I used a properties file in Java I’ve wanted to be able to reload it upon a sysadmin request or some other circumstance without having to reload the whole application, reset the application server or use some dark proprietary Sun APIs. Well, finally in Java 1.6 we can do it!!
(continue reading…)
Fast collection look-ups
by ricardoz on Apr.30, 2009, under Performance, Tips
I recently had to load a bunch of objects into memory and then perform thousands of look-ups over that collection. Using the good old java.util.ArrayList just didn’t cut it, the contains() function is extremely slow (as you would guess of course since this implementation stores elements as they are inserted and without any aditional indexing structure).
(continue reading…)
Automatically serialize POJOs to and from JSON
by ricardoz on Apr.22, 2009, under JavaScript, Tips, Web related
The best tool I’ve found so far to serialize POJOs to JSON (and back again) is XStream, it’s automatic, simple and elegant, check it out.
PHP & Java interoperable encryption
by ricardoz on Jan.16, 2009, under Articles, Security, Tips
I recently faced the problem of encrypting something in PHP and decrypting it using Java, this proved to be a little more of a challenge than what it initially seemed like. (continue reading…)
Setup your web server to properly serve MS Office 2007 files
by ricardoz on Oct.20, 2008, under Tips, Web related
Most web servers are missing the new MIME types needed for Office 2007 files (docx, xslx, etc.) and when you server one of this files from your web application the users browser typically tries to open them as ZIP files.
(continue reading…)