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

Tuesday, May 14, 2013

Timezone fix for Liferay

Ever been annoyed that liferay logs in GMT/UTC even though you might be somewhere else in the world and you system is correctly setup in terms of time and zone? Judging from google results a lot of people seems to want to change this for some reason...

This is because someone at Liferay decided it would be best to override the system time zone in their bundled tomcat configuration. Great idea!

To fix this silliness just edit your setenv.sh and remove the chunk of characters that is saying: -Duser.timezone=GMT

There you go. One step closer to a sane Liferay environment.

Friday, April 5, 2013

Adobe AIR on Ubuntu 12.10 64-bit

Somehow I always run into this, as much as I would like to avoid this kind of software platforms. There are a lot of posts out there on how to get Adobe AIR working on your linux installation, but I find them overly complicated. I will however refer to this post which gives some useful information.

My addition is that it is enough to do this
  • LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu ./AdobeAIRInstaller.bin  
You can safely ignore most of the advanced solutions you will find in your google results.

All I can say now is:
Pretty please, stop developing for Adobe AIR!






Wednesday, April 3, 2013

Broken mount.cifs after upgrade to ubuntu 12.10

After upgrading to Ubuntu 12.10 (Quantal Quetzal) my samba mounts stopped working and the mount commands only gave me this
mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
I did spend some time figuring this out, many google hits didn't give any hints whatsoever other than how to enable more verbose logging. And the solution was ridiculously simple.

In your fstab you probably have something like
/// cifs    user,noauto,noexec,noatime,uid=1000,file_mode=0644,dir_mode=0755
 Just remove noatime and you are good to go!

Tuesday, February 12, 2013

Play framework in an enterprise environment

I've been given the task of evaluating how well a play framwork application can fit inside an enterprise environment. And it is very "enterprise". We are talking maven artifacts, webservices, data models, spring and EJBs to the left and right and preference in terms of application servers, build scripts, development environments. And not to mention, large legacy code base that is "expensive" to touch.

So why the play framework? Well, to put it simple, web development in this environment is very clumsy to work with and time consuming (read: expensive) to work with. The evaluation of play framework is seen as an opportunity to reduce cost for simple GUI development. And perhaps even the developers will get motivated and ambitious again.

The points to evaluate are these:
  • Play 2 (Java)
  • Maven. Both builds and dependency management.
  • Dependency management (yes, SBT can pick up deps from our nexus)
  • Spring. Loading beans in dependencies.
  • Web service clients, mainly axis (maybe only)
  • EJBs. Both weblogic and JBoss.
  • JBoss AS 7
We'll see how far I get before I get other assignments...

Play 2, first impressions

I have two first impressions of the play framework.
  1. They've really decided to go their own way with Java web development, which is good, since we need a faster way of building these kinds of systems.
  2. It static. I'm talking about the java reserved word static. I've always hated it for various reasons I will not take up here. But I guess I'll have to deal with that.

Maven

There is a play2-maven-plugin which seems to handle everything judging from their homepage.

Building

I have tried running the project with maven, which works fine. However you will not get away from having a local play2 installation, which kind of complicates the work at the CI servers. This is the reason why we have maven, all our builds work everywhere there is maven and java. But not with play.

Dependencies

Play framework v2 uses the sbt (build tool for scala?) build system. For all the maven and ivy users out there this is great news, because sbt speaks maven. To add your dependencies to the project you can add them to the pom.xml. But it seems to me that that is not what matters most. You need to add them to the project/Build.scala file. Otherwise it wont work. You also need to add your internal repositories here, if needed. After having updated the Build.scala, you need to run play eclipsify or similar depending on your favourite IDE.

References

http://cescoffier.github.com/maven-play2-plugin/maven/snapshot/ 

Spring

The spring4play2 module makes this work just fine. You can use spring just like you do in any application. However, since play2 @Autowired or @Inject does not work anymore, maybe they'll show up later. And you cannot make play pick up ordinary controllers from Spring, as they are static. There are ways to do this but it complicates the structure of the application a little bit. I would have prefered if you could point Play to always get controllers from Spring, like the Spring object factory in Struts 2. As a small sidenote, the Spring4Play2 module does not seem to work with Play 2.1.

References

https://github.com/scott-phillips/Spring4Play2/blob/master/README.markdown

EJBs

Once the spring integration was proven useful the simplest way to wire in EJBs is through spring. This turned out to be too painful a task to finish off. In my case, we run JBoss AS 7, which would mean that we "only" need to add the jboss-as-client dependency and we should be ready to go. This is not the case. SBT freaks out due to the massive complexity of all the dependencies and whatnot that comes with the jboss-as-client. I wont spend any more time on this but "dream" back to the days we ran weblogic and had a manually composed jar based on the gigantic weblogic.jar that we added to our applications with maven.
You could probably do the same thing for JBoss. And it would probably work. But I'm giving up.

Web service clients

Simple enough. This is just a client library. We build and manage them with maven. Just add your deps and you are ready to go!

JBoss AS 7

One of the most important points. Can I run the application in JBoss? Well, yes you can, but with play framework version 2.0 you can only run it in the root context, but this should be possible with 2.1 [reference needed]. From the threads I read through I get the impression that play 2 isn't ready for the traditional enterprise environment yet.

References

https://play.lighthouseapp.com/projects/82401/tickets/8-war-packaging
http://stackoverflow.com/questions/12915199/deploy-play-2-app-to-jboss-7

Conclusion

I must say that play is a truly new take on web development for Java and the JVM. It feels like a trendbreaker. The very generic approach of Java tools has prevented easy and fast web development. Play framework is the answer to this. However, in the very complex existing enterprise environments the web systems must fit in. Web frontends must be able to speak with present components and systems using present integration technologies. Which it isn't really ready for. The technological hassle to go through to get things running can become costly and introduce too much risk. It might not be worth the effort.

Heres another writeup on the Play Framework 2 which touches similar points.
http://ricardozuasti.com/2012/web-development-frameworks-part-2-play-framework-2-0/