Since Firefox 30 using unsafeWindow is really not recommended anymore

I had written a little Greasemonkey script allowing to generate some html code from a flickr photo page to use in a blog posting.

Gut gelaunter Baum
"Gut gelaunter Baum" by Axel Magard.

See picture on the right as an example.

That script went to userscripts.org but unfortunately userscripts.org is not available anymore, so you now can get that script from here (OpenUserJS).

That script used code like described here to dynamically load jQuery so that jQuery can be used in that Greasemonkey script. Because of this change in Firefox this code stopped working and I always ran into a Javascript error saying: “Permission denied to access property …”

Luckily this problem has been discussed here on stackoverflow.

The solution: a different way to use jQuery in a Greasemonkey script, bascially thru the @require directive, nicely explained in Taw’s blog here. ( You can check out the source code of my script right away here on OpenUserJS.

jQuery – the best Javascript library ever !

jQuery is my favorite javascript library and luckily it is the most popular at all on the market according to these "Usage of JavaScript libraries for websites".
What I especially like in jQuery is its powerful and consistent way to select DOM elements. Combined with a professional way to use CSS styles and classes it becomes quiet easy to come up with a dynamic full functional web page with a consistent look-and-feel and behaviour.
I have created a jsFiddle here to demonstrate what I am stating here. In this example I have two divs with three paragraphs in each, and thru some buttons I demonstrate how to highlight particular divs or paragraphs and how to easily reset everything to default settings by simply adding or removing a particular class "Highlight" I have created for this. This class could be more fancy than just changing background color, it could come with larger or different fonts, nice borders or whatever you can think of CSS-wise.
jQuery selector like "div#div2" ( choose the div with id "div2" ) or "div p:first-child" ( to select the first paragraph in all divs ) make it really easy to deal with particular DOM elements on the web page.
HTML code:

Code:

<div id="div1">
    <p id="p1">Item 1</p>
    <p id="p2">Item 2</p>
    <p id="p3">Item 3</p>
</div>
<div id="div2">
    <p id="p1">Item 1</p>
    <p id="p2">Item 2</p>
    <p id="p3">Item 3</p>
</div>
<div id="buttons">
    <button type="button" id="b1">Highlight div 1</button>
    <button type="button" id="b2">Highlight div 2</button>   
    <button type="button" id="b3">Highlight all first items</button>   
    <button type="button" id="b4">Highlight 2nd item in 2nd div</button>   
    <button type="button" id="b">Factory settings</button>
</div>

CSS Code:

Code:

div {
    background: lightcyan;
}
.highlight {
    background: yellow;
}

Javascript ( and jQuery ) code:

Code:

$("button#b1").click( function () {
    $("div#div1").addClass("highlight");
  });
$("button#b2").click( function () {
    $("div#div2").addClass("highlight");
  });
$("button#b3").click( function () {
    $("div p:first-child()").addClass("highlight");
  });
$("button#b4").click( function () {
    $("div#div2 p:nth-child(2)").addClass("highlight");
  });
$("button#b").click( function () {
    $("div").removeClass("highlight");
    $("p").removeClass("highlight");
  });

 

I have enhanced my example with a fancy way to highlight the first div: using a blue border and animations.
http://jsfiddle.net/amagard/pB8nx/7/

Kanban in project management

Yesterday I consumed another of the 1-hour-replays of a project management education session I have to go through in order to gain my PMI re-certification in 2016 ( 60 hours of education are required to get re-certified ).

"" by Jim Downing.

This was about the use of Kanban in project management and I found this quiet remarkable.
Kanban – originally invented for manufacturing processes and based on the "pull" principle – can also nicely be used in project management and I guess works best for agile projects. "Pull" principle here means that team members ( analogy to manufacturing operations ) pull work into their working queue from the predecessor rather than getting work pushed into it. That way, and by implementing some rules like Work In Process limits, the project team ( analogy to manufacturing line ) can be better balanced. The "bottleneck" controls how much work can be done overall while avoiding unnecessary Work In Progress queue’s created somewhere else which are usually causing costly non-value-add overhead and the risk of producing too many defective or out-dated work products.
The wikipedia article ( link posted above ) about Kanban in project management has a nice example of a dashboard visualizing user stories and where they are in the project flow. With such a dashboard ( can be a physical white board for a collocated team, or a piece of software supporting collaboration of remote teams, like Apollo Agile PM or KanbanFlow ) it is easy to keep track of the project and see where resources ( aka people ) are missing and what the status of particular user stories is. Swim lanes can be used to keep track of user stories by feature, or to introduce high priority of fire lanes. Also besides user stories defects can be tracked as well – may be using a different color like red of the Kanban cards.

The Servant Leader

Yesterday I consumed one of the 1-hour-replays of a project management education session I have to go through in order to gain my PMI re-certification in 2016 ( 60 hours of education are required to get re-certified ).
It was about the concept of the "Servant Leader" and I found that concept quiet astonishing. Many think of a leader as the one who has people working for him in order to accomplish a mission. According to the nice quote by Dwight Eisenhower:

"Leadership is the art of getting someone else to do something you want done because he wants to do it."

The concept of the "Servant Leader" actually changes the point of view: leadership as a service, so to speak. The leader servers the team to accomplish something. She enables and empowers the team to get the job done. He identifies barriers and moves those away. He coaches and educates and ensures things are moving into the right direction.
Brilliant concept, in my opinion. My current team lead is actually doing a quiet good job with this.
How about you ? Have you ever met a Servant Leader ?

How to write your own OpenOffice Calc Functions

Today I have been looking for a function in OpenOffice which I would call ( and know from many programming languages ) ‘substring’ and which would allow me to split a string into chunks using a pre-defined delimiter and then return one or more words from this collection of chunks. Did I explain this well ? If not, here is an example: from a string like ‘+   6.84%’ I just need the numeric part, the 6.84 so to speak – to then be able to convert that to a number.

Unfortunately such a function is not offered with OpenOffice. Or should I say … fortunately ? Because I actually started to figure out how to write my own functions in OpenOffice using Visual Basic For Applications, aka VBA. And at the end of the day I know how to do this and probably write many more functions in the future.

Here is my substring function in VBA:

Function substring(str As String, start As Integer, optional n As Integer, optional delim As String) As String
  If isMissing(n) Then
      n = 1
  EndIf
  If isMissing(delim) Then
      delim = " "
  EndIf  
  out_str = ""
  cnt = 0
  Dim arr() as String 
  arr = Split(str,delim)
  For i = 0 to UBound(arr)
      If (i+1) >= start Then
          If arr(i) <> "" Then
                    cnt = cnt + 1            ' Ignore empty values
          EndIf
          if cnt <= n Then
              if cnt = n Then
                  delim = ""                ' no more delimiter needed at the end
              EndIf
              out_str = out_str & arr(i) & delim
          EndIf
      EndIf
  Next
  substring = out_str
End Function

As you probably can see it takes a string and a starting position as parameter 1 and 2, the number of words to return and the delimiter to use as optional parameter 3 and 4. Parameter 3 will be 1 as default, parameter 4 a white space, if not specified.

Here is an example how I now can use this function to do my data tweaking together with two of the built-in functions SUBSTITUTE and VALUE to finally achieve what I described above:

=VALUE(SUBSTITUTE(SUBSTRING(SUBSTRING(A1;2;1;” “);1;1;”%”);”.”;”,”))

would get me 6,84 in numeric format if cell A1 contains ‘+   6.84%’.

So far, so good. How to get such a function into OpenOffice Calc ?

It starts with navigating to the Macro Organizer: Tools –> Macros –> Organize Macros –> OpenOffice.org Basic

From here I select “My Macros” –> “Standard” –> “Module1” and then click the Edit button. An IDE for VBA opens allowing me to paste in the code I have shown above. Done.

That IDE is quiet useful since it also allows me to do debugging, like setting breakpoints and inspecting the content of variables.

Do you really need what you want ?

"Do you really need what you want ?" has been the quote on one of my fortune cookies I got with a lunch last week.
This side "This Is Why I am Broke" ( recommended in an article about 15 web sites to visit when you are bored on "digital inspiration" ) certainly offers many funny products I don’t need. Well, frankly: I also wouldn’t want most of those, for instance this one:

And certainly not this one:

Data Volume 2012

1.8 zettabyte of data has been produced world wide in 2012, according to bild der wissenschaft plus "Auf in die Zukunft".
That’s a lot. That’s 1.8 times 10 million petabyte. 1 petabyte is 1000 terabyte. 1 terabyte 1000 gigabyte.
1.8 zettabyte is ~ 200 × estimated information content of all human knowledge (as of mid-1999), according to Wolfram Alpha.
And here is another interesting figure from this magazine: there are 18 victims of cyber crime every second, 1.5 million daily, according to Symantec’s Cybercrime Report.
Welcome to the era of "Big Data" !

Follow

Get every new post delivered to your Inbox.