My favorites for week 20, 2011

Big GrinSomething to laugh: my favorite comic strip of the weekabout what kids care about nowadays

Moderately Confused nicely shows in today’s comic strip what kids care about these days. Well, honestly, what do we care about most when looking for a hotel ?

NerdSomething to watch: my favorite video clip of the weekabout modern office spaces

Why we don’t throw paperclips at coworkers is nicely shown in the video "Why you don’t throw paperclips at coworkers". I mean – we know not to do this. See what can happen if you forget about it …

  Something to enjoy: my favorite photo  on flickr under a Common Creative licenseabout Mallorca

Bay at Cape Pinar
"Bay at Cape Pinar" by axel_magard.

Let me share another of my own photos here this week, taken during my stay on Majorca last year. Why ? Because again this year I will travel there for another week to go hiking, this time through the entire mountains of the Tramuntana Range from the West to the East, and this time together with my wife who didn’t join me last year but now after I told her how nice Majorca is for hiking she wanna see it as well of course.
When ? Next week of course. Thus: see you again in 2 weeks from now !

Surprise Something to surprise: my favorite "I really didn’t know this" of the weekabout books

Did you know that

  • starting April 1st Amazon sold more digital than printed books: 105 vs. 100.

Source: amazon.com

Something to talk about: my favorite quote of the weekabout uncertainty

Uncertainty is an uncomfortable position. But certainty is an absurd one.

People who are confident all the time and know an answer to every question and never ever say “I don’t know” or “I am not sure” are suspicious to me. I know, we have been trained to be like this. An IBMer always know an answer to a question, right ? When you give a presentation and someone asks a question, you never ever would say “I don’t know”, even you actually don’t know. Better to give some sort of answer – probably to a question never asked – than not giving any answer at all.
”A little bit of self-doubt is healthy. It gives you an open mind.”, is said in this Lifehacker article. I can’t agree more.

Advertisements

My favorites for week 4, 2011

Big GrinSomething to laugh: my favorite comic strip of the weekabout books

Do you still read books ? Or do you spent just too much time with your e-mail, instant messenger, mobile gadgets and rss reader / feeder ?

And if you still use books, are these the once made of paper where you manually have to turn pages ? Or do you prefer electronic or even interactive books meanwhile ? Moderately Confused ? Don’t worry too much. Finish reading my blog, then grab a book Wink.

NerdSomething to watch: my favorite video clip of the weekabout computer pixels escaping into the real world

PIXELS by PATRICK JEAN.” is a well done video on Dailymotion showing how computer pixels escape into the real world. If you are from an older generation like me you probably will recognize a lot of those older classic computer games you spent some time with when you were younger, or may be even today sometimes. Thanks to tools like DosBox you can still run those old games on modern computers. I must admit: I started playing “Oh, no more Lemmings” again. And again got stuck at level 16, Rated Crazy. Some day I’ll find the solution. Or cheat here.

  Something to enjoy: my favorite photo  on flickr under a Common Creative licenseabout two relaxed hippos

Xmas in Sthn States 2010 314
"Xmas in Sthn States 2010 314" by Stonestreet’s Coaches – The Extra Mile.

I never heard of the Sthn States, but apparently they are in Australia, most probably the Northern New South Wales and Southern Queensland regions.. That’s where this photo “Xmas in Sthn States 2010 314” has been taken. Those two guys look pretty relaxed, don’t they ?

Surprise Something to surprise: my favorite "I really didn’t know this" of the weekabout the internet 2010

Did you know that in 2010

  • 107 trillion e-mails have been sent over the internet ? ( If you are uncertain about how large that number is, WolfframAlpha can help; it is 5.4 times the number of red blood cells in the human body. )
  • 294 billion e-mails have been sent per day, 89 % of those have been spam ? ( That’s roughly the number of stars in our galaxy )
  • 1.88 billion people on this world use e-mail, and 1.97 billion use the internet ?
  • there are 152 million blogs available in the internet ?
  • 2 billion videos are watched on youtube every day, and 35 hours of video are uploaded to youtube every minute ? ( I already mentioned this in week 45 last year )
  • 5 billion photos are hosted on flickr and 3000 are added every day ?

