I find myself doing this kind of operation quite often, namely when I decorate some object generated from JSON retrieved from a server and want to send it back after changing it client-side. This syntax makes it oh-so-simple!

This was quite annoying, especially since I failed at googling a cure for it.

What happens: whenever you type “'t” in a comment on a Java file in Idea followed by a whitespace, it gets replaced with “<></>“, and whatever you type after that is added as if it were an HTML tag pair.

If you actually pause after typing “'t” (which I don’t know why it’s something I never did until now), you’ll notice IntelliJ’s auto-complete popup telling you what’s going on:

It turns out that “t” is the shortcut for “tag pair”, which might be awesome for HTML coding, but it’s not as nice when you’re writing comments.

followed by a Java stack trace. I noticed a suspicious line in that stack trace:

at org.eclipse.jetty.webapp.MetaData.setWebXml(MetaData.java:170)

interesting. It looked like something was wrong with Jenkins’ web.xml, so I checked /var/cache/jenkins/war/WEB-INF/web.xml and, surprise surprise… it was empty!

I unpacked an old jenkins.war that I had, and copied its web.xml over, restarting the service. A-ha! The logged error changed. Unfortunately, it still wouldn’t start, but it made me look for “jenkins corrupted /var/cache” which finally lead me to this bug report.

“Dang!” – I thought – “is that it?”.

Moved the old /var/cache/jenkins away, created a new empty directory, and set user jenkins as its owner:

I’m so glad I found out how to fix this, because it’s an issue that just kept popping up every now and then.

The issue is this: for some applications, especially (but not necessarily) after upgrades, Unity somehow decides to spawn a new icon every time the app is launched. Thus, you end up with two identical (or in the case of upgrades, very similar) versions of the icon in the Unity launchbar, with the additional annoyance of having one work as a window switcher, and the other working as a new launcher.

Here’s how to fix that.

1. Locate your application’s .desktop file

In Ubuntu this is either inside ~/.local/share/applications or inside /usr/share/applications.

One problem you may have is that you have more than one .desktop file for the same application. If that is the case, remove one (probably the older one).

The .desktop files don’t necessarily match the application name that’s shown when you hover on the launcher (wonderful design idea, duh), so you might need to use grep to find the file.

For example, to find my PyCharm launcher, I had to execute

ls ~/.local/share/applications | grep -i charm

which returned jetbrains-pycharm.desktop, the file that I was looking for.

Removing duplicate .desktop files might be enough to solve the issue, so try launching your app to see if that fixed it. Otherwise, read on.

2. Find your application’s WM_CLASS

This was the core of the issue in my case. To match a window to an application, Unity looks for the window’s WM_CLASS.

To find what your application’s WM_CLASS is, launch your app and run this in a terminal (using a small window for the terminal, leaving your app visible in the background, you’ll see why in a moment):

xprop WM_CLASS

your mouse cursor will turn into a crosshair, and you must click anywhere on your application’s window. You will find something like this in your terminal:

WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "jetbrains-pycharm-ce"

(this is the output for PyCharm Community Edition). Your WM_CLASS is the most specific string in the list (use your intuition, in this case jetbrains-pycharm-ce is obviously about PyCharm, whereas the other seems to be related to all Java apps in general).

3. Set your application’s WM_CLASS in the .desktop file

Open your .desktop file from Step 1 with a text editor, and either add (if it’s not there already) this line to the bottom, or replace its previous value with the WM_CLASS string from Step 2:

StartupWMClass=jetbrains-pycharm-ce

replacing jetbrains-pycharm-ce with your WM_CLASS, of course.

4. Profit

That’s it! Close all your application windows, and relaunch your app. This time, after you launch the app, you should only have one icon 🙂

In what seems to be a never ending series of posts on how to fix out of sync subtitles… here’s how to do it using Angular! 🙂

First things first: here’s a link to the webpage that you can use to fix your out of sync subtitles. Just go there and follow the instructions, it’s really easy. Trust me, I’m the author 😛

A little background on why I made that page. About a year and a half ago I started toying around with AngularJS, because we decided to re-write the SketchTogether HTML client in it. Since I’m mostly taking care of the server side of the app, I spent a lot more time reading Angular code than writing it; even if I think I got the basic concepts relatively quickly, I wanted to have some first-hand experience with the library to really grasp what it means to develop an app with it, even if just a basic one.

Since back in those days I was fiddling with a toy python script to fix out of sync subtitles, I decided that it could have been fun to do the same thing in Angular. I wrote a rough implementation of the script’s functionality in about two weeks of my off time (about 10 very fragmented hours all in all, and I must say I was happy with it, considering how Angular is known for its steep learning curve), and left it there. Fast forward to 4 months ago, I decided to make it look a little prettier, and publish it on GitHub. And then, it took me 4 more months to find the time to write this blog post about it on a Sunday night 😛

My experience with Angular so far has been positive. For one thing, it’s not as hard to create a non-trivial webpage with it as most people want you to believe. Data binding can get you pretty far, and it’s relatively straightforward (one basic thing that left me wondering though is the from-dashed-to-camelCase directive name auto-conversion… that felt a bit like unneeded magic to me).

It does get a bit convoluted when your application grows and you want to add some piece of functionality that’s like 4 lines of code in jQuery, but which takes a new directive definition, changes to the HTML, and maybe a new scope, just to follow the Angular way. But then again, it could be my limited knowledge of the library (which I intend to keep expanding, because there’s so much to learn!).

As with most things Javascript, there tends to be an oversupply of sub-libraries to do pretty much anything. For subslider.js, for example, I found a lot of angular plugins to take care of pagination, with no clear winner. The same applies for drag-and-drop support (which in the end was implemented as a directive in the app). It really takes some time to simply understand which of the many plugins suits you best… just look at how many plugins are listed by ngmodules!