This blog (as you can probably tell! is stale) and my new blog is at http://colinyates.co.uk
Archive for the ‘Uncategorized’ Category
http://colinyates.co.uk
August 27, 2015Another test
August 12, 2014About
this is another Markdown test….
Email test to wordpress using markdown
August 12, 2014#About
This is a test to see if emailing markdown _really_works.
If so, *woot*.
Automatic registration in zabbix
July 22, 2011Just a note to myself – don’t forget to include the “Add host” action when configuring automatic registration in (the most excellent) http://www.zabbix.com/
Maven, JIRA, Bamboo and release management – ARRHH!
July 15, 2011(this is a long one! Hope your sitting comfortably)
I just don’t get it, I really don’t – life just shouldn’t be this hard!
First, some (simplified and made-up) background:
- there is a single product
- we host the products and each client will always be running the latest production
- we care about the “mainline” code, the version currently being tested and the version currently in production
What I want is the following process:
- developer does stuff in git – enough is done to justify a roll-out. Maybe “enough” is “a single chunk of work” (i.e. continual deployment)
- some trigger starts the “test” process which means I now care about a set of release candidates that will eventually go into production as an atomic unit
- developers do some more stuff which should go into this release, so more stuff is added to the *existing* test process
- eventually testers say “yeah!” and all the current release candidates go into a single production build
Capturing line numbers from antlr parsing errors
July 15, 2011(copied from http://goobertron.wordpress.com/2011/07/01/capturing-line…parsing-errors/)
http://www.antlr.org/ is a fantastic tool for writing external parsers (http://martinfowler.com/bliki/DomainSpecificLanguage.html). Briefly, you define a set of tokens that your grammar should recognise and the grammar itself defining the, er, grammar 🙂 . ANTLR then generates two (Java in my case) artefacts, a lexer and a parser which you then use in your code. Inside the grammar you can define chunks of code that should be executed when various chunks of the grammar are recognised typically to build up your own representation of the input. Very similar to flex and yacc for the oldies amongst us.
If ever you need to process an external DSL then antlr is well worth checking out.
When ANTLR comes across a string of tokens that it doesn’t recognise it will throw out an error. You can capture these messages in a collection of strings, for example, which is useful to a point. I wanted a bit more context, in particular *where* the error occured (i.e. the position in the source text which wasn’t recognised) so I could highlight failures in the HTML editor (more on that in the future!).
Turns out to be trivial (excuse formatting…still learning wordpress…):
First, define a error container (in groovy):
public final class ParserValidationFailure {
String token int lineNumber int character }
then update the grammar (.g) file:
@parser::members {
private List<ParserValidationFailure> errors = new ArrayList<ParserValidationFailure>(); public void displayRecognitionError(String[] tokenNames, RecognitionException e) { super.displayRecognitionError(tokenNames, e); ParserValidationFailure failure = new ParserValidationFailure(); failure.setLineNumber(e.line); failure.setCharacter(e.charPositionInLine); failure.setToken(e.token.getText()); this.errors.add(failure); } public List<ParserValidationFailure> getErrors() { return errors; } }
What that snippet does is override the “displayRecognitionError” method, extracts the relevant information into our container and sticks it in a list. It also defines a new method which allows me to retrieve those errors later, to do with as I like.
And that’s it!
A convenient freemarker iterating directive
May 7, 2009We are seeing the same pattern of iterating lists within freemarker appearing:
<#list items as item>
<#if item_has_next>,
<#list>
this is quite verbose, and error prone so I have added a new directive called ‘iterate’, which automatically appends a separator (default is comma) if required.
<@iterate items ; item>
whatever I want to do with the ${item}.
<@iterate>
The directive:
<#macro iterate items separator=’,’>
<#list items as item>
<#nested item/>
<#if item_has_next>${separator}<!–#if–>
<#list>
<#macro>
To use, this you need to put it into a file (i.e. mystuff.ftl) and then include it within all the templates from which you want to use the new directive (i.e. all of them ;)).
My freemarker fu sucks a bit at this point. We have a web app so I included it in /WEB-INF/views/includes/mystuff.ftl (of course I didn’t call it that!). Unfortunately I needed to specify the relative path as I couldn’t figure out the fully qualified one – /WEB-INF/views/includes/mystuff.ftl and /views/includes/mystuff.ftl don’t work.
So, if my template is /WEB-INF/views/people/list.ftl then I need to do the following:
<#include ../includes/mystuff.ftl>
<@iterate people ; person>
Person ${person_index}: ${person.name}
<@iterate>
We are using <a href=”http://springframework.org/”>Spring</a> to configure Freemarker, which means using <a href=”http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurer.html”>FreeMarkerConfigurer</a>. Unfortunately, I don’t think this supports the ability to specify <a href=”http://freemarker.sourceforge.net/docs/api/freemarker/template/Configuration.html#setAutoIncludes%28java.util.List%29″>automatic includes</a> (similar to JSP preludes and codas), so I might need to write my own. No biggies.
test from ecto
May 7, 2009test post from ecto – fun fun fun.
My first post
October 21, 2005Welcome to Flock Developer Preview
So I just downloaded flock, hmm, what is this all about.
Will be trying it out over the next few weeks.
Hello world!
October 21, 2005Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!