Sunday, 30 November 2008

Open Finder at PWD

Tuesday, 25 November 2008

Getting Lat and Long values from Google maps

This is listed in countless other places, but I didn't want to lose track of it:

Centre an item in google maps and put this in the address bar -



This will alert the lat and long values to the screen.

Original hint found here (with thanks!):
http://birdhouse.org/blog/2008/05/01/get-latlong-from-google-maps/

Sunday, 16 November 2008

Java: Using Jersey and Grizzly to create a RESTful Framework for Web Applications

Here are some notes if you want to get started building a basic Jersey / Grizzly REST framework. The information here should be enough to get you started with the application launcher and a couple of resources which you can then test in a browser.

I got started by following the notes here as much as possible and then tried to boil the information down in order to give myself the most basic understanding of how these frameworks could be used in projects:

https://jersey.dev.java.net/use/getting-started.html

I created a new project in my favourite editor (IntelliJ IDEA) and then placed the following .jar files in my lib directory:

In the src folder, I created the following files (note: you'll need to edit the line containing "YOUR.NAMESPACE.HERE" and replace it with your namespace:

LaunchApp.java:


I placed the next two files in a folder called resources (src/YOUR/NAMESPACE/resources), so the config class could find and register them:

HelloWorldResource.java:


GreetPersonResource.java:


Once they're all in place and you have imported the jar folder into the project, you should be able to run LaunchApp and visit the following URIs:


And finally, I got myself up and running by looking at this page and downloading the project:

http://docs.sun.com/app/docs/doc/820-4867/ggqzb?a=view

I hope this helps someone get started quickly.

Friday, 14 November 2008

PHP: parsing an include

If you're using php include a fair amount, you may well get to a point where you don't just want to 'drop' some text into your document but need to resolve variables etc.

There is a written function in the php manual that allows 'included' php to be parsed - hopefully this post will make the code snippet slightly more visible to someone and hence save them some time: (from http://www.php.net/include/)



If you use this block of code, you can pass in the name of a file to be included and the resultant page will return with any php processing fully parsed (rather than being dumped out into the content of the page as static strings.

$_SERVER['HTTP_REFERER'] and firefox

Just a quick note on a potentially useful discovery - if you need to keep track of the http referer and you're counting on using javascript (e.g. you might be writing an AJAX service), firefox doesn't pass the http_referer to a service when it gets (or posts) to it.

So if you were writing a service (say: something like a login overlay that returns the user to the last page they were viewing), you can 'resolve' the http referer from the javascript window.location.href. Useful to know, I think :)