Source: These and more interesting facts and numbers you can find in “Internet 2010 in numbers”.

Cool Something to discover: my favorite bookmark of the weekabout a audio-visual wiki

Lifehacker today presented Qwiki – a mini, visually-rich Wikipedia that reads to you.  After watching the presentations about Wolfgang Amadeus Mozart and Albert Einstein, General Relativity and Gravitation I checked out the one about IBM.

Something to talk about: my favorite quote of the weekabout good and bad, wrong and right

When I do good, I feel good; when I do bad, I feel bad, and that is my religion.

A large enterprise apparently needs Business Conduct Guidelines, and tons of other rules like export regulations for example or IT security guidelines and social computing guidelines. And apparently there is a need to re-train all employees every year and get them "re-certified". This simple rule by Abraham Lincoln does not seem to be sufficient to find out what is right and what is wrong in our daily decisions about how to behave. What a pity, life could be so simple if we just would trust our gut feelings.

The never ending journey through knowledge …

It’s amazing, isn’t it ? I read “Ajax: A Beginner’s Guide” by Steven Holzner and learned basics about Javascript and Ajax, and I learned that there are many Javascript frameworks out there making it easier to use these technologies – one of it is Dojo, a quiet popular one. I read  “Learning Dojo” by Peter Svensson and through this book I learn about alternate Javascript frameworks like e.g. JQuery, another popular one. Since also some people argue this to be better than Dojo ( certainly others argue the other way around ) I become curious and now started reading “Beginning JavaScript and CSS Development with jQuery” by Richard York. Among the first things I learn from this book is that there are other Javascript frameworks out there: base2, Yahoo UI, Prototype, SproutCore.

* Habe nun, ach! Philosophie, Juristerei und Medizin, Und leider auch Theologie Durchaus studiert, mit heißem Bemühn. Da steh ich nun, ich armer Tor! Und bin so klug als wie zuvor;

Well, that’s Philosophy I’ve read, And Law and Medicine, and I fear Theology, too, from A to Z; Hard studies all, that have cost me dear. And so I sit, poor silly man No wiser now than when I began.

Wow, you can’t win that game, can you ? You can become smarter, but never smart. With every question you answer you get a whole bunch of new ones. With every piece of knowledge you start discovering you also discover tens and hundreds more waiting for you to be discovered.

Goethe’s Faust already said it: “I know that I know nothing!”. The more you learn the more you know how true this is. And since in these fast changing times your learning pace might never be good enough to catch up with new knowledge you are always behind, aren’t you ? A single man never can catch up with knowledge “produced” by millions and billions of people.

Suppose it would be your job to recommend the best Javascript framework for a given project ( and let us assume for now and for the sake of simplicity this would be a well defined project with well established requirements ): how would you do this ? Learn about all available Javascript frameworks and come up with a decision on your own ? Hardly possible. Learning about all these Javascript frameworks actually wouldn’t be sufficient, you would have to be an expert for all those through having actually used all those for at least a few projects. Not realistic – your project would never start.

Your other option would be to find experts for all these Javascript frameworks, make them familiar with your project, put them all together and see with what decision they would come up with. If any. Hardly possible either. A little bit more realistic may be, but still almost impossible. It starts with the hurdle that you never would find all those experts nor get them all together for your project. If you would overcome this problem most likely you would see each of your experts fight for his favorite framework without getting to any decision. If a decision would be made it is most probably not made based on objective judgment, it is most likely a result of group dynamics and politics.

What will be your realistic option ? You probably will only consider the few ( one 😉 ) framework you know about and pick it. You won’t have the time nor the resources to dig deeper into knowledge available and start your project smart with the optimal decision and best framework you could get for your project. You will start it in a sub-optimal and semi-smart way, won’t you ? And you and the project will suffer because of this for the remaining duration of the project and longer, for the life time of whatever your project is putting into existence.

