Author Archive

August 1, 2008

Java Magic Trick: The Ball Is Everywhere

Tom @ 7:04 pm

As keen Java programmers we’re always on the lookout for interesting tidbits about the language, how it is being used and where it is heading. Just the other day Matt brought in a copy of Java Puzzlers to test our knowledge. So it was something of a coincidence that the guys over at Atlassian came out with their own Java puzzler.

The puzzle is a Java version of the shell game (AKA ‘thimblerig’), where the onlooker must choose which shell the ball is under (after the con artist has shuffled them around).

The puzzle and the included solutions are interesting, and well worth a read if you’re a programmer. Chris came up with the ’static block’ method almost immediately, but I must admit that my thinking was just along the lines of “err, with reflection somehow?” before we looked up the answers.

Four solutions were presented on Atlassian’s blog post, but I have a fifth: The terms of engagement were “you can only modify the class representing the ball”. But what about a solution that doesn’t involve modifying the ball either? What if you could alter the onlookers’ perception so that when the cup is raised they see a ball, despite there not being a ball at all?

Using the Force and with a wave of the hand, we get:

aspect YouWillBeEqual {
    boolean around(): call(boolean String.equals(Object)) {
        return true;
    }
}

Now there is a ball under every cup, always. At least, it appears that way. Actually, everything around here appears to have a ball under it…

Made possible with a little AOP ;)

December 6, 2006

Knowledge Base gets OpenSearch

Tom @ 11:25 am

If you were looking really hard while browsing our knowledge base recently, you might have noticed your Firefox search window glowing. You are using Firefox aren’t you? (get it here) Ok ok, if you’re stuck with IE7 you might have seen it as well. Anyway, the glowing search box is letting you know that there’s a new search engine available on this page to add to your browser’s drop-down list. This means you can search the PaperCut knowledge base quickly from your browser’s toolbar (without having to browse to the search page first).

It’s done using OpenSearch (WP). Basically it allows adding new engines the browser’s list in a standard way (i.e. you don’t have to write one for every browser out there).

The syntax is really quite simple, the bulk of it being contained in an XML file - an “OpenSource description document”. You can view the OSDD (I just made that up because I didn’t want to type it again) for our knowledge base here.

Most of it is just fluff that may or may not be ever needed/used. The important bit is the <Url /> tag. You’ll notice ours is quite long - this is mainly to do with customising the search results (excluding pages that aren’t relevant to people looking for answers in the knowledge base). A much simpler form of this tag might look like so:

http://somesite.net/search?q={searchTerms}

Then the following line in the <head> section of a page will make it available for consumption:

<link rel="search" type="application/opensearchdescription+xml"
      href="/papercut.osd.xml" title="PaperCut" />

That’s it. The glowing effect in the browser and everything needed to add it to the list of engines is all done for you. Search plugins to the masses!

September 15, 2006

Full Steam Ahead

Tom @ 10:23 am

Hello, world! I’m Tom, the latest addition to the PaperCut development team. Over the last month or so I’ve undergone a lightning induction into the world of programming at PaperCut and the many technologies used - Java, Tapestry, Hibernate, Spring, Jetty, JasperReports, Derby, PostgreSQL, Squid and many others, not to mention developing for Linux, Mac and Windows - an exciting prospect for any graduate!

You may have already noticed some of my additions to PaperCut NG - some new reports including the ‘detailed summary’ reports that show a breakdown by page size, the ‘report based on above data’ component, regex document name filters, and some new web service and server-command calls. I hope to be adding even more features in future, as well as improving our web site. Is there something that you would like to see added or improved? Send an email to the development team and let us know!

Even with the recent first public testing release of Internet Control for PaperCut NG, the fantastic feedback we’ve been getting with the PaperCut NG for Mac testing programme, and recent improvements for running PaperCut in unauthenticated environments, we’ve still got big things on the way. Here’s a quick look at what you can expect in the coming months:

  • PaperCut NG 7 - just around the corner!
  • Features from PaperCut ChargeBack coming to NG.
  • All those little updates that make the software that little bit easier or nicer to use.

We’ve also aggregated the developer blogs to one location, so please update your links if have been following along.

Happy to be on board with PaperCut and looking forward to hearing from you all in the future.

Cheers,

- Tom