Extract release notes from Jira

If you are like me, you love automation. But sometimes, software and automation just don't like each other.

Today, I wanted to do a really simple thing. I wanted to retrieve the release notes for an EasyMock version on Jira. Seems easy enough. Jira has a great REST API that should allow to do that in two seconds.


Let's say you want the release notes for version 3.2. There is no REST API for the release notes. There is one for the versions. However, to get the details of a version, you need the version id. Which isn't 3.2 but an internal id. And there is no search available on the versions.

I've decided to keep things "simple" by not using any high level language. Only bash. I'm pretty sure Gradle could have helped me but I didn't want to put my arm in there yet.

So, first step, get the id by grepping it from the list of all versions.

# Seems complicated but I'm just adding a backslash before the . in 3.2
escaped_version=$(echo $version | sed "s/\([0-9]*\)\.\([0-9]*\)/\1\\\.\2/")

# Retrieve all versions and the id. Hoping a bit that the fields will stay in the same order
jira_version_id=$(curl --silent "http://jira.codehaus.org/rest/api/2/project/EASYMOCK/versions" | grep -o "\"id\":\"[0-9]*\",\"description\":\"EasyMock $escaped_version\"" | cut -d'"' -f4)
Good. Now I have the version id. But sadly, the API doesn't give the release notes for this version. But the Jira GUI does. When doing it by hand, you click on the version, the on the release notes, the you select the format wanted (text or html) and finally, you reach a page with a text area showing exactly what I want.

But, of course, there's no way to get only the content of the text area. So I now need to extract it from the page

# Get the page
release_notes=$(curl --silent "$release_notes_page")

# Extract the interesting page
echo "$release_notes" | sed -n "/<textarea rows=\"40\" cols=\"120\">/,/<\/textarea>/p" | grep -v "textarea

Et voilà!

BTW, there is a Jira opened in Atlassian bug tracker asking for this exact feature. Please vote.

My keyboards

I’ve lived in France for 14 years. I loved the food. I loved the wine (and learned a lot about it). Even the people are nicer than you would expect. I also picked, partly, the accent. Not because I wanted it. It just happened.