While this might sound a bit negative it is the natural way projects go, the way of business and life. Knowledge is changing all the time and there is never such a thing than an absolute true statement or a best answer to a given question. You always start with compromises, weaknesses and problems-. You might fix some of those later on, may be as part of your project, and this will be the root of more change to come. The cycle of change so to speak, and the reason why project managers and engineers and scientists and experts will always be busy with what they do. We will never sit back and say: “Done!”. The day this happens might be the end of everything.

Dojo, Ajax and JSON

In the book “Learning Dojo” by Peter Svensson Ajax is covered in chapter 4 “Dojo Ajax Feature” and a common way to send an asynchronous request to a server is this one:

   1: var x;
   2: dojo.xhr("Get",
   3:             {
   4:                 url:"/yourserver/server.php",
   5:                 handleAs: "text",
   6:                  load: function(data, ioArgs)
   7:                  {
   8:                     x = data;           
   9:                  }
  10:               });
  11: console.log("x == "+x);

Details about the XMLHTTP request object ( abbreviated XHR ) can be found here. Besides “Get” of course “Post”, “Put” and “Delete” can be used as well. The difference between “Get” and “Post” is, as far as I understood from this book, that “Post” sends parameter to the server in a more hidden way, as part of the document sent to the server, while with “Get” parameters are added to the URL, thus become visible and of course easier to hack.

Anyway, my focus in this blog posting is on the “handleAs” attribute of the dojo.xhr call. The terms “XMLHTTP” or “Ajax” suggest – since the “x” in “Ajax” stands for XML as well – that data is exchanged between client and server in XML format. Which is one possible way to do it, but not the only one. The example above shows a second way: exchanging simple (unformatted) text.

A third option is using JSON ( and there are some variants like ”json-comment-optional” or “json-comment-filtered”, see here ) and I have read comments from many people saying that parsing JSON data is faster than parsing XML. Since JSON stands for JavaScript Object Notation it is easy to imagine that this might be the right thing to do when using Javascript.

I spent an hour or so to figure out how this works, since even it has been mentioned in this book I couldn’t find any example. Key is to specify

   1: handleAs: “json”

as a parameter to the dojo.xhr call. So much to do on the client side, except later on dealing with the returned Javascript objects. Interesting is to find out what to do on the server side, when using php for instance.

What I did in my trial was to setup an array in php to be returned to the client. Thus, part of the server code looks like this, and key to success was to use the json_encode function on the array returned:

   1: // ...
   2: // Defining the array ...
   3: $ret_array = array();
   4: // Populating the array ...
   5: $ret_array["id"] = 101;  
   6: $ret_array["text"] = “Hello World!”;  
   7: // Returning the array to the client ...
   8: echo json_encode($ret_array);        
   9: // ...

And here is what the client gets. The following client side code  …

   1: dojo.xhr("Get",
   2:             {
   3:                 url:"/yourserver/server.php",
   4:                 handleAs: "json",
   5:                  load: function(data, ioArgs)
   6:                  {
   7:                     console.log("Server returned: "+data);
   8:                     console.log(data.id);
   9:                     console.log(data.text);
  10:                     console.dir(data);          
  11:                  }
  12:               });

… produces this output in the console window:

   1: Server returned: [object Object]
   2: 101
   3: Hello World!
   4: id        101
   5: text      "Hello World!"  

Ajax for beginners

As mentioned yesterday I have been reading “Ajax: A Beginner’s Guide” by Steven Holzner. I finished it today and must say: an excellent read and absolutely worth the time spent on it ! It teaches the fundamentals around HTML, XML, dynamic HTML, Javascript and PHP in the context of developing dynamic web applications with what is called Ajax technology. It comes with 12 easy to digest chapters and lots of examples to go through and try on your own. In order to do the latter for almost all examples of course a web server is needed and PHP for the examples making use of PHP as a very common means to do  server side programming. Since I have Apache 2.2 set up on my thinkpad and PHP installed I have been able to do all these examples and really learn all the nice things you can do we Ajax.

