About Mark Shead

Mark Shead

Mark Shead

Find more about me on:

Here are my most recent posts

Annie Edson Taylor’s Barrel

Annie Taylor was the first person to go over Niagara Falls in a barrel. She was 63 when she pulled the stunt and survived very well. She was doing it in order to provide herself with an income in her older age. It didn’t work out that well and she eventually lost the historic barrel when it was stolen by her manager. No one knows where it is now.

Maybe it will turn up someday.

A Plan for the Post Office

It appears that thousands of post offices may be closed due to the fact that the USPS is losing large amounts of money each year. I would think that ecommerce would be creating more goods that would be sent though the postal service and this would help offset some of the decreases in the amount of mail people send. Evidently it isn’t enough.

Closing post offices may make sense, but what about doing the opposite? In areas that are less populated, do deliveries every other day, but let people who want mail every day pick it up from a post office box. I would imagine that the cost of keeping a rural post office open is minimal compared to the cost of paying drivers to deliver the mail. Maybe the solution is more and bigger post offices and fewer deliveries to homes.

scalr

Scalr looks like an interesting tool that will let you automatically bring up Amazon Web Services infrastructure to support spikes in demand for your web application.

Get the URL of a Page in Tapestry 5

Sometimes your program will need to get the full URL of a page to send in an email, share on Facebook or run through a URL shortener to send to Twitter. You can do this by injecting the HTTPRequest and the building a string representation of the URL manually, but this is a lot more work that it needs to be. Here is a simple way to do it using Tapestry’s PageRenderLinkSource and a Link object.

@Inject
PageRenderLinkSource linkSource

/**
 * Return a string with the full URL of MyPage with a 
 * context of 5.
 */
public String getPageURL() {
	Link link = linkSource.createPageRenderLinkWithContext("MyPage", 5);
	return link.toAbsoluteURI();
}

I’ve hard coded the value 5 as the context–you’d normally set that based on whatever you are wanting to share. This method will return a link to MyPage with a context of 5, so it will probably look something like: http://www.myserver.com/MyPage/5. One of the nice things about this solution is that it will automatically handle things if your application needs to use a URL like: http://www.myserver.com/myapp/MyPage/5