Juniper’s Network Connect on Ubuntu

Getting Juniper’s Network Connect VPN client software running on Ubuntu installations has always been a huge pain. Since every time I do a fresh Ubuntu installation I have to scour the internet for the steps to take to get this running and I never find the information in one location I’ve decided to document the steps. Since I do a decent amount of Java development I like to run Oracle’s distribution of Java rather than OpenJDK.

1. Install JDK 7 or 8 with the webupd8 PPA.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

2. Download the 32-bit JDK tar.gz package from Oracle:

3. Extract the archive downloaded from Oracle’s site to another directory. For this blog post I’ll be using /opt/jdk8_x86/

mkdir -p /opt/jdk8_x86/
tar -zxvf jdk-8u5-linux-i586.tar.gz -C /opt/jdk8_x86

Note: If you download the a different version you’ll have to change the 8u5 part here and in later parts of this blog.

4. Add the 32-bit JDK to update-alternatives

sudo update-alternatives --install /usr/bin/java java /opt/jdk8_x86/jdk1.8.0_05/bin/java 10

5. Ensure the 64-bit java is selected by default (Network Connect simply uses update-alternatives to find the 32-bit Java installation when it runs)

sudo update-alternatives --config java

6. Install some required 32 bit libraries. I’m not actually sure if all these need to be installed but I found the list on this article so it’s what I’m using for now.

sudo apt-get install libstdc++6:i386 lib32z1 lib32ncurses5 lib32bz2-1.0 libxext6:i386 libxrender1:i386 libxtst6:i386 libxi6:i386

7. Symlink update-alternatives if running Ubuntu 14.04. Apparantly Juniper looks for /usr/sbin/update-alternatives and Ubuntu 14.04 sticks it in /usr/bin, so we need to make a symlink.

sudo ln -s /usr/bin/update-alternatives /usr/sbin/update-alternatives

Custom PyQt4 Widget Plugin – Qt Designer

Reference Code –

Why make custom widgets?

I’ve been working on a GUI MySQL client for a while now using PyQt for the GUI and, until now, have been at odds with how I want to proceed with separating my view and business logic.  I really enjoy using the Qt Designer to build the layouts for me but came very close to abandoning it and building all of my layouts programmatically in order to be able to subclass the Qt GUI elements to stuff view related code directly into them rather than wrapping the classes output from the Qt Designer.  Luckily I stumbled across a rather simple way to build custom widgets that can be used in Qt Designer without touching C++.

TestWidget End Game

The widget I created to test this out is simply a QLabel which I added a method to, ‘testMethod’, that takes no arguments and prints a message to standard out.  I had some trouble finding a simple piece of example code when Googling around so this one just contains the bare minimum to get up and running.

Writing The Codez

All file paths I reference below will be relative to the root of the GitHub repo linked above.

The code is pretty small – the actual Qt Designer plugin only requires two files. Let’s start with the widget itself: widget/

from PyQt4.QtGui import QLabel

class TestWidget(QLabel):
	def testMethod(self):
		print 'Just adding a method to our QLabel'

All this file is doing is subclassing the QLabel and adding the testMethod method.

The actual Qt Designer plugin contains a bit more meat. It is basically a bunch of metadata to tell Qt Designer what to display in the interface. I’m only overriding the bare minimum number of methods here to make it work.


from PyQt4.QtDesigner import QPyDesignerCustomWidgetPlugin
from PyQt4.QtGui import QIcon
from testwidget import TestWidget

class TestWidgetPlugin(QPyDesignerCustomWidgetPlugin):
	def __init__(self, parent=None):

	def name(self):
		return 'TestWidget'

	def group(self):
		return 'Fapiko.Com Example Widgets'

	def icon(self):
		return QIcon()

	def isContainer(self):
		return False

	def includeFile(self):
		return 'testwidget'

	def toolTip(self):
		return 'Arnold Facepalmer'

	def whatsThis(self):
		return 'Facepalm all day'

	def createWidget(self, parent):
		return TestWidget(parent)

I’ll briefly describe each of the methods and what they do:

  • name – Sets the name of the widget which appears in Qt Designer
  • group – Adds a category which widgets will be grouped into in the Qt Designer widget panel
  • icon – Sets the icon to display in the Qt Designer for this widget. Returning an empty QIcon as I’m doing here will cause it to display the default icon.
  • isContainer – Returning True from this method will allow you to add widgets to this widget
  • includeFile – The name of the file containing the actual code for the widget to be imported.
  • createWidget – Initialization code used when instantiating the widget.

