Ugly fonts in Java apps under Linux

What strikes me from time to time is that under Linux all works well… after you spend some time searching for ways to fix things, and make them work exactly the way you want them too.

I am really picky when it comes to the UI. I love command line and console, but as I do work a lot with written words… quality of fonts rendering is extremely important for myself.

I am learning RoR at the moment. I’ve been doing quite some coding recenlty using pure VIM, but decided to give RubyMine a try. RubyMine is very powerful IDE, but under the default JDK/JRE (no difference if this is OpenJDK or Oracle’s JDK/JRE) the way it renders fonts is just pain to the eyes. Eclipse renders fonts much better (by default) than RubyMine, and NetBeans is as bad as RubyMine is.

I’ve spent a bit of a time trying to configure RubyMine so that it renders fonts as nicely as VIM :) but with no success. I was so desperate on this, that I was planning to either switch to another IDE (but Aptana is no go for me) or to go back to pure VIM again.
Fortunately I have found a solution for Debian/Ubuntu:

1) Do not use Oracle’s Java
2) Do not use the OpenJDK default repository
3) Add the https://launchpad.net/~no1wantdthisname/+archive/ubuntu/openjdk-fontfix as a ppa

Install OpenJDK 7/8 from the repo mentioned in point 3.

If you have other flavors of Java installed, use sudo update-alternative --config java to pick the OpenJDK installed from no1wantdthisname ppa.

That’s it.

And the results? Huge, huge differnce:

Before:

After:

Boiling Frogs conference

Last Saturday (16th of January) I had a chance to take part in the Boiling Frogs 2016 conference. This is not very widely known event - at least I haven’t heard of it before my friend told me couple of weeks ago. Boiling Frogs is organized in Wroclaw, Poland. As far as I remember this year’s edition was the second one (actually I was corrected on that: this was the first edition of the conference). What is interesting is that there is no huge company behind organizers. You may actually say that Boiling Frogs is a community driven event is oranized by people who form community.

I was quite surprised that this event offered three separate tracks of talks. I understand how much of an effort is required to prepare even a single track conference, but three separate tracks… well done Boiling Frogs 2016 organinzers! Each track had a mixture of talks: some focused on very technical aspects of software development, some others more focused on a topics that focus on software from a bit higher perspective (architecture, project management etc.).
One important thing to note was that even though most of the presenters had their slides in English, talks were held in Polish only (at least all those that I have attended).

Opening Talk

Conference started with opening talk by the main organizer: Tomasz Kaczmarzyk. Tomasz told us about the history of the conference, the effort himself, team and friends and family devoted to make this event happened.

Talk #1 - “From legacy to DDD”

After the opening talk I decided to listen to Andrzej Krzywda (from Arkency) talking about his journey from “Legacy to DDD”. That was a very interesting talk. Andrzej told us a bit of his effort to find the architecture/approach that would help him build software that is most valuable to his customers. It was great to hear how an adoption of some techniques enables developers to think more in terms of business opportunities than in strictly technical manner. Some time ago I was told that pure technical excelency is not that important as being capable of delivering technical solutions, but in the same time understanding business and being able to suggest new features and functionalities.
Slide deck from Andrzej’s talk is available online: http://www.slideshare.net/andrzejkrzywda/from-legacy-to-ddd-5-starting-steps
The most important things to take from the talk:

  1. Learn ideal DDD - to think about implementing any (part of) system in DDD you should learn the most important concepts first. Obvious, right? :)
  2. Publish events (just in case to be ready to later make further changes to the application code, and benefit from ‘just publishing events’)
  3. Microservices are hot. What they bring on board is requirement to have things done in an async way. The question is: do you and your team have enough knowledge and experience to have it done on your own?
  4. Frameworks are great, but… sometimes you end up being a prisoner of the framework of your choice. It is a good idea to separate framework(s) from the core of your application. Why would framework specific objects leak into the most inner part of your application? Andrzej put a lot of emphgasis on separating network (http) and storage/database layer from the application.
  5. Learn bounded contexts - this is actually the core of your project. It is the most important to have as good understanding of it as possible, that’s why you should think of how to model your ‘world’.

I personally love talks like that one. This is the level of understanding how software works (or should be built) that I think is the most important. This kind of perspective requires not only ability to code, not only knowledge of frameworks, but moreover knowledge of some architectural approaches and (maybe most important) experience: a lot of hours ‘wasted’ staring at the code and thinking how to improve that.

Talk #2 - “BDD and agile requirements”