However, there is one thing I’ve always refused to adapt to, it’s the AZERTY keyboard. It makes me insane. Mostly because

  • The dot needs a shift key
  • The numbers need a shift key
  • The M is really far, you can’t do it with your left hand while pressing the Windows key
  • It’s impossible to put an accent on a capital letter (“Yes but we never put accents on a capital letter” “Yes but in Québec we do. So in Québec, "élodie".toUpperCase().toLowerCase() brings you back to "élodie". As expected
  • And last but not least, parenthesis, brackets and square brackets are not opened and closed with the same hand

Since I knew all this, I came to France with two Canadian French keyboards. The best keyboard to code is the English-US. But if you also want to write in French, the Canadian French layout is the best compromise.

One keyboard was used at home, one at work. I swapped them after 4 years because the work one was too used as you will see in the picture.


Both are now in the same state. After 7 years I bought two new ones. Sadly, the quality was not the same. The keys were too harsh to press. So I’ve replaced my work keyboard with a Logitech K800. At home, I’m typing on my laptop.

I took the picture by nostalgia before coming back to Montreal and leaving the two well-used keyboards behind.

Having a Mac

I normally use Windows and once in a while Ubuntu. I’m one of the rare persons who love Windows 8. It is by far the best version. Mainly because I’m a power user. I never use the tiled start screen. It’s like on a Mac. You should never use the application bar. You should use Spotlight. On Windows, you should use Windows+Q and Windows+W to find settings and applications. As soon as you’ve learned there two shortcuts, life is good.

Back to the Mac. These days, Windows constructors are a selling bad hardware. SSDs are rare, autonomy is bad, screen is ok (not wow), etc etc… Macs are strangely the best deal you can get. For instance, a Mac Book Air is the cheapest computer on which to run Windows efficiently. Doh.

So I ended up with a Mac and decided that before formatting it, I would try OS X (Maverick) just in case. Some stuff is good. It’s really fluid and it wakes up instantaneously for instance.

However, the guy who did the windowing should be exchanged with an hostage of IS. That should slow them down. I will spare him if he agrees to implement the following suggestions:

  • Cmd+Tab should bring to front the requested window. Always. It doesn’t matter is the window is minimized, in background or whatever. Just bring it in front
  • Cmd+Tab should allow to select between the multiple windows of an application. Or at least any other shortcut. Being forced to go to the Window menu is not a good option</li><li>Home should always go to the beginning of the line. End to the end. There’s no point in randomly changing this behavior depending on the application
  • Also, Cmd+Left or Fn+Left should always go home. Cmd+Right or Fn+Left should go at the end. Pick one, stick with it and it should work everywhere
  • I should be able to lock my workstation immediately but also to have it locked automatically in 15 minutes. Those are two different needs
  • Why having virtual desktop for only maximized windows? Why can’t I create as many desktops as I want and put whatever I want on them?
  • Being able to dock windows on the left or right natively would be nice. I currently use BetterTouchTool for that
  • We should really be able to hibernate for real. Even is it means that the computer will wake up more slowly in that case.
  • Nothing is worst than leaving the computer to rest for the night and to discover in the morning that the battery ran out magically
  • The Windows ca-fr keyboard was perfect. Why moving the brackets and square brackets to somewhere I can’t reach them? And don’t get me started on the azerty on mac. It’s a great feat to turn the worst keyboard on Earth into something even worse…

That would be a good start. I’ve also replaced the shell but I will talk about that another time.

New EasyMock website is out!

After years having the most vintage open source website out there, the EasyMock team is proud to announce that the new website is up and running.

Please tell us what you think. Directly on the pages using Disqus, in comment of this blog post, by twitter (@henri_tremblay) or on Gitter

Next steps:

  • Be able to deliver more quickly
  • Deliver EasyMock 3.3 ASAP!

Meanwhile, enjoy the website.

Université de la performance

I just published on Slideshare the slide from the Université de la Performance done at Devoxx France 2014.

Obviously it’s in French and much less interesting without the demos. So the video is available on YouTube.

Collisions on a Switch on Strings

Today, I felt on a really nice blog post about how a switch is implemented for String under the hood.

It basically explains that the switch is implemented on the String hash code. Easy and efficient. But it made me wondering what would happen if the was a collision in the hash codes. By that I mean: What happen if you got two cases containing strings having the same hash code?

To test it, I've created such a switch. First I was needing to found two strings with the same hash code. The way the hash code of calculate for a string is quite simple. It loops over the characters, adding their value to the previous result multiplied by 31. So, doing a bit of algebra, the two characters strings below will be in collision.

int c1 = some_character, c2 = some_other_character;
int c3 = c1-1, c4 = 31*c1+c2-31*c3;

String s1 = new String(new char[] {(char)c1, (char)c2});
String s2 = new String(new char[] {(char)c3, (char)c4});
From where I just had to create a switch with the result. For instance "10" and "0O" both have a hash code of 1567.

switch (args[0]) {
case "10":
case "0O":
case "123":

Decompiling this code brings a surprising result.

String str1 = args[0];int i = -1;
switch (str1.hashCode())
case 1567:
  if (str1.equals("0O")) {
    i = 1;
  } else if (str1.equals("10")) {
    i = 0;
case 48690:
  if (str1.equals("123")) {
    i = 2;
switch (i)
case 0:
case 1:
case 2:

So, in case of collision, the compiler changes the strategy and add a redirection. It is worthy to mention that the redirection applies even to cases that are not in collision (like "123" in the example).

So, unless the JVM manage to optimize this at runtime (which is highly possible), if we are unlucky enough to have a collision in your switch, you code will be slower than if there wasn't any.

New file shortcut

There is no way to create a new file in Windows explorer using a shortcut. You can Ctrl+Shift+N to create a new folder but strangely nothing to create a file.

The solution is to use AutoHotKey and a script. This one works on Windows 8. It was adapted from here.

#IfWinActive ahk_class CabinetWClass

; Create new file in Explorer


WinGetText, full_path, A
StringSplit, word_array, full_path, `n
Loop, %word_array0%
IfInString, word_array%A_Index%, Address
full_path := word_array%A_Index%
full_path := RegExReplace(full_path, "^Address: ", "")
StringReplace, full_path, full_path, `r, , all

IfInString full_path, \
NoFile = 0
IfExist %full_path%\NewTextFile%NoFile%.txt
FileAppend, ,%full_path%\NewTextFile%NoFile%.txt

Windows hard links

As on Unix, it is also possible on Windows to create a hard link to a file. I'm using this feature to backup in Dropbox files that need to be placed in some other directory. For instance, my ssh config file.

Here's how you do it from a cmd:

mklink /h %USERPROFILE%\Dropbox\.ssh\config %USERPROFILE%\.ssh\config

Note that there is no way to visualy know that it is a hard link. You have to guess and confirm your intuition doing:

fsutil hardlink list config

Also, if you are wondering, delete one of the file doesn't delete the file. You need to delete all links to it to get rid of it.

Ctrl+V in cmd

I've been using this for a while in fact but thought it was useful enough to be told.

A really annoying thing on Windows is that you can't Ctrl+V in a cmd. You can anywhere else but not there.

A nice piece of software named AutoHotkey can solve this. It allows you to script (in a strange language sadly) hot keys anywhere in Windows.

For Ctrl+V, the following script does the trick:

#IfWinActive ahk_class ConsoleWindowClass
SendInput {Raw}%clipboard%

UPDATE: In fact SendIput has encoding issue. So I'm now using Send !{Space}ep which simulate an access to the system menu and then select the paste by typing 'e' and 'p'. Not that is works in English. You might have to change the letters to fit your OS language.


I’m not originally a web developer. But I’m doing more and more of it. I’ve discovered LiveReload some time ago and became addicted to it.

By that I mean that I’m putting it on pretty much every web page I’m working on. Getting instant feedback is great.

I’m using Grunt to launch it. So I’m now having two files that I’m copying around. They are pretty basic but could be useful so I thought I could share.


  "name": "livereload-gruntjs",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "~0.4.2",
    "load-grunt-tasks": "~0.3.0",
    "requirejs": "~2.1.11",
    "grunt-contrib-connect": "~0.6.0",
    "grunt-contrib-watch": "~0.5.3"


module.exports = function(grunt) {


    pkg: grunt.file.readJSON('package.json'),

    connect: {
      options: {
        hostname: 'localhost',
        port: 9001,
        livereload: 35729
      livereload: {
        options: {
          open: true,
          base: 'app'

    watch: {
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        files: [


  grunt.registerTask('serve', [