Tuesday, January 27, 2015

Simple Java Ray Tracer

This evening I decided to go through a few old folders on my laptop and delete anything I don't need anymore. One of the items was a zip file of some source code for a ray tracer written in Java. I downloaded it a few years ago from another blog that's no longer online. I believe it was originally written in 2008 by Barak Cohen and Gur Dotan.


As the authors blog is no longer available I couldn't bring myself to deleting it and have put a copy on GitHub in case any other people out there want to take a look. I've rejigged the project structure a little and removed all the Eclipse related files in favour of a Gradle configuration.

Friday, January 23, 2015

Vendor specific meta tags

The company I work for use IE almost exclusively. Every member of staff has been on IE9 for some time and are now on IE11 which means that I'm in the fortunate position of not needing worry too much about implementing CSS and Javascript workarounds for old browsers. What I am seeing more of though is vendor specific meta data.

Although the company use IE on the desktop (I still use Chrome & Firefox for development), we do also test projects on Android and iOS. All three platforms we support have their own tags for icons and the like.

It would be good see some standards introduced so that developers can add this type of information in a way that can be used by multiple browsers.

Thursday, January 22, 2015

How To: Deploy a Java war file to OpenShift

I recently put together a responsive web application for someone that wanted a convenient way to keep track of the types of food they've had each day with the ability to perform some statistical analysis on the data recorded. The application uses Spring, Hibernate, JSF, Primefaces, and Twitter Bootstrap. They've opted to have it hosted in the cloud using Red Hat's OpenShift which gave me an opportunity to use the platform for the first time.

Openshift provide a range of options for Java. My app needed Java 7 and Tomcat 7 (there currently doesn't seem to be an option for Java 8) so I selected the appropriate option and set about getting my app deployed.
$ git clone
$ cd nutritionapp/
A directory structure and pom file is already setup for those wanting to commit source code to be built by Openshift prior to deployment. This wasn't what I wanted as I've already compiled a war file and just want a quick way to deploy it. For this option, Red Hat have also put a 'webapps' folder in the root of the repository so I needed to do was delete the 'pom.xml' and the 'src' folder, add the war then push.
$ git rm pom.xml
$ git rm -r src/
$ git add webapps/nutritionapp-1.1.war
$ git commit -am "deploy v0.1 to cloud"
$ git push
I then ssh'd into OpenShift using the url provided in the web interface and did 'tail -f app-root/logs/jbossews.log' to see what was happening with deployment. There was a problem during start up but the log entry wasn't too helpful. Luckily I found a post here which helped out, seems that in OpenShift the 'web.xml' in the app needs to have the Log4jConfigListener removed.

    org.springframework.web.util.Log4jConfigListener
So after a quick edit of the 'web.xml' one last commit was needed.
$ git commit -am "removing Log4jConfigListener"
$ git push
That was it, the whole process was pretty simple.