The very next talk that I have attended was entitled “BDD and agile requirements”, given by Wiktor Żołnowski. Wiktor is experienced QA and consulant, who helps many companies make sure that the software they create is of acceptable quality.
This talk was packed with a lot of stuff:

  • proper approach to define BDD scenarios
  • introduction to GROW (Goal, Reality, Opportunites, Work) approach
  • a story of a startup that Wiktor has been advising
  • introduction to usage of Cynefin (have you ever heard of it before reading it here? no? google it!)

It is easy to spot that Wiktor has a lot of experience in advising companies and organizing how teams work. Great talk.

Talk #3 - “Paradise for polyglots - everything floats”

Right before the lunch I have attended interesting talk by Michał Płachta “Paradise for polyglots - everything floats”. This one was aimed at reactive progamming. Michał was showing the audience how to build a simple snake game using reactive approach (so approach based on streams). From the very simple thing (snake and fruit in the same place all the time), Michał went to a full featured version of the game. Just to show that reactive approach could be used on both: frontend and backend (same time) - Michał got to the point of having two different players (snakes) at the same time. Snakes were synced using backend (written in Scala+Akka). It was really impressive talk. I was really inspired by the way such a simple application has been built with the reactive concept in mind.

Lunch

The lunch was a great opportunity for myself to talk to couple of my colleagues, and to eat some pierogi :) (if you have ever visited Poland, you have surely been offered pierogi, no doubt!).
Great time to have another look at the agenda and mark talks that seemed the most interesting.

Talk #4 - “Effective Software Delivery”

First talk after the lunch that I heard was “Effective Software Delivery” by Jakub Kubryński. Jakub cooperates with Bottega Solutions, and I must say, that I have heard couple of talks by people who work for Bottega, and each time it was time well spent. To me this is now clear - presenter who works for Bottega = high quality of the talk.
Back to the talk: Jakub was talking about all the different approaches we take to make sure we can deliver software of high quality. Jakub has also pointed out couple of different approaches that are quite common but result in the development of software of not-so-high quality.
One of them was hacking models/database - using columns or properties to enable some additional features: “during this transaction we don’t use the property X, so if this is set to Y…”. Does that sound familiar? Another one: “yes, I agree with you - I’d like to have this feature tested, but trust me, this one is special and you can’t test it”. Scripting? “I know it should be automated, but…”.
Another thing that was touched by Jakub: what is the difference between PoC and spike(s)? When should you go with PoC? How do you evaluate technology? Should you trust something just because it prooved useful in a previous project you worked on?
Another interesting thing that Jakub touched was the way we build software in general, how we think about it. Is architect a good name for someone who is in charge of technical side of software development? Is building houses really good analogy?
Apart from that there were couple of other things mentioned: silverbullets (in terms of technology), praising small changes, knowledge of your tools, scripting and automation of tasks, testing software, DRY (and WET), premature optimization, code inspections and couple of more. For experienced developers some (all?) of the things mentioned should be familiar, but still it was a great summary of techniques to make great quality apps. For not that experienced developers this should be one of the required talks.

Talk #5 - “How to find time for quality? Theory of queues and Little law’s in the software development process”

The very next talk I went to was another one given by Wiktor Żołnowski: “How to find time for quality? Theory of queues and Little law’s in the software development process”. Originally I wanted to go to my friend’s (Tomasz Pluskiewicz) talk “HATEOS as if you meant it”, but I decided that the previous talk Wiktor gave was so good, and that I have already talked to Tomasz couple of times about HATEOAS that… I have decided to go for the second talk given by Wiktor. His talk started with a simple problem: how to optimize a system. We were thinking about McD-alike “drive-in” system, which has 3 different stages: placing order, payment and order collection. The trick was that each stage took a different time to be completed. Wiktor has shown couple of simulations using different number of vehicles being in the queue. It was interesting to see that squeezing too much actually makes the whole system performing much worse than we would expect.
Taking it from there Wiktor elaborated more about how to improve performance of a team that uses Scrum. He pointed couple of things to consider that are related to work organiation, amount of work planned to be done within a sprint etc.
I think that both talks by Wiktor should be attended by all managers in IT. I agree with Wiktor: we do lack managers in IT who have management background (as the common story is that developers are being given a chance to manage and they do it as well as they can).

Talk #6 - “Machine Learning for Developers”

The very last talk that I have attended was “Machine Learning for Developers” by Mariusz Gil. I am not sure, but this may have been the most important talk of all for myself. Why? Simple reason: I had no idea what machine learning was, before entering the room where the talk was given. After ~45 minutes I am still no expert in the area, but at least I have an understanding what machine learning is, where could it (possibly) be applied and what are the things the you should consider when building a machine learning system.