A lot of the fundamentals have not been really new to me but it actually did not hurt to go through this again and add some more solid knowledge around a few topics and some great tips by the author like

  • the difference between GET and POST and how to handle that
  • usage of an anonymous inner function as the easiest way to handle multiple XMLHttpRequest objects
  • usage of array type names for form elements to handle many forms and containing elements through arrays
  • usage of literals as an index for arrays in PHP
  • handling timeouts
  • handling image maps
  • the real difference between client side and server side programming

The latter became real obvious when debugging my examples. Based on the fact that in Books24x7 apparently scanned-in soft copies of the original books are used a lot of typos made it into the code in form of incomplete lines and thus missing semicolons or brackets, or additional blanks, or the typical confusion between e.g. “1” ( the number ) and “l” ( the letter ). It turned out that HTML and Javascript errors are easy to catch through the browsers error console ( because that’s of course code running on the client side ) while PHP errors are invisible on the browser and one has to peek into the server side log files to catch those. Makes sense, but experiencing it is a different thing.

As I mentioned browser: what I really like as well about the book is that the author puts a lot of focus on the differences of browser and what works and what doesn’t work in either Microsoft’s Internet Explorer (IE) or Mozilla based browser. Capturing mouse events for instance works very different in IE vs. Firefox and the author shows an elegant way to write a wrapper function to deal with both cases. There are four different dynamic HTML properties available, but only one works in Firefox: innerHTML. And most annoying is the way Mozilla based browser create a DOM ( the Document Object Model ) from a web page compared to IE: for some strange reason the DOM created by a browser like Firefox contains blank elements for the indents in front of nested tags. Hard to explain, but this is a great way to confuse programmers and make properties like firstChild or nextSibling hard to use. Again a nice way is shown how to detect whether a Mozilla based browser is used and to remove those dummy “white space node"s” in this case. Well done ! The author also highlights what works in both browsers and thus gives great advices what to consider when you want to develop some web applications supposed to work in both types of browser.

So, if you consider to do some Ajax web development, this is a must read ! 12 Chapters – if you do 1 per day you are done in two weeks. It takes may be 1 or 2 hours per chapter including trying out the examples. Well invested time, to my mind !

My third experience with OpenOffice V3 Macros

After my first expereince with OpenOffice V3 Macro has been a complete failure I investigated a little further and made a second experience: here I learned that the sample macros provided do work – but only for text documents, not for spreadsheets.

I still have been working on trying to get one of my simple sample MS Excel macros to work with OpenOffice V3. Both applications – and if we include Lotus Symphony there would be three – support BASIC as a language to write macros. The challenge lies in the different object models used by these applications how to access services and how to access documents and parts of a document like sheets or cells in a spreadsheet.

Let me explain first what my MS Excel macro is supposed to do. Basically it is supposed to convert something like this shown here on the left side to something like this shown here on the right side:

Imagine you receive a spreadsheet in which some columns are used for category or grouping values and to make it better readable the value is only present when it changes. This is nice unless you want to sort this spreadsheet by the first column which would create an incorrect output or unless you like to use that spreadsheet as an input for a database import which would cause problems due to missing values in the first column.

Here is how I solved this in MS Excel by writing this VBA macro:

   1: Sub CompleteCategoryRow()
   2: Dim c As Long
   3: Dim r As Long
   4: Dim contents As String
   5: If Selection.Rows.Count <= 1 Then
   6: MsgBox "Nothing selected.", vbOKOnly
   7: End If
   8: contents = " "
   9: For c = 1 To Selection.Columns.Count
  10: For r = 1 To Selection.Rows.Count
  11: If Selection.Cells(r, c) <> "" And Selection.Cells(r, c) <> " " Then
  12: contents = Selection.Cells(r, c)
  13: Else
  14: Selection.Cells(r, c) = contents
  15: End If
  16: Next r
  17: Next c
  18: End Sub

Little side comment: to still get a better readability we could add the following line right after the Else statement’: Selection.Cells(r, c).Font.Color = RGB(255, 255, 255). This would still add the contents but display it with white color. So as long as your background color is white you wouldn’t see it.

Trying to run my MS Excel macro in OpenOffice V3 simply would generate an error as shown below:

