Monday, December 22, 2014

European Road Trip - xmas 2014

It's been a little over 2 years since our last road trip. This This time it's a little shorter but also spread over a longer time making the whole experience a little less intense.


We set off from Leeds on Friday night and stayed in a hotel on route to the channel tunnel then again in Luxembourg on Saturday evening, leaving a 5 hour drive to Munich on Sunday. We'll stay here for a couple of days before going south to Innsbruck for Christmas.

Monday, December 01, 2014

How To: Get started with D

As much as I like working with Java, it's nice to use a language that can be compiled to native code. Occasionally I dabble with C or C++ but the ecosystem is about as old as the languages. I want to work with a language that doesn't just have clear syntax but decent tools to handle builds and project dependencies as well as making it easy to compile on multiple platforms (Windows, Mac and Linux is a must).

D meets these needs (partly due to DUB). It's been around for over a decade but it's the second version (first released in 2007) that is currently in use.

The D compiler can be downloaded from dlang.org and DUB can also be downloaded from the sub-domain code.dlang.org. Once they are both installed and available on your PATH open up a command prompt and use DUB to initialise a project.


DUB will create your project structure and a simple manifest file 'dub.json' which will be familiar to anyone that uses NPM or Gradle.


For this simple example I've added 'vibe-d' to the project dependencies. Then in the source file I've replaced the contents of the 'app.d' file with the simple example given on the Vibe-d website.


To compile the project simply run the 'dub' command in the root of the project. DUB will then download the vibe-d library, compile and link the project, the run the compiled executable.


That's it! We have a simple server running that can be opened in the browser.


Obviously this example is pretty trivial but I've been playing with D in my spare time for some months now (working on a GTK app) and have found the transition from Java to D to be relatively painless. So go give it a try.

Saturday, October 25, 2014

How To: List all compile dependencies using Gradle

Gradle makes it easy to add steps to the build process. Today I found a nice little task to list all project dependencies:


The only problem with this is when a project has some local dependencies that are included using compile files('lib/some.jar'). A dependency included in this way has no group, name, or version as it is not in a repository. This was causing a dependency in my project to show up as "null : unspecified : null". To get around this I made a variation of the task above which will list the filename of each jar file that is being included:


It comes in handy when you want your build server to provide a little more information for debugging problems. Simply add the task to your projects build.gradle file (anywhere below the dependencies block).

Monday, October 06, 2014

What happened to nine?

Microsoft may not acknowledge the number nine but one thing they are doing with their upcomming version of Windows is accepting that they were wrong about the start screen. This is something the GNOME Foundation should take notice of. At least Microsoft have listened to the backlash and realised that people still need a traditional desktop.

The idea of forcing a user interface designed for touch-screen devices onto users that need a productive desktop machine was always doomed to fail. Who cares if the average consumer is now buying a tablet instead of a desktop, as long there are jobs there will be a need for computers that can be productive in the workplace.


I do feel that the team at Microsoft deserve some respect for the work they've done in merging the start screen from Windows 8 with the menu from previous releases but most of all for backing down and listening to their users.

Thursday, August 28, 2014

Things to remember when creating an HTML email template

Every web developer knows about the kind of problems that can be encountered when supporting multiple browsers, especially older versions of IE. These days things are getting better though, even IE is able to do a half decent job. The world of email clients is another story all together though. The pain of supporting multiple browsers is nothing compared to the nightmare of trying to get your well designed email to render correctly in even a small selection of the hundreds of email clients out there.

Having spent the last few months doing a major overhaul of an application at work I decided it would be a good idea to redesign the email templates being sent from the system to be more in line with it's new layout.

As the emails are only received by members of staff during work I'm in the fortunate position of only needing to support two email clients. However, rather unfortunately the two clients we need to support a rather hideous; Microsoft Outlook and the built-in client used in BlackBerry devices.

There are two types of problems you'll encounter when designing email templates. Firstly email clients tend to lag far behind browsers in terms of HTML and CSS support and secondly there's a lot of weird quirky behaviour in some email clients.

For some strange reason Microsoft uses the same HTML engine used in Word to display HTML emails in Outlook, meaning that Outlook has minimal support for CSS properties. BlackBerry has full support for XHTML 1.0 and partial support for HTML 4 & CSS 2.1. So forget about using anything recent, email templates need to be done the old fashioned way, with tables.