After the conference we have headed to the pub where we had a bit of a disussion on IT, software etc. I came home quite exhausted, but happy, as I considered this day to be a well spent one. I have learned some things, I had a chance to talk to some of my colleagues I know from local tech groups, and make some new acquaintances.

Summary

As for the confenece itself I must say that I like these type of events: organized by smaller group of people. Made with passion and not because there is a business aim, or an opportunity for a company to make its brand better known.
Boiling Frogs was one of the events that boost you with energy, that makes you become better in what you do on a daily basis.
If there is another Boiling Frogs conference next year to be organized - I will definitely make sure to get a chance to attend it.

I think that 2016 has started very well. I can’t wait for other opportunities for me to develop my knowledge and attend even more interesting events.

Go, Kubuntu, fish-shell & gvm - addendum

There is just one important thing that I have missed in my previous post. It all seems to work ok, but if you restart your machine you quickly realize that the gvm is not available to you anymore. What is the point?
Well… this is due to the fact that after a function is created for fish-shell (as in step 2 in previous blog post) it works… but it is not stored for future use. To do that - there is one single thing required - function has to be saved. This will make it persisted, and such a function will be available to you after your machine is restarted.

How to save a function? This is extreemely easy, you just type funcsave <function_name> - in our case (in case of saving gvm) it will be: funcsave gvm. That’s it.

Now if you cd to your ~/config/fish/function folder, you will spot the file named gvm.fish. The content of the file is (surprise?) the definition of the gvm function used by fish-shell (step 2 of the previous blog note).

I hope it is now clear

Go 1.5.x on Kubuntu using fish shell and gvm

I got really interested in Go and I am learning it in my spare time. Unfortunately the verion of Go that is available via Ubuntu repository is very old (at the moment of writing this it was 1.2.x). It was not good enough even for learning purposes.

I wanted to use the very latest version of Go (1.5.x) and started looking for an PPA that would allow me to install the newest version. I quickly found one: https://launchpad.net/~evarlast/+archive/ubuntu/golang1.5 Unfortunately I quickly realized that it may not be the best idea.

What if need to use two different versions of Go? How do I manage them?

The best thing is to use something similar to nvm (NodeJS Version Manager) or RVM (Ruby Version Manager). As I am using fish shell instead of bash, things are a bit more complicated. There are couple of steps required to have Go 1.5.x installed on Linux, and make the whole thing work with fish shell.

  1. Install gvm (https://github.com/moovweb/gvm)
  2. Make gvm work with fish shell (https://github.com/moovweb/gvm/issues/137#issuecomment-131400212). You may need to install bass first (https://github.com/edc/bass)
  3. gvm install go1.5.x will not work, as Go 1.5.x requires Go 1.4.x for compilation. Install Go 1.4.x first (gvm install go1.4.3)
  4. gvm install go1.5.x will fail again, due to the fact that it will be unable to find Go 1.4.x. You will probably see similar error message
    1
    2
    3
    4
    ERROR: Failed to compile. Check the logs at /home/<username>/.gvm/logs/go-go1.5.1-compile.log
    ERROR: Failed to use installed version
    Installing go1.5.1...
    * Compiling...
    In my case the log content was:
    1
    2
    3
    4
    5
    ##### Building Go bootstrap tool.                                             
    cmd/dist
    ERROR: Cannot find /home/<username>/go1.4/bin/go.
    Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.
    ./make.bash: line 121: /home/<username>/go1.4/bin/go: No such file or directory
  5. Execute the folling commands to help gvm to succesfully compile Go 1.5.x (this is based on the discussion: https://github.com/moovweb/gvm/issues/155#issuecomment-135855340):
    a) gvm use go1.4.3
    b) set -x GOROOT_BOOTSTRAP $GOROOT
    c) gvm install go1.5.1

That should be all fine right now. Go 1.5.x should be installed on your machine (side by side with the Go 1.4.x that was used required to compile the newest version of Go).

Happy coding (in Go!)

Checking out hexo!

I was thinkig for quite some time how to migrate my old blog from Wordpress to some other blogging platform. Couple of reasons why I started thinking of giving up Wordpress:

  • Wordpress is complicated, offers a lot of plugins, and this makes it vulnerable to ‘hacking’
  • I don’t think I really need the flexibility that Wordpress offers. I think for me it is just too much. I am not planning to write blog with someone else (so I don’t need platform which supports many authors)
  • Wordpress requires hosting. And that costs.

Some time ago I’ve bumped on couple of people saying that static sites generators are great for blogging purposes. It seemed to me a good idea having my blog hosted on github, so that I can have all the things in one place.

