Running IntelliJ IDEA under DWM with java 7 & 8

For quite long time I’ve been using IntelliJ 12 because it was still compatible with java 6 which & was running well with DWM. Whenever I was trying a newer version of IntelliJ which required java 7, I was getting a gray screen. The IDE was loading but couldn’t see anything but a gray window. And that sucked because the newer versions of IntelliJ support multiple selections etc which are quite neat.

Today I finally found a solution to the problem (mentioned here and I basically had to run the following command before starting IntelliJ:

> wmname LG3D
> ./

And that was it! Seems like you can use this tool/trick for any java program that has some issues!

So now I’m running IntelliJ using a little script I created inside /usr/bin/intellj (remember to sudo chmod a+x /usr/bin/intellj so other users can run it as well):

wmname LG3D
export IDEA_JDK=/usr/lib/jvm/java-8-oracle

Update: If you want to run Webstorm, you might need to exchange IDEA_JDK with WEBIDE_JDK

Connecting to wifi through command line (Lubuntu + DWM)

Hi everyone!

As you might have noticed already, I’m a big fun of DWM and for long time I had issues with wireless. Basically whenever I wanted to change to a different wireless network I had to logout from DWM, login to the Lubuntu’s default desktop manager (not even sure what it’s called) and from there switch to the new wifi. That was kind of annoying, having to close all my open applications just to set up the wifi.

I’ve tried a few times with iwconfig etc to get it working but I never managed to connect to another wifi through command line until today! How did I do that? I used nmcli tool! This seems to be the command line tool of the network manager. Here is the command I used to connect to the wifi network:

sudo nmcli dev wifi connect <wifinetworkname> password <wifipass>

That’s simple isn’t it? Enjoy!

Note: if you want to see what networks are found in range you can use the following simple command:

nmcli connection

Server time went out of sync

Last Sunday night I received a call from one of my clients that the pdf generation stopped working! What on earth! It was working fine for the 2 years and it decided this Sunday to stop working? What happened? I checked the code (nothing was committed accidentally). Checked the requests “Server can not generate pdf”. Then after a bit of debugging it turned out that the code that was uploading the generated PDF to Amazon S3 was throwing an error. Luckily the error description was quite clear:

The difference between the request time and the current time is too large.

So right away I checked the hour of the server that generates the PDF files & indeed it was around 15 mins in front. After a bit of looking up online I found that you can sync your server time using the command below. And that right away solved the issue & PDF generation was magically fixed 🙂

sudo ntpdate
sudo apt install ntp
sudo systemctl reload ntp.service

You can read more about it on Ubuntu documentation

flatMap explained

Understanding how map works is pretty easy. It doesn’t need a second thought. In the contrary flatMap usually needs a bit of thinking to realize/remember how it works. In this post I’ll try to give a schematic explanation of the difference of flatMap & map.

Basically, map & flatMap result to the same thing. They take a monad & return a monad with transformed values.

monad transformations

The difference between them lays in the transformation function. Map’s transformation function takes a value & returns a value where flatMap takes a value & returns a monad with the transformed value.



Now you will ask me why is it called flatMap then? Well .. it’s called flatMap because if you use map on a function that returns a monad, you get a “doublemonad (see drawing below). So in that context, flatMap “flattens out” the result 🙂

issue with map

And that situation (double monad) happens quite often! For example, if you have a booking that has an optional user. And the optional user has an optional email. And you want to write a method getEmail() that gives you the email option of a booking, how would you do it with map?

booking : Booking
booking.user : Option[User] : Option[String]
def getEmail(booking: Booking) : Option[String] = ???

If you use map for it, you’ll have to do something like that (mainly because returns an Option[Option[String]]):

def getEmail(booking: Booking) =

This is where flatMap becomes useful. Due to the fact that flatMap’s transformation function is returning a monad, we kind of right away get the inner monad!:

def getEmail(booking: Booking) booking.user.flatMap(

And that’s it! Do you get it now why is it called flatMap? Hope this blog post helps you remember it 🙂 Have a nice day!

Lock your screen with slock

I’m sitting here in a co-working space (first time in my life) and a very good friend of mine showed me an awesome command for locking the screen when leaving the desk. As you might have imagined, me as a DWM user I’ve fallen in love with it right way. Here it goes!


Note: to unlock just put your login password & hit enter. Whatever else you type the screen shouldn’t react. Awesome isn’t it?

Virtual Desktops in Windows using VirtuaWin

Good morning everyone!

I’ve used for the first time today VirtuaWin under Win 7 64-bit and I’m happy to say that it worked well! I downloaded the executable setup from the website, I run it and a small tray icon appeared. I couldn’t figure out how to move a window from one desktop to another but then I opened the setup page and I saw the hotkeys. I modified them (as shown on the screenshot below) and now I have my desktops & shortcuts like in Linux (Ctrl + Alt + <arrow> switches to other desktops and Ctrl + Alt + Shift + <arrow> moves windows to other desktops).


Screenshot of the hotkeys I set up so VirtuaWin behaves like in Linux

Have a nice day & hope this post will help you put an order to your windows 🙂



Remove element after applying bindings with knockout.js

There are some situations that you want to display something before the bindings get applied. For example, you might want to display a loading message until the bindings have been applied to this set of elements. Here is how you can do it.

<div id="container">
  <div data-bind="if: false">  <-- here is the trick
    <span>Loading ..</span>
  <div data-bind=" --- something to bind by calling ko.applyBindings() --- "></div>

How it works? Simple. Once the bindings are applied, the binding on the div that surrounds the loading text will be removed automatically! 🙂

Having issues with navigation in Webstorm?

Did your Ctrl+N or Ctrl+Shift+N or Ctrl+Shift+Alt+N stopped working properly in Webstorm (not considering all files, not finding all methods etc)? Then most probably there is an issue with Webstorm’s cache & needs to be invalidated. The solution is simple:

File -> Invalidate Caches .. -> Invalidate & Restart

Then the problem will be gone 🙂

Have a nice day!

How to navigate through usages in file with WebStorm

It’s quite useful sometimes to be able to navigate through the usages of a certain variable inside a file. For example, you find a method and you want to see where it’s being called, or a variable and see where it’s being used. With WebStorm it turns out it’s quite easy to do. You hit Ctrl + Shift + F7 and then you use F3 and Shift + F3 to navigate between usages.

Ctrl + Shift + F7    // Highlights all usages in file
F3 or Shift + F3     // Navigate forward or backward between usages

If you are interested in usages in other files as well, use Alt + F7 instead.

Alt + F7             // Finds usages inside the project

Dynamic Pinterest button

There are sometimes that you want to update the url or the media url of the Pinterest button dynamically. On Pinterest’s developer website there is nothing about it (weird!). I found a blog that suggests to remove & re-evaluate the pinit.js script, an approach that works but is very inefficient. I then by accident found on Github pinit.js uncompressed code and went through it & found out that it’s possible to update a button! Here is how you do it:

Step 1

You add a data-pin-build attribute to the script element that loads pinit.js and you give it a name, which will be the name of the method that you’ll be using for dynamically building Pinterest buttons (named build_pinterest_button in this example).


Step 2

Generate the new pinterest button (modifying the existing one might not work out because pinit.js replaces the button with a different one with a background image loaded from Pinterest’s servers). Then call the method you provided above on a parent container of the button (not on the button itself)

var $newButton = $('<div>')... //generate the new button
var $container = $(...)        //a parent container of the new button
build_pinterest_button($container[0]);  //re-build pinterest buttons inside container

And that’s it! You’ll get an update Pinterest button the same way as it does at the first time you load the script 🙂

If you run into any issues feel free to ask me (through comments below).