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

Automated native2ascii character conversion for internationalisation of Atlassian add-ons


Normally, I write my internationalisation (i18n) files in UTF-8 format. This means that they are human readable.

Java i18n files however must be ISO-8859-1. If you don’t process them using something like native2ascii, accented and multibyte characters will return gobbledegook at best.

You can manually convert a single file manually using this command:

native2ascii -encoding utf-8 ./src/main/resources/ ./target/classes/

That’s tedious, so why not automate the process during the build?

Using native2ascii-maven-plugin

Luckily, there’s a maven plugin called native2ascii-maven-plugin. Its old, but does the job.

For Atlassian SDK p2 add-ons, use something like this:


            <!-- For Java 7+ compilation: -->

Your source files will be in sweet UTF-8 format and your target files will be mangled into ISO-8859-1 as Java requires.

How do you do this? Please add a comment below with details.

Update: Maven resource filtering can mess with the working of this plugin, so try with no resource filtering first 😉

Releasing a locked port on a Mac / OS X

Sometimes a port doesn’t release properly resulting in servers staring on non-standard ports.

How do you release the port? Easy, use this:

lsof -i :portnumber

Grab the resulting PID and kill the process. Use -9 if you really have to.

Here’s a “worked example”:

$ lsof -i :1990
java    2857 david   39u  IPv6 0x23ed6292526f5971      0t0  TCP *:stun-p1 (LISTEN)
$ kill -9 2857

Customising Atlassian Confluence with header photos


Header photos are all the rage (as my mother might say). Twitter has them. So does Facebook. Yup, even LinkedIn has them.

Confluence is a great platform for documentation, but what if you want to add extra some flare to your pages? Would a custom header photo be a good idea? Maybe so.

This post gives a simple method to do just that for pages that use the Default Theme.

In Confluence Admin | Configuration | User Macros create a new user macro:

## Macro: header-photo
## Author: David Simpson
## @param Photo:title=Header Photo|type=enum|enumValues=akabilk,captain_oblivion,rikpiks,renateflynn,grotan|default=red|desc=Choose a photo from one of these Flickr users
<script>AJS.toInit(function($){ $('body').addClass('header-photo photo-${paramPhoto}'); }); </script>

This gives you a user macro with some options to swap the background image between these images:

In Confluence Admin | Look and Feel | Stylesheet add the following:

 *  Uses the {header-photo} user macro to trigger the styles:

.header-photo #main-header {
	margin: -20px;
	padding: 20px;
	background: #69c;

.header-photo #title-text {
	padding-top: 40px

.header-photo #breadcrumbs a,
.header-photo #title-text a,
.header-photo .page-metadata,
.header-photo .page-metadata ul li a
	color: #fff;
	text-shadow: 2px 2px 5px #000;

