Inefficient jQuery Selectors

My PyCharm IDE warns me if I use inefficient jQuery selectors:

As I am a bit nosy I wanted to know “how” inefficient these selectors are. So I compared the inefficient

$("#items tbody");

with the optimized


Here is the test code:

window.onload = function () {
    test("unoptimized", function () {
        for(var i = 0; i < 100000; i++){
            $("#items tbody");
        assert(true, "Test finished");
    test("optimized", function () {
        for(var i = 0; i < 100000; i++){
        assert(true, "Test finished");

I used the little test framework from the book Adventures of the JavaScript Ninja

The results vary from run to run but the optimized version just takes around 55% of the time which makes it almost twice as fast. Though the single execution is in the nanosecond range, if you heavily rely on using jQuery, it might be worthwhile to optimize your selector statements.

Code on GitHub



Bringing AJAX to Flask – Part 1

Flask is a micro web framework which is really fun to use. With the following snippet You have a complete web app working within seconds.

from flask import Flask # 1
app = Flask(__name__)   # 2

@app.route('/')         # 3
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':           #4

All this snippet does is

  1. Importing the Flask module,
  2. Creating the app,
  3. Defining an so called endpoint and finally
  4. Running the web app in a container.

Flask brings its own WSGI server called “werkzeug”. Please use it just for development purposes. It is not suitable for live applications. Continue reading “Bringing AJAX to Flask – Part 1”

Code Kata: Converting old ICQ chat logs to html

Enough about books for a while. Let’s do some coding finger exercise. When I migrated from my Windows XP machine to my MacBook I made a backup of my old ICQ chats. Because I wanted to read what my wife and I chatted about ten years ago I tried to convert the old logs into HTML.

First challenge: Files are not correctly sorted in directory

These files are stored as one XML file per month and conversation.

The naming convention is a bit odd, it reads conversation_1207, which means December 2007.

So let’s rename the files that they will be in correct order.

Second challenge: build a temporary file which contains the whole conversation

Third challenge: convert to HTML

  • Replace unnecessary tags
  • Replace tags with div tags
  • Convert UTC time stamp to readable time stamp
  • Wrap the output with HTML basic page

Fourth challenge: write a CSS file to make it look like a ICQ conversation


The code on github

Review “Managing Oneself” by Peter Drucker

To call this book a book is a bit exaggerated. It contains only 60 pages which I assume you can read in under one hour. Nevertheless if you haven’t encountered the work of Peter Drucker yet this is the place to start.

The Author

Peter Drucker is best known for his concept of “Management by Objectives”. He also coined the term “knowledge worker” and “core competency”.

Main Takeaways

Drucker elaborates on three major questions:

  • What are my strengths?
  • How do I perform?
  • What are my values?

These are the basic questions to ask yourself to answer the bigger questions:

  • Where do I belong?
  • What can I contribute?

The rest of the book ponders on developing relationships and a second career for later in life.

The bottom line

I will stop writing so my review won’t be longer than the book itself. Managing yourself is a big factor in personal success. If you don’t manage yourself how can you manage others? As I already mentioned this one is a good entry into the works of Peter Drucker. It’s also perfect as a gift, so buy a bunch of them.

My reading habits over the years

As a child and teenager I read a lot, mostly fictional books. I often went to the library and got lots of books as a birthday or Christmas present.

  • Astrid Lindgren
  • Tonke Dragt
  • Wolfgang Hohlbein

On of my favorite authors at that time was Ken Follet. I read through the 1000+ pages of the Pillars of the Earth on just two or three days. The more we had to read for German classes in school the less I’d liked to read at home. Occasionally I read a Preston / Child thriller.

After I finished school I worked as a sound technician at the Landestheater Detmold. Due to masses of spare time and to the lack of nowadays always on communication devices I got into reading again.

I re-read all the classics which I should have already read in school.  Because I didn’t had to, it was actually a lot of fun. I read a lot of the books from Thomas Mann,  from Heinrich, Klaus and Golo Mann as well.

During my studies I started reading non-fictional books and often bought different books about the same topic because I enjoyed reading things from a different perspective to better understand them.

So what happened to the habit over the years? Why did I almost stopped reading entirely?

Distractions by other hobbies

  • Working 40+ hours per week plus commuting
  • Surfing Facebook and 9gag
  • Binge watching
  • Children 🙂

What got me into reading again

  • Martin Suter
  • Paulo Coelho
  • Manfred Spitzer

My new most favorite author became Dan Simmons after I accidentally bought the book “Terror”
After I watched the TED talk Why I read a book a day (and why you should too): The Law of 33% I started to read again like crazy and started to build up a personal library

Review “The Passionate Programmer”

About the Author

Chad Fowler is best know for being CTO of 6Wunderkinder after its exit to Microsoft. Before he was Senior Vice President of Technology at LivingSocial.

The Book

Fun fact: the first edition of this book was titled “My Job Went to India: 52 Ways To Save Your Job” but Fowler found this title misleading: instead of improving from mediocrity to keep your job we wants You to focus on becoming exceptional and staying ahead of the pack. Continue reading “Review “The Passionate Programmer””