Adding styles to the Confluence editor

I’ve tried to add styles to the Confluence editor. It wouldn’t take them. Perhaps one of Atlassian’s values is “Don’t f@@k the editor”.

    <web-resource name="editor-scripts" key="editor-scripts">
        <resource name="editor-templates.js" type="download" location="assets/js/editor-templates.js" />
        <!-- // TODO: Check whether I need a context here -->

    <web-resource name="editor-styles" key="editor-styles">
        <resource name="css/confluence-editor.css" type="download" location="assets/css/confluence-editor.css"/>

        <!-- // TODO: Check whether I need all the dependencies here -->

My confluence-editor.css styles just wouldn’t be accepted. Javascript injection worked just fine though. Perhaps I could use JS to inject my styles?

Yup. Adding this to my editor-templates.js file worked a treat:

var editorCss = AJS.params.staticResourceUrlPrefix + '/download/resources/me.davidsimpson.confluence.addon.awesome-addon:editor-styles/css/confluence-editor.css';

if (AJS.params.isDevMode) {
    editorCss = editorCss + '?_=' +;

$('#wysiwygTextarea_ifr').contents().find('head').append('<link type="text/css" rel="stylesheet" href="' + editorCss + '" media="all">');

Note the cache busting timestamp for local development.

Why is my machine contacting

I’ve been looking at the network traffic and noticed a lot of calls from one machine to an address I’d never heard of:

Screen Shot 2015-11-16 at 00.59.42

Information on this seemed somewhat sketchy until I spotted this page on Multicast Addresses

ALL-SYSTEMS.MCAST.NET All systems on the local subnet.

What? All the machines on my local network? Really?

Pinging it confirmed this:

$ ping
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=64 time=0.103 ms
64 bytes from icmp_seq=0 ttl=64 time=14.788 ms
64 bytes from icmp_seq=0 ttl=64 time=239.376 ms
64 bytes from icmp_seq=0 ttl=64 time=256.191 ms
64 bytes from icmp_seq=1 ttl=64 time=50.762 ms

The machine accessing is running a DLNA server, so it appears to be broadcasting its presence to all the machines on the local network. Panic over.

Installing OpenWRT on a Linksys WRT1900ACS


Linksys recently released their WRT1900ACS router. Linksys said it collaborated with Marvell to ensure full open source support in the latest version of OpenWrt’s Chaos Calmer release (15.05) at launch. I’ve not seen many OpenWRT compatible routers on the market in the UK, so my interest was piqued. It seems like a decent (though expensive) router, so I thought I’d give it a go and install OpenWRT.

The WRT1900ACS page on the OpenWRT wiki was a little vague about which version of the firmware to install, but stated that the router had Marvell Armada 385 & Shelby hardware, so I used the openwrt-mvebu-armada-385-linksys-shelby-squashfs-factory.img image to flash the firmware. This worked, so I’ve document it here for others.

This merely documents what worked for me. If you brick your router following these instructions, I’m sorry, but you do so at your own risk.

Installing OpenWRT

Download the OpenWRT firmware: openwrt-mvebu-armada-385-linksys-shelby-squashfs-factory.img

Connect to the router with the supplied network cable.

Login to The password is admin. Don’t use the setup wizard. Specify manual setup.

Browse to Connectivity and in Router Firmware Update click on Manual > Select File


Select the previously downloaded openwrt-mvebu-armada-385-linksys-shelby-squashfs-factor.img, then click on Start.


Click on Yes in the Unrecognized file name modal:


Click on Yes in the Update firmware modal:


Click on OK in the Reboot Router modal:


Almost immediately, you’ll be able to browse to and see that OpenWrt has been installed:


It should ask you to set a password at this point. (I forgot to get a screenshot of that).

By default, the wifi is disabled, but it’s really straightforward to enable and secure in the admin UI.

You’ll also be able to ssh into your router. This is where the fun begins…


Secure your internet access with a VPN

The next sensible step is to setup your VPN connection. I use Private Internet Access as my VPN provider, so my VPN setup is tailored to PIA. This is incredibly easy to configure, thanks to previous work by Logan Marchione and Andrew Brereton.

Save your eyes, enable the Bootstrap theme

Follow the script and you’ll be done in a couple of minutes.

One last thing, go into System | System | Language and Styles and enable the Bootstrap theme. It means that your admin UI is no longer an eyesore.

It turns this:

Screen Shot 2015-11-16 at 00.30.14

Into this:

Screen Shot 2015-11-16 at 00.32.48

Separation of concerns for JIRA gadgets

This blog post started out as an answer to a Stack Overflow question.

For my gadgets, I separate out all the XML, HTML, JavaScript and CSS from the atlassian-plugin.xml.

The setup is initially more complex, but once you’ve got this correct, the separation of concerns is much nicer than mangling everything into the atlassian-plugin.xml file.

The relative paths on the other hand do indeed look crazy.

My file system looks like this:

- resources/
    - gadgets/
        - css/
            - example.css
        - html/
            - example.html
        - js/
            - example.js
        - examaple-gadget.xml
    - atlassian-plugin.xml

In /resources/atlassian-plugin.xml:

<!-- add our web resources -->
<web-resource key="${project.artifactId}-resources" name="${project.artifactId} Web Resources">
    <resource type="download" name="example-gadgets/" location="/gadgets"/>

<gadget name="Example JIRA Gadget" i18n-name-key="" key="example-jira-gadget" location="gadgets/example-gadget.xml">
    <!-- hosted at: /rest/gadgets/1.0/g/${project.groupId}.${project.artifactId}:example-gadgets/gadgets/example-gadget.xml -->
    <description key="jira-query-gadget.description">The JIRA Query Gadget Plugin</description>

In /resources/gadgets/example-gadget.xml (replace ${project.artifactId} & ${project.groupId} with the correct value):

<?xml version="1.0" encoding="UTF-8" ?>
    <Content type="html" view="example.view" preferred_width="100%" href="../../../../../../download/resources/${project.groupId}.${project.artifactId}:${project.artifactId}-resources/gadgets/html/example.html"/>

In /resources/gadgets/html/example.html (replace ${project.artifactId} & ${project.groupId} with the correct value):

<!DOCTYPE html>
        <!--   added ../../../../../../download/resources/${project.groupId}.${project.artifactId}:${project.artifactId}-resources/gadgets/ to most relative links -->
        <link  href="../../../../../../download/resources/${project.groupId}.${project.artifactId}:${project.artifactId}-resources/gadgets/css/example.css" type="text/css" rel="stylesheet">
        <script src="../../../../../../download/resources/${project.groupId}.${project.artifactId}:${project.artifactId}-resources/gadgets/js/example.js" type="text/javascript" charset="utf-8"></script>

From this somewhat excessing starting point, you’ll have content, behaviour and styles completely separated. If that floats your boat, then you’ll be happy.

How to format a disk to FAT32 on a Mac / OS X

From Alex Plumb on superuser:

If you’re comfortable with using the Terminal, try this:

First, look at the partition table by running this command:

diskutil list

You should see something like this:

#:                       TYPE NAME                    SIZE       IDENTIFIER
0:      GUID_partition_scheme                        *16.0 GB    disk1
1:                        EFI                         209.7 MB   disk1s1
2:                  Apple_HFS Example                 15.7 GB    disk1s2

The partition we want to change is /dev/disk1.

We want to change the device to an MBR-formatted FAT32 partition.
To do that, run this command:

sudo diskutil eraseDisk FAT32 NAME< MBRFormat /dev/disk1

where NAME is the name you want to give to the disk.

As mentioned in the comments, you cannot put square brackets into the volume’s name lest things mess up. To avoid having everything fail, simply ensure that there are no square brackets in the FAT32 volume’s new name.

Switching Java versions easily on a Mac


I do a lot of development using Java 7 and recently needed to start using Java 8.

The quickest way I know to update to the latest Java uses homebrew:

brew tap caskroom/cask
brew install brew-cask
brew cask install java

I now need an easy way to switch back and forth between Java 7 & 8.

Adding this to your ~/.bash_profile or ~/.profile does the trick:

function setjdk() {
  if [ $# -ne 0 ]; then
   removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin'
   if [ -n "${JAVA_HOME+x}" ]; then
    removeFromPath $JAVA_HOME
   export JAVA_HOME=`/usr/libexec/java_home -v $@`
   export PATH=$JAVA_HOME/bin:$PATH
 function removeFromPath() {
  export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")

# set your default version
setjdk 1.7


This script cunningly uses /usr/libexec/java_home -v x.y to do the hard lifting.

I can now easily swap between Java versions as seen below:

david$ setjdk 1.6
david$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

david$ setjdk 1.7
david$ java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

david$ setjdk 1.8
david$ java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

This is a nice simple way to swap versions and is at least good enough for now.

Aside: I also tried out jenv which promises much, but wouldn’t accept my versions of Java when I tried it out.

Using wsadmin to quickly restart IBM Connections (or WebSphere) applications

Restarting WebSphere applications using the wsadmin tool feels much faster than through the WebSphere Integrated Solutions Console.

If you’ve already invoked wsadmin to update a configuration then this is especially true. No navigating through menus to find the right item, just a “simple” command line and the application quickly restarts.

Here’s how…

Invoke wsadmin:

cd /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin
./ -lang jython -user icadmin -password PASSWORD_HERE

If you can’t remember the name of your applications, list the applications installed.


This returns a somewhat unattractive string:

'Activities\nBlogs\nCommon\nCommunities\nConnectionsProxy\nDefaultApplication\nDogear\nEditLiveForConnections\nExtensions\nFileNetEngine\nFiles\nForums\nHelp\nHomepage\nMetrics\nMobile\nMobile Administration\nModeration\nNews\nProfiles\nPushNotification\nSearch\nWebSphereOauth20SP\nWidgetContainer\nWikis\nnavigator\noEmbed'

It’s better formatted:

Mobile Administration

If you’ve recently changed any configurations, you may want to update the IBM Connections configuration and synchronise nodes at this point:


Choose one of the applications, for example Communities, then stop and start the application:

AdminControl.invoke(appManager, "stopApplication", "Communities")
AdminControl.invoke(appManager, "startApplication", "Communities")

This is pretty quick. Often no more than 30 seconds.

Speeding up the Atlassian SDK with JRebel


JRebel saves compile time. It “Instantly reload changes to Java classes” – that’s the marketing talk anyway.

The theory is great. Anything has to be better than the randomness of Atlassian’s FastDev or atlas-cli, right? If it’s really worth the hype, I want to use it with the Atlassian SDK and speed up my development time. Here’s a short tutorial for JIRA development. Scroll down to the video if you want a demo.

Getting up and running…

Here’s my quick “how to” get up and running.
Get the jrebel.jar and save it somewhere – like /opt/jrebel/jrebel.jar

Add the jvmArgs in the plugin to point at said file (and turn off fast dev)…


Add the jrebel-maven-plugin under build > plugins (see details of what does what here).


Run atlas-run or atlas-debug on the command line, checking for any errors.

In Intelli-J, enable automatic compiling on code change by checking Make project build automatically:


Change something in your code & reload the page.

All is automatically updated. Immediately. No more waiting for code compile changes.

Check this quick video demo:

The good news – it’s pretty cool. The bad news – JRebel costs around $365 per seat per year. But think of all the time you save.

Runing a web server in the current directory

Sometimes I want to run a simple web server in the current directory.

There are many ways to do this. Here’s here’s one using npm / serve .


npm install serve -g
. ~/.profile


cd /path/to/directory

You get this message:

serving /path/to/directory on port 3000

You can now access the directory in a browser:



There are more options available:

serve -h

  Usage: serve [options] [dir]


    -h, --help                output usage information
    -V, --version             output the version number
    -a, --auth <user>:<pass>  specify basic auth credentials
    -F, --format <fmt>        specify the log format string
    -p, --port <port>         specify the port [3000]
    -H, --hidden              enable hidden file serving
    -S, --no-stylus           disable stylus rendering
    -J, --no-jade             disable jade rendering
        --no-less             disable less css rendering
    -I, --no-icons            disable icons
    -L, --no-logs             disable request logging
    -D, --no-dirs             disable directory serving
    -f, --favicon <path>      serve the given favicon
    -C, --cors                allows cross origin access serving
        --compress            gzip or deflate the response
        --exec <cmd>          execute command on each request