How-to use Docker with Gogland Go IDE

If you’re on macOS follow these steps.

Install socat

brew install socat

If you don’t have the brew command, checkout

Create TCP listener

socat -d -d TCP-L:8044,fork UNIX:/var/run/docker.sock

This creates a TCP port on 8044 that is mapped to the socket that Docker is running on.
Tip: In your ~/.bash_profile file make an alias to easily create the listener at anytime. Example:

alias dockertcp="socat -d -d TCP-L:8044,fork UNIX:/var/run/docker.sock"

Now anytime you want to create the listener simply run dockertcp from a Terminal.

Configure Gogland

To get to the Docker configuration go to Preferences / Build, Execution, Deployment / Docker.

Set your API URL to tcp://localhost:8044
I had to leave the Certificates folder blank in order for it to work for me.

And you should be all set!

BTW these instructions should work for all of Jetbrains IDE products including PyCharm, WebStorm, etc.

Update 2017-03-30

The latest Jetbrains products no longer require you to use SOCAT. Instead enter UNIX:/var/run/docker.sock directly in the API URL box.

Cross Platform Browser HTML5 Desktop Notifications

Yelling_protester_at_health_care_reform_town_hall_meeting_in_West_Hartford,_Connecticut,_2009-09-02You might have heard of window.webkitNotifications. It’s a crazy simple JavaScript API to do desktop notifications in webkit based browsers. It works great in Chrome and Safari.

But what about Firefox? It took a bit of digging for me to figure out how to make this work for all browsers that support HTML5 notifications. It’s actually not that hard once you have the correct information.

You can try it out using our new Drop Chat app which is designed for distributed teams needing to communicate. It works a lot like IRC except it’s web based and persistent. Which means when you come back all the messages are still there and you can keep going at any point. Still a work in progress but check it out on github!

So there is an official “living standard” available at and that’s what I’m basing my work on. The problem comes in one slight difference between the way webkit implements the standard and Firefox doing it a bit differently.

So the first thing you need to do is ask the user if it’s OK that you send them desktop notifications. It will prompt them with a permission request interface.
The code to do so is very simple:

Notification.requestPermission(function (perm) {
    if (perm == 'granted') {
        // Tell your app it's OK to send notifications

There is a callback function which returns one argument telling you if it was accepted or not. The value could either be “granted” which is what I’m checking for, or it could be “denied”.

Now the strange thing is, in Firefox you can run that code automatically without a problem. But in webkit user interaction is required for the requestPermission function to work. This is a good thing, I don’t understand why Firefox did not implement this check, but perhaps they will yet. I’ve only tested this in Firefox 22 beta 4. It does not work at all in Firefox 21 which is the currently stable release at the time of writing.

So the correct method would be to have a button that the user clicks on to enable notifications.

$('#mybtn').click(function () {
    Notification.requestPermission(function (perm) {
        if (perm == 'granted') {
            // Tell your app it's OK to send notifications

Now another problem (or maybe the 1st problem) is that according to the specification, there should be a variable called permission that is part of the Notification object. Well the problem is in Firefox it doesn’t exist at all, and in Chrome it only exists after you send a notification. So let’s send a notification:

try {
    test_notification = new Notification('This is a test!', {
       body: 'Just showing how HTML5 notifications work!',
       dir: "auto",
       lang: "",
       tag: 'test',
       icon: '/images/icon.png'
    console.log('Permission is: ' + test_notification.permission);
catch {
   // Browser does not support notifications

This time I’ve placed this code inside a try statement so that way if the browser does not support the Notification API, it doesn’t break everything. You should be doing the same thing with the requestPermission function, and design your app so if the browser does not support the API that functionality just doesn’t show up.

The code above is all you need to send a desktop notification.  As you can see I included a console.log line which should print to the console what permission the browser has granted this web page. Unfortunately on Firefox that currently prints “Permission is: undefined” but I expect that will change soon.

Of course if you’d like to see some code that actually uses this, checkout

How to Install PIL (Python Imaging Library) on Mac OS X (10.8)

python-logoIn the past I’ve used homebrew and MacPorts to install stuff like PIL or other Python libraries on OS X, but really it’s much simpler. And Apple already has everything needed to get it done without the need for those 3rd party options.

Just follow these steps:

  1. Install Xcode from the App Store.
  2. Open Xcode and open Xcode Preferences.
  3. Click on the Downloads tab, and you’ll see Command Line Tools. Click the Install button to install the Command Line Tools. (This provides gcc to compile PIL)
  4. Now open the Terminal app, and run the following commands:
    sudo easy_install pip
    sudo pip install PIL
  5. And that’s it!

I needed the Python Imaging Library for the Google App Engine SDK Image API. It’s so much neater to be able to install it like this verses the time it takes using Homebrew or MacPorts.

Have fun and happy development!

CSS Margin-Collapsing

Just working on a new web site design here and doing the CSS for it, and came across a little thing that I’ve came across many times before but never understood it. So I ran a query through Google to see what might come up, and came across this awesome article by Minz Meyer at Researchkitchen.

Just to sum it up, when working with block elements, when you’re playing with margins, the margin collapses when you add a border or padding via CSS. After reading that article I finally know why.

Hope it helps you if you’re looking for the same reasoning.