/*** Hide these until mouseover/hover ***/
.header-photo #page-metadata-banner,
.header-photo #breadcrumbs,
.header-photo #navigation,
.header-photo .page-metadata {
	transition         : opacity .25s ease-in-out;
	-moz-transition    : opacity .25s ease-in-out;
	-webkit-transition : opacity .25s ease-in-out;
	opacity: 0;

/*** Display on mouseover/hover ***/
.header-photo #breadcrumbs:hover,
.header-photo #navigation:hover,
.header-photo .page-metadata:hover {
	opacity: 1;

.header-photo #main-header {
	background-size: cover;
	background-color: #000;
	background-position: 50% 50%;

/*** Each of these backgrounds has been selected from Flicker and uses a Creative Commons license ***/

/* From: */ #main-header {
	background: #000 url(//  no-repeat  ; 

/* From: */ #main-header {
	background-image:  url(//; 

/* From: */ #main-header {
	background-image: url(//; 

/* From: */ #main-header {
	background-image: url(//; 

/* From: */ #main-header {
	background-image: url(//; 

This is a simple bit of CSS that adds a different background to the page header based on the body class added in the user macro. I’ve purposefully chosen only dark backgrounds so that I can use a single text colour. Yes, that was quite lazy. You can embellish with more styles as required.

Here’s the macro configuration screen:


The macro parameter values in the dropdown match the CSS classes in the custom global stylesheet. It’s pretty straightforward.

I’ve really restricted the number of photos available here. This is just an example of how you could implement a feature like this. You could easily adapt this for custom photos on every space or every page if you really feel like it.

Perhaps random photos is the way forward for you? If so, you could do worse than

Secure development on Atlassian SDK using useHttps

Check the <useHttps>true</useHttps> configuration item. It appears to be a bit of a secret that could handle some more exposure. It starts Atlassian SDK running over HTTPS/SSL on port 443 without the need for a proxy server. Nice.

You can add it here:


You’ll need to start the server like so:

sudo atlas-run

Otherwise, you’ll likely get the following error trying to bind to port 443 as a non-root user:

[INFO] [talledLocalContainer] SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-443"]
[INFO] [talledLocalContainer] Permission denied <null>:443
[INFO] [talledLocalContainer] 	at
[INFO] [talledLocalContainer] 	at
[INFO] [talledLocalContainer] 	at org.apache.coyote.AbstractProtocol.init(
[INFO] [talledLocalContainer] 	at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(
[INFO] [talledLocalContainer] 	at org.apache.catalina.connector.Connector.initInternal(
[INFO] [talledLocalContainer] 	at org.apache.catalina.util.LifecycleBase.init(
[INFO] [talledLocalContainer] 	at org.apache.catalina.core.StandardService.initInternal(
[INFO] [talledLocalContainer] 	at org.apache.catalina.util.LifecycleBase.init(
[INFO] [talledLocalContainer] 	at org.apache.catalina.core.StandardServer.initInternal(
[INFO] [talledLocalContainer] 	at org.apache.catalina.util.LifecycleBase.init(
[INFO] [talledLocalContainer] 	at org.apache.catalina.startup.Catalina.load(
[INFO] [talledLocalContainer] 	at org.apache.catalina.startup.Catalina.load(
[INFO] [talledLocalContainer] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer] 	at sun.reflect.NativeMethodAccessorImpl.invoke(
[INFO] [talledLocalContainer] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
[INFO] [talledLocalContainer] 	at java.lang.reflect.Method.invoke(
[INFO] [talledLocalContainer] 	at org.apache.catalina.startup.Bootstrap.load(
[INFO] [talledLocalContainer] 	at org.apache.catalina.startup.Bootstrap.main(
[INFO] [talledLocalContainer] Caused by: Permission denied
[INFO] [talledLocalContainer] 	at Method)
[INFO] [talledLocalContainer] 	at
[INFO] [talledLocalContainer] 	at
[INFO] [talledLocalContainer] 	at<init>(
[INFO] [talledLocalContainer] 	at<init>(
[INFO] [talledLocalContainer] 	at<init>(
[INFO] [talledLocalContainer] 	at<init>(
[INFO] [talledLocalContainer] 	at
[INFO] [talledLocalContainer] 	at
[INFO] [talledLocalContainer] 	at
[INFO] [talledLocalContainer] 	... 17 more
[INFO] [talledLocalContainer] 

Does this work well?

Yes and no. It’s super easy to get going provided you remember about root permissions, but there are drawbacks.

You have to sudo on redeploys, and well, pretty much everything you do.

This seems like overkill though:

sudo atlas-package

atlas-install-plugin or sudo atlas-install-plugin doesn’t work as it tries to install to port 1990 for Confluence, 2990 for JIRA and so forth.

I ended up uploading the plugin via the UPM each time it was redeployed. That’s just rubbish.

This however, should work nicely:

sudo atlas-install-plugin --http-port 443

Will I continue to use this?

I’m not sure at the moment, unless its just for a very quick test or for JIRA development. Proxying with nginx is so easy. It’s setup and forget easy, at least for Confluence.