I’ve heard about Jekyll, Nikola, Pelican but I knew there were many more. I had to figure out what my needs are, and after a short while, I came up with the most important features my preferred blogging platform should offer:

  • good support for code snippets (as I will be using this mainly for my programming related blogging)
  • support for plugins (for example: I want to be able to use disqus for comments)
  • offering some nice themes, so that I can pick something for the very beginning

My workmate suggested me to have a look at Nikola. The installation was easy (I’ve used virtualenv so not to spoil my environment). It took me a bit to have a first blog post in the shape of my desire. In a short time I’ve learned how to work with Nikola. I think Nikola is a great piece of software. I was quite amazed when I discovered how easy it was to install additional theme. It wasn’t much harder to change bootstrap’s based theme (for the bootstrap based themes). All with just providing couple of arguments to Nikola. Although… I wasn’t very happy with Nikola. Mainly because:

  • Nikola is quite slow, re-generating your site takes quite some time. As I was playing with quite many themes, and was doing a lot of tweaking - that was something hard not to notice
  • I’ve spent some time searching for nice themes, and… I was quite dissappointed. I couldn’t find a nice, easthetic theme, that would render code snippets in a fancy way. Some themes looked better in general, some were not that nice, but rendered code snippets better. All in all I haven’t found one theme I could be happy with. I had a quick look at Pelican (http://blog.getpelican.com/) (which is another static site generator written in Python) and it seemed to me that Pelican offers nicer themes.
  • my feeling is that there are not many plugins, and that the community behind Nikola is not very big

After my experience with Nikola, I decided to give some others platforms a chance. I’ve made some research, and found a site that lists many static sites generators: https://www.staticgen.com/ It is definitelly more than enough. I was amazed how many generators are there. Not only for Python and Ruby, but also for functional languages (Haskell, Scala) and some really exotic languages such as Racket (https://www.staticgen.com/frog).
One of my thoughts was that I should probably go with Jekyll as it has the biggest community, dozens of themes and plugins. What’s more, I think that in comparison to Nikola, it may be easier to find some articles on how to change things in Jekyll. I was pretty much set for trying Jekyll, when I spotted Hexo (https://www.staticgen.com/hexo).

Hexo is written in JavaScript and uses NodeJS. One of the biggest advantages is Hexo’s popularity: it is ranked 4th when taking github stars. Developers working on Hexo claim it is very fast. And comparing to Nikola… I must say that this is true. Hexo is even easier to set up than Nikola (or maybe it is just me being more fluent with JS stack than Python). If you already have NodeJS on your machine, there is just one package to install. After about a minute I had my “blog” created. Within next couple of minutes I had couple of sample notes, with codeblocks and gists - I decided it looked better than what I was able to create using Nikola. I’ve spent next hour (or two) playing with themes, and making my own modifications of themes. I am pretty happy with what I have achieved so far. There are couple of things I will need to change, but I guess I am good to go with what I have.

Hexo supports codeblocks…

this is how it highlights Python…

somepy
1
2
3
4
5
6
7
8
9

import sys

def my_func():
print(sys.info)

if __name__=="__main__":
my_func()


JavaScript:

some simple AngularJS controller
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
angular.module('angularFullstackApp')
.controller('CategoryCtrl', function ($scope, hierarchy, $location) {
$scope.message = 'Hello';

$scope.categories = [];

$scope.populateCategories = function(allCategories) {
$scope.categories = allCategories;
};

$scope.categoryClicked = function(categoryId) {
console.log('category clicked: ', categoryId);
$location.url('/topics').search('category',categoryId);
};

hierarchy.getAllCategories().then($scope.populateCategories);
});


…and Go:

simple example in Go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

package main

import "fmt"

func main() {
fmt.Println("Hello World from Go!")
for i := 1; i < 20; i++ {
var t = ""
if i%2 == 0 {
t = "even"
} else {
t = "odd"
}
fmt.Printf("Number: %02d binary: %05b octal: %02o %#x\t is %v\n", i, i, i, i, t)
}
}

and this… is how Hexo displays gists:

To sum up: I have created my main github page and within minutes I had it published.

I haven’t thought that setting up new blog using static site generator will be so much fun. I regret I haven’t devoted some time to do it much earlier this year… anyway, I hope that this blog is going to be an opportunity to share what I learn.

As for the moment, the only thing that bothers me is: how do I write blog notes using differnt machine than the one I have everything set up? With Wordpress and other dynamic bloggin platforms it was easy - most of them offered some kind of web interface (administration panel) one may use to write a blog note. With Hexo this is not the way. I will need to think of some way to make it possible. I will post if I have something to share on this topic.