To keep things simple I stuck to using a fairly basic layout using XHTML strict and validating it periodically using the W3C Validator to make sure everything was correct, not that it would make much of a difference, as some email clients (including Outlook 2007 and 2010) strip or ignore your doctype entirely.

Another section that is likely to be striped out is the head along with any style tags. For this reason it's best to use in-line styling on your markup. MailChimp provide a handy CSS Inliner Tool which can help do this once the design is complete.

Thursday, August 14, 2014

The worst javascript kludge ever

Due to limitations in a third party application, today I've had to create the most hideous workaround I've ever done. Essentially I needed to create a new instance of IE rather than just creating a new browser window. Using ActiveX I first attempted to create an IE instance directly.


When looking at the Task Manager I could see that the new window was still a child of the same parent process so I needed to go even further. I used ActiveX to get a shell then run iexplore.exe passing in the url I want to open:


It's for an internal site which should only be accessed by IE and does in fact do exactly what is needed but it still makes me shudder.

Friday, May 16, 2014

WTFilter now on the Atlassian Marketplace

Over the last week I've been updating the WTFilter plugin for Confluence. The last release was back in 2012 and it was unfinished. I figured that it's about time I finished it off and did a proper build.

It now filters comments as well as pages and blog posts both during creation and edits. It's also been updated for the latest versions of Confluence, anything since 5.0.

The new build, version 1.2.0, can now be downloaded from the Atlassian Marketplace.

Sunday, March 16, 2014

Elder Scrolls Online

Whilst checking my inbox earlier I found that I'd been sent a beta invite for Elder Scrolls Online. So I downloaded the Mac client and started the 22GB net install. Three and a half hours later...





I've only played about an hour but so far it's been impressive, except for the fact that the game crashed on me after completing the first mages guild quest. I'm not usually into MMO games but for this one I may make an exception.

Friday, February 28, 2014

How To: Use Bootstrap 3 in your Java Web App

Last year I built a Java webapp for work using JSF, Primefaces, Spring, PrettyFaces, the regular kind of stuff that is generally used when developing an app to run on Tomcat Server. I chose not to use the Primefaces styling, wanting to create my own styles making use of the LESS files that are used to generate Bootstraps CSS. It's worth noting that Primefaces does have various themes including a Bootstrap theme but it isn't quite the same. You can remove the Primefaces styling by placing the following in your web.xml:


The app originally used Bootstrap 2.3.2 and much has changed since then. I've spent the whole of today going through the process of upgrading to Bootstrap 3.1.1. For anyone wanting to update from version 2 there is a convenient page on the Bootstrap website: Migrating to v3.x. Apart from the obvious changes to classnames were are a few steps required to get the new version working properly.

The best way to make use of Twitter Bootstrap in a JSF web application is to use bootstraps LESS files. These should be added the same way as any other resources. When you come to build your application the 'lesscss-maven-plugin' can compile all the LESS files into a minified css file, which can be used in your template using the following:


When upgrading to Bootstrap 3 I found that the plugin was no longer able to compile Bootstraps LESS files as the used features that were not supported in the version of LESS that was used by the plugin. Fortunately this can be resolved in the configuration block for the plugin by manually providing a path to a more recent LESS version.


Add the fonts to '/webapp/resources/fonts' then edit 'glyphicons.less', change the @font-face block to match the following:
@font-face {
font-family: 'Glyphicons Halflings';
src: url("#{resource['fonts/glyphicons-halflings-regular.eot']}");
src: url("#{resource['fonts/glyphicons-halflings-regular.eot']}?#iefix") format('embedded-opentype'),
url("#{resource['fonts/glyphicons-halflings-regular.woff']}") format('woff'),
url("#{resource['fonts/glyphicons-halflings-regular.ttf']}") format('truetype'),
url("#{resource['fonts/glyphicons-halflings-regular.svg']}#glyphicons-halflingsregular") format('svg');
}
Using the steps provided here you should be all set to start theming you app using Bootstrap. The great thing about using the LESS files rather than just adding the compiled CSS to the app is that you can use the same mixins that Bootstrap provides as well as easy access to the global values used in variables.less.