Monday, November 24, 2014

Broken VPN in Ubuntu 14.10 Utopic Unicorn

I spent a few hours today trying to figure out why my Open VPN connections refused to work. The only thing I got as a lead was a rather useless error message.

Failed to request VPN secrets #2: (6) No agents were available for this request.

Google only pointed by to obscure old bug reports or the Arch Linux fix. But the Arch fix was of no use in Ubuntu. Until finally I stumbled upon a solution (which I have now lost track of). It's rather simple, but be careful!

sudo apt-get remove --purge network-manager-gnome

Now reboot. Hopefully you'll come back online but without the widget when logging back in. Then, just reinstall the package.

sudo apt-get install network-manager-gnome

As a precaution, you can download the package, just in case your network doesn't work without the user widget.

Sunday, August 24, 2014

Tracking outbound links with google analytics, without annoying middle-clickers

As a quick and dirty solution I just added google analytics tracking of outbound links. It was really easy as I just borrowed a piece of code from this blog (kudos!). Everything went fine and the stats started coming in.

But when I later visited the site myself I realized something awful. Since I'm a obsessive middle-clicker opening all potentially interesting links in new tabs I ran into the issue immediately. It opens my middle-clicks in the same tab, transforming my middle-clicks to left-clicks.

Further googling explained everything. Many have written scripts like the one I picked and some have already considered this issue. So I read them all and improved the script I had stolen already. Here it is. Please comment if you think there's something wrong with it!


(function($) {
  "use strict";
  // current page host
  var baseURI = window.location.host;
  // click event on body
  $("body").on("click", function(e) {
    // abandon if link already aborted or analytics is not available
    if (e.isDefaultPrevented() || typeof ga !== "function") return;
    // abandon if no active link or link within domain
    var link = $(e.target).closest("a");
    if (link.length != 1 || baseURI == link[0].host) return;
    var normalClick = !e.metaKey && !e.crtlKey && e.which == 1;
    var href = link[0].href;
    var opts = {'hitType': 'event','eventCategory': 'outbound',
      'eventAction': 'link','eventLabel': href
    }
    if (normalClick) {
     // cancel event and record outbound link
     { opts.hitCallback = loadPage };
     e.preventDefault();
     ga('send', opts);
     // redirect after one second if recording takes too long
     setTimeout(loadPage, 1000);
    } else {
     // Just send the event
     ga('send', opts);
    }
    // redirect to outbound page
    function loadPage() {
      document.location = href;
    }
  });
})(jQuery);

Monday, August 11, 2014

Menu icons in eclipse linux

This very tiny issue in the linux version of Eclipse has bugged me for a couple of years. Despite the bug reports and suggested corrections I have not been able to get it to work. But today I somehow managed to figure it out. And the solution is very simple.

dconf write /org/gnome/desktop/interface/menus-have-icons true