Since there is no easy way to convert those macros from MS Excel to OpenOffice I noticed this subject is going to become more complicated and I started to use a different approach in solving the problem: reading. Reading books is supposed to make you smart, isn’t it ? Somewhere I found this book being recommended: “Learn OpenOffice.org Spreadsheet Macro Programming: OOoBasic and Calc Automation: A Fast and Friendly Tutorial to Writing Macros and Spreadsheet Applications” by Mark Alexander Bain.

Chapter 1 on the book describes how to work with the IDE of OpenOffice, chapter 2 how macros are organized – in libraries, modules, sub routines and functions – and chapter 3 is about the OpenOffce Object Model. I found this chapter quiet hard to digest. It introduces UNOs—OpenOffice.org’s Universal Network Objects —and then it is about clients, interfaces, methods and services, things I actually did not really want to read about before being enabled to come up with my first OpenOffice macro.

In Chapter 4 it is getting more practical and the first working macro is shown in sub chapter “Manipulating Spreadsheet Cells”  – not a “Hello World” one, but one which opens up a blank spreadsheet and displays current date and time in the first cell of this sheet.

The follow-on chapters deal with subjects I might be interested in at a later time, like formatting sheets, working with databases, working with other documents, developing dialogs and creating a complete application. Chapter 10 sounds interesting and is about Using Excel VBA in OpenOffice, something for me to read in more detail soon. It mentions that there are plans that a future version of OpenOffice ( written after the book has been published, so may be this is V 3 already ? ) might contain VBA support.

The sample macro from chapter 4 was a good start for me but did not resolve major questions I have had at that point, like especially

  • how to work on the actual spreadsheet already opened,
  • and how to access a range in that spreadsheet currently selected.

The book also contains a link to the OpenOffice API documentation site and some hints how to use that. I googled through dozen of pages in the internet to find a way how to access a selected range in the current active sheet. I finally learned about the getCurrenSelection function in the XModel interface, but it turned out that this API documentation is insufficient: no examples provided how to use it, even no details about what type of object this function would return.

After more googling I was almost ready to give up for now until I got the idea to do what I sometimes do when there seems to be no information available about a particular program: I debug it. The need to start debugging is an indicator that knowledge management has failed so far in providing to you the knowledge you need. Thus: time to find out on your own and may be contributing to the incomplete body of knowledge out there in this particular realm.

The OpenOffice IDE allows to run a macro step by step and to add watch points. Using that feature I explored the object returned by the  getCurrenSelection function and saw that it provides an attribute DataArray giving access to all the cells in a selected range.

With that previously missing piece of knowledge discovered through code debugging I was able to finally come up with this OpenOffice V3 macro BASIC code supposed to do exactly the same thing than my MS Excel macro:

   1: Sub CompleteCategoryRow
   2: xSelection = thisComponent.getCurrentSelection()
   3: If xselection.Rows.Count <= 1 Then
   4:     MsgBox "Nothing selected."
   5: End If
   6: contents = " "
   7: Data() = xselection.getDataArray()
   8: For c = 1 To xselection.Columns.Count
   9:     For r = 1 To xselection.Rows.Count
  10:         If Data(r-1)(c-1) <> "" And Data(r-1)(c-1) <> " " Then
  11:             contents = Data(r-1)(c-1)
  12:         Else
  13:             Data(r-1)(c-1) = contents
  14:         End If
  15:     Next r
  16: Next c
  17: xselection.setDataArray(Data())
  18: End Sub

And, Eureka!, it works ! My first OpenOffice V3 Spreadsheet macro is running, as you can see in this screen cast!

Update:

Pure VBA code works as well in OpenOffice V 3 ! Simply adding “Option VBASupport 1” to the original MS Excel VBA code does the trick, as I learned from chapter 10 of the book I mentioned above. Thus: OpenOffice V 3 includes Microsoft VBA support ! The code shown below works as well and does exactly the same thing than the code I showed above:

   1: Option VBASupport 1
   2:
   3: Sub CompleteCategoryRowVBA
   4: Dim c As Long
   5: Dim r As Long
   6: Dim contents As String
   7: If Selection.Rows.Count <= 1 Then
   8:     MsgBox "Nothing selected.", vbOKOnly
   9: End If
  10: contents = " "
  11: For c = 1 To Selection.Columns.Count
  12:     For r = 1 To Selection.Rows.Count
  13:         If selection.Cells(r, c) <> "" And Selection.Cells(r, c) <> " " Then
  14:             contents = Selection.Cells(r, c)
  15:         Else
  16:             Selection.Cells(r, c) = contents
  17:         End If
  18:     Next r
  19: Next c
  20: End Sub

