“What” is more Important than “How”
June 10, 2010
The return on an investment in “How” is much less than the return from an investment in “What”.
Learning about “What” concerns itself with things like “what exists?”, “what do people want?” and “what can be done?”. Learning about “How” concerns itself with “how is this done”, “how does that work”, “how do they do that”. Knowledge about “What” leads to answers about “when” and “why”. These kinds of answers lead to leverage which can lead to profit. Learning about “How” is easy but leads only to competition. Anyone can learn “How” to do something, but if they don’t know when or why, then they’ve only positioned themselves to be used like a tool.
Tools are interchangeable so the ones who know “How” are easily swapped around leaving them with no real power over their destiny. Tools can also become obsolete and get replaced by something better. If the only goal is acquiring knowledge about “How” but no research into “What” has been done then good decisions about picking the “How’s” to invest in can’t be made.
To be really useful as an individual or company, it’s knowledge about “What” that is most important.
Safari 5 – Reader feature
June 8, 2010
The newest version of safari came out today and I really like the new “Reader” feature which allows the user to better focus on the article that they are trying to read. I’m not sure how sophisticated it is yet but it’s supposed to detect multi-page articles and merge them into one page and also provides some additional controls for sharing. It removes the clutter of adds and other surrounding content to make for a better reading experience. Yesterday I found this article which suggests that the busyness of the internet makes it hard to focus in and understand what we are reading. Maybe this new safari feature will help with this. I’ve attached a video demonstrating the Reader feature in Safari 5.
I was looking through some old code I had written and found this small and cryptic method for converting a number of seconds into a string containing of this format “hh:mm:ss” and I will describe how it works. First, the code:
def seconds_to_time(secs)
hms = [3600, 60].inject([secs]) {|x, y| x += x.pop.divmod(y)}
return hms.map {|y| "%02d" % y}.join(":")
end
This method leverages the behavior of the Enum.inject method and the Numeric.divmod method to creatively convert the seconds into an array containing hours, minutes and seconds. It then utilizes the Enum.map method to join these values into a recognizable time string. Here is some sample output:
puts seconds_to_time(63628) 17:40:28
The inject method is passed in a starting value and on each iteration the return value of the previous iteration is passed again. This parameter is commonly called an accumulator. The accumulator shows up in the provided block as the first block variable called x. The initial value of this accumulator is an array containing the original seconds. The second parameter to the block (y) is the value from the original array that is the focus of the current iteration. In this example y starts out as 3600.
In the first iteration this value is pop’d out of this array and the divmod method is called passing in the first value from the array that inject is being called on. This value is 3600 and represents the number of seconds in one hour. The return value of the divmod method is an array with the integer part as the first position and the remainder as the second position [17, 2428]. Since the original seconds were pop’d from x, x will now be empty and += will cause x to fill up with the 2 values that were returned from divmod. At the end of the first iteration of the inject method the accumulator variable will contain [17, 2428].
In iteration 2 y is set to 60 which is the number of seconds in a minute while x is set to the value of the accumulator from the previous iteration [17, 2428]. 2428 will be pop’d from this array and divmod will be called on this value with a parameter of y. The result of this call is the array [40, 28] which represents the number of minutes in 2428 seconds and the remainder. This array is then appended to x causing it to become [17, 40, 28] which is the end of our second iteration.
Since this is our last iteration the return value for the inject call will be the array [17, 40, 28]. This array is then map’d into an array of strings formatted as 2 digit integers. This step is needed to pad single digit positions with a leading zero. The final step is to call the join method to glue these pieces together with a colon.