David Votrubec

So, is the world really faster?

Every now and then I hear people complaining that the world is now much faster than it used to be in time of our grandparents. But is it really so? Did people complain about that very fact in their time? Another common complain is that parents now have less time for their children or their partners. I don’t agree with this. I think that generally we work less now, don’t we have 8 hours long work day? Problem is that we have now too many options to choose from. It is difficult to choose and be happy with your choice, when choosing one option means saying no to all other tempting options. We have twitter and facebook statutes, google reader, rss.. and so on and so on. The amount of information is so overwhelming, that we always miss something. We just can’t catch up on it all. Therefore the world seems so fast. It’s not that much about the progress and innovation pace but about the number of small choices and distractions you face every day.  So why not just slow down and enjoy simple (offline!) things?

As a programmer I tend to follow what’s going on in the industry. I love learning new stuff. So I read about new technologies, I try them, dream about using them. And I often feel kind of guilty that I can’t learn them all. I always feel quite behind. Incapable of following. I guess that lot of people have similar problem of trying to do too much.

After reading that sleep is more important then food I decided to try to slow down and really sleep more. Yes, it does help :). I don’ t always manage to get those recommended 8 hours per day, but when I do, I can tell the difference. I just focus much better when I am fully rested (surprise:) ).  One of the requirements to get more sleep and feel better is to drop something off. Make more free time for yourself. Then your world will be slower again as it should be.

Environment and productivity

What kind of environment is best for work? Do you work in such? When I worked for IBM I was confined in a cubicle in a big open-space.  It was an experience I don’t want to go through again. The environment was “noisy by default”, there was a continuous sound-spam of chatting people. It was really difficult to concentrate and be productive.  The only way how to avoid it was to put on headphones and listen to some music.  But still I was disturbed by IM notifications and other crap.

Now I work in a small office in a team of five people and I am totally happy.  Most of the time nobody talks and if then it is mostly work related.  There is often silence, the only thing you hear is fingers tipping the keyboard.  I guess I sound quite nerdy, but I really like it this way. I believe this is the only way how to be really productive. Talk little, avoid being disturbed (if possible) and focus on the task at hand.  Then take a break, read some short article, have a cup of tea, or a little walk in the office.  That helps. If I deliver nice code, I am happy. If I don’t then I don’t like myself. Really.  I am far from being a perfectionist, but I like good work. I find it satisfactory 🙂

What helps me focus and create something is good music.  I can not play any musical instrument but I am an enthusiastic listener. I am particularly fond of jazz music. I know it may sound as a contradiction because jazz is often difficult to listen to, but it helps me to write code. Jazz is so full of energy and surprising ideas, that it lifts me up. It inspires me.  I love Pat Metheny for example. Listen here. Is it beautiful?

So .. this is the kind of music I listen to when I code. Or when I need to get new ideas. Or just to sit back and relax 🙂

What kind of music do prefer to listen to when you work? Or do you prefer silence?

Circus Cermaque

February, the last month of winter, is the worst one. I am tired of winter, of the ever clouded sky, of lack of sunshine.  And in these grey days I have met by chance three shining guys. At first all I could hear was distant sound of clarinet. I came closer and saw these guys playing joyful-melancholic music.

Circus Cermaque

It suddenly felt like summer. Sun was shinning and it was unusually warm for end of February. There is one thing I love on summer and that’s the street artists. They bring poetry to dull day-to-day life. Unfortunately I can’t play music at all and I found it quite difficult to dance in rhythm but I am an enthusiastic listener. This music was exactly of my taste: playful but with sadness and melancholy underneath, and one can’t say what style it actually it. It was a mixture of folk and jazz and improvisation. I could not resist and bought their CD. Every peace looks different, every peace is original 🙂

Circus Cermaque Booklet

Later I found out that Cermaque already released two albums and Jakub Cermak released two garners (at quite young age). It is not an easy listening like ABBA, it is fragile, gently disturbing and fascinating.

Listner here:

http://bandzone.cz/cermaque

jQuery datepicker improved

I like jQuery’s datepicker a lot, but I miss two things – one is some kind of mask on the input field so I can write date directly without worrying about the correct date format, and the second is customisable trigger (the thing you click on to toggle the calendar widget 🙂 )

Masked input

This is a screenshot taken directly from jqueryui.com. As you see you can write anything to the input field.  Then you have to validate it, display error message, prevent form from submit… etc. It’s not nice.  Luckily there is a nice solution, a jQuery plugin called maskedinput. (and yes, I use it in durationPicker plugin). I definitely recommend you to use it, it’s very handy, saves lot of work.

I typed a date, right? ... or didn't I?

This is what I wanted!

So, that’s the first thing. Masked input is great, but there is a conflict with the new jQueryUI datepicker. Both of them listen on keypress event. Masked input in order to position entered digit in front of or behind given delimiter and datepicker listens in order to automatically update selected date in a widget as you type.  It works fine until you type the first digit indicating year – maskedinput will insert delimiter in front of your digit, which is perfectly fine, but datepicker expects number, and as a result you get year 1900 (or something else same crazy).

Custom trigger

To prevent this conflict you need to toggle datepicker not when user enters input field, which is the default behaviour, but when she clicks on some trigger, in most cases icon or a button.  Datepicker has an option for it

$( "#datepicker" ).datepicker({
   showOn: "button",
   buttonImage: "images/calendar.gif",
   buttonImageOnly: true
});

Do you see the path to image file embedded in js code? It should not be there, it’s not flexible and makes it very difficult to style.  Not mentioning that you can’t use themeroller. Wouldn’t it be nice if you could use any DOM element as an trigger with themeroller-ready classes, and not just an image? Well…. You can 🙂 Use something like this:

var el = $('.datepicker');
el.parent().addClass('hideCalImage calImgWrapper'); //add class to hide 'native' image triggers
//add themeroller ui classes
	var calImgController = $('<div class="calImg ui-icon-calendar ui-icon"></div>').click(function () {
	if (el.attr('data-hasDPVisible') == 'true') {
		el.attr('data-hasDPVisible', 'false');
		el.datepicker('hide');
	}
	else {
		el.attr('data-hasDPVisible', 'true');
		el.datepicker('show');
	}
}).appendTo(el.parent());

I add some css class to hide the <img>, and then replace it with my own <div> element with attached click listeners.  Notice the use of data- attribute hasDpVisible. I have to use some kind of indication whether datepicker is on or off to be able to show / close it as needed.  And that’s basically it. For the full source code see the DEMO.