Intelligent people are bad

Yesterday I finished reading "Lean Brain Management" by Gunter Dueck.  A book about the future which already has begun. A future we either might not want to live in if we don’t change what we are today, or a future which will change us into some(one)thing different. From the very last sentence of the book I conclude that even the author does not want to live in that world he is describing.

Two key messages from the book:

  1. Let’s produce more fakes. They are cheaper to make and usually better than the orignal.
  2. We don’t need intelligent people anymore. We put all the intelligence into our business processes and systems.

My friend and his family visited us on Saturday. His kids are the best example: they definitely prefer some artificial food over any what my wife and I would call real food. Once my wife made mashed potatoes out of potatoes, you know, the real stuff with milk added where you really can taste the real potatoes in it. They didn’t like it. They are used to the artificial mashed potatoes you can buy in the super market, this yellow powder to which you add some water and then you get what is sold as mashed potatoes. A mashed potatoes fake. Everyone can prepare it, and obviously ( for most people ) it is even better than what you could produce on your own with real ingredients and a lot of effort. Fakes are the future !

And fakes are easy to produce. The procedure printed on the back of the package is easy to follow, a four-year-old could do it: put the powder in a bowl, add water, stir, done, enjoy. Simple steps, no training is needed to execute those. This principle needs to be applied to our entire life and to the business of every company. Business processes are designed in such a smart way that no smart people are needed anymore, except the few who would design those business processes and those intelligent systems behind. We have to achieve the ultimate level of specialism.

We don’t need IT architects anymore who know the entire portfolio of our and partners and competitors products. In the future you might become an expert how to install DB/2 version 9.5 on an AIX 6.1 machine. That’s it. Your training will take 4 hours and then you ( or everyone else ) can do the job. We don’t need skilled software developer who “speak” a lot of programming languages and can do software design as well, and testing and documentation of course. In the future programming is not needed anyway, you just sick a view prepared components together and that’s it. Or you become the expert for “for”-loops in Perl. Whenever a “for”-loop is needed somewhere in some perl code they call you. We don’t need project manager anymore who need month and years of training and expertise. We might not do projects anyway anymore, but if we do you might be the expert on how to fill out a change request and they will call you into the project if a change request needs to be filled out.

Intelligent people are bad. They make things complicated and cost a lot of money. To be competitive we have to get rid of them.

I don’t know whether Gunter Dueck has written a book about SOA without knowing it. At least I can not recall that I have seen that acronym anywhere in the book. Wouldn’t SOA be the perfect platform to achieve Lean Brain Management (LBM) ? The more we take out those steps in a business process requiring human intervention, or the more we simplify those, the closer we get to the LBM world. And if we built all smarts into the business process like services disocvering each other automatically and connecting in the right way to execute the business process, or like a SOA Supervisor who keeps track of everything and makes corrections when needed, then we are almost there !

Are we there yet or even close ? The author has his doubts, and I have my doubts too, especially after I have just seen at the end of last quarter when I had to work over the weekend and stay in a manufacturing site in Hungary to help supporting their processes and logistic systems  how many intelligent people have to stand by during those critical days to ensure everything goes smooth and to correct all the unforeseen situations and complicated problems coming up.

LBM can be applied everywhere in our life and the second part of the books describes how LBM can be ( or already is ?) applied to military, science, sex, health, psychology, laws, religion, politics, and management of course.

May be human beings will always fight against LBM. May be it is against our nature. May be we are not willing to give up our brain and what we can do with it. But wouldn’t it bee the smartest thing to do to use our brain to finally get rid of it ?