Helper Files

I’ve included a few helper files in the repo as well. Here’s a brief description of what they do:

  • – This guy simplifies setting up the PYQTDESIGNERPATH and PYTHONPATH environment variables, which let Qt Designer know where to look for the plugin code, before launching it.
  • main_window.ui – This is an example dialog created in Qt Designer which contains our custom widget.
  • – Running this shell script will use pyuic4 (provided by the ‘pyqt4-dev-tools’ package on Ubuntu 13.04) to convert our Qt Designer .ui file into python code.
  • – A demo script that displays the example dialog and calls the test method to verify that subclassing the QLabel worked.


I had a bit of difficulty getting the Qt Designer to recognize my plugins until I found that I was missing a package. On Ubuntu 13.04 the package I needed was: python-qt4-dev

ZeroMQ PubSub in NodeJS

Alternate language examples: Python

Yesterday, I posted an entry about how to implement the publish-subscribe model using ZeroMQ in Python.  Today I’ve gone ahead and ported that example over to NodeJS.  You can refer to the original article for a more detailed explanation of what’s going on, I’m simply going to publish the source code below.


var zeromq = require('zmq');

var socket = zeromq.socket('pub');

socket.bind('tcp://', function(error) {

    if (error) {

    console.log("Listening on port 2001");

    setInterval(function() {

        var face = "Facepalmer";
        var randNumber = Math.floor(Math.random() *
        var message = face + " " + randNumber;

        socket.send("ARNOLD " + message);
        // This message should be dropped on the client
        socket.send("FACEPALMER ARNOLD " + message);
        socket.send("ARNOLDFACEPALMER " + message);

    }, 1000);



var zeromq = require('zmq');

var sock = zeromq.socket('sub');

sock.on('message', function(data) {

ZeroMQ PubSub in Python

Alternate language examples: NodeJS

I’ve recently started playing around with ØMQ (ZeroMQ) and have found it an incredibly useful and easy to use tool for messaging.  This article will describe how to quickly setup a client and server demonstration using the publish-subscribe pattern in Python.

Let’s go ahead and start with our server code:

import zmq
import random
from time import sleep

context = zmq.Context()
socket = context.socket(zmq.PUB)

while True:
	face = "Facepalmer"
	randNumber = random.randrange(0,999999)

	# This guy should show up to the client
	socket.send("ARNOLD %s %d" % (face, randNumber))

	# This will be dropped by the client as it's
	# filtering messages where ARNOLD is the first
	# string
	socket.send("FACEPALMER ARNOLD %s %d" % (face,

	# This will also show up in the client as the
	# filter is simply checking to see that the pattern
	# matches the front of the string, you would need
	# to add a space to the consumer's filter to make
	# this message get dropped
	socket.send("ARNOLDFACEPALMER %s %d" % (face,


The server here is simply binding to port 2000 waiting for some subscribers to take its messages.  It constantly spits out the three messages to all subscribing consumers.

Now for the client code:

import zmq

context = zmq.Context()

sock = context.socket(zmq.SUB)

# This tells the consumer to drop all messages which
# don't begin with the text ARNOLD
sock.setsockopt(zmq.SUBSCRIBE, 'ARNOLD')

while True:
	input = sock.recv()
	print input

If we run both the server and then the client, we should see output similar to this:

ARNOLD Facepalmer 490438
ARNOLDFACEPALMER Facepalmer 490438
ARNOLD Facepalmer 16614
ARNOLD Facepalmer 353308
ARNOLDFACEPALMER Facepalmer 353308
ARNOLD Facepalmer 740853
ARNOLDFACEPALMER Facepalmer 740853
ARNOLD Facepalmer 541693
ARNOLDFACEPALMER Facepalmer 541693
ARNOLD Facepalmer 560235
ARNOLDFACEPALMER Facepalmer 560235

You may notice that when stopping and starting the server, the client seamlessly picks it up again and continues printing out the messages it receives to the console. Pretty handy, eh? No longer is there a need to write client and server code to handle the TCP socket state, ZeroMQ will handle the hard parts for you!