Yesterday, my father gave a marathi book - 'Hasgat' to me. It is written by a well known and my favorite marathi actor Dilip Prabhawalkar. I could not resist myself to read his book. The book made my travel to office and back to home journey jovial.
The book is a collection of short stories which can be enjoyed any time. The common thread that binds these stories is the element of situational humour and the naive characters in each of these, reminiscent of the P.G. Wodehousian style, which has admittedly been one of Prabhawalkar's literary influences.
Dilip Prabhawalkar has done a great work in theatre, cinema, television and as a writer as well. Please take a look at his website :- http://dilipprabhavalkar.com/v1/indexHtml.htm
I have watched his drama - 'Hasvaphasvi' at least 8 to 10 times. You can see the pictures of six different character roles that he played in that drama at : http://dilipprabhavalkar.com/v1/hasvaphasvi.htm
Isn't it awesome ? :-)
Enjoy reading ...
Thursday, July 22, 2010
Tuesday, July 6, 2010
Augmented Array in Ruby
Few days ago, I was randomly going through the Ruby Array class API and the method '*' caught my attention.
array * int -> an_array : Returns a new array built by concatenating the int copies of self.
[ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
I just had a thought can I have a method named '/' which will return a new array by splitting the array into arrays of int divisor elements each ?
The functionality that I was looking for :-
[1,2,3,4,5,6]/1 # => [[1], [2], [3], [4], [5], [6]]
[1,2,3,4,5,6]/2 # => [[1, 2], [3, 4], [5, 6]]
[1,2,3,4,5,6]/3 # => [[1, 2, 3], [4, 5, 6]]
I gave it a try, my fingers typed the code as per my brain's instructions and it worked the way I expected.
Then I saw the methods at(index) and fetch(index) and thought can I fetch or even set the elements of the array with the index as if index acting as array's attributes ?
Like this :-
ary = [1,2,3]
ary._0 = 25
ary._0 # => 25
ary._1 = 10
ary._1 # => 10
ary # => [25, 10,3]
For the above to work, I played with the method_missing method.
Few things that I noticed in the Array class were it has 'first' and 'last' methods but not 'first=' and 'last=' methods. It has 'nitems' method which returns the number of non-nil elements, but no 'nilitems' method which will return nil elements in the array.
My mind started to think whether I can build some other useful methods as well and it came to a sufficiently big list which I finally moved into a gem. I named the gem as 'augmented_array' and pushed it to gemcutter.
Install:
====
gem install augmented_array
Uninstall:
====
gem uninstall augmented_array
Source Code is available at my Github repository.
array * int -> an_array : Returns a new array built by concatenating the int copies of self.
[ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
I just had a thought can I have a method named '/' which will return a new array by splitting the array into arrays of int divisor elements each ?
The functionality that I was looking for :-
[1,2,3,4,5,6]/1 # => [[1], [2], [3], [4], [5], [6]]
[1,2,3,4,5,6]/2 # => [[1, 2], [3, 4], [5, 6]]
[1,2,3,4,5,6]/3 # => [[1, 2, 3], [4, 5, 6]]
I gave it a try, my fingers typed the code as per my brain's instructions and it worked the way I expected.
Then I saw the methods at(index) and fetch(index) and thought can I fetch or even set the elements of the array with the index as if index acting as array's attributes ?
Like this :-
ary = [1,2,3]
ary._0 = 25
ary._0 # => 25
ary._1 = 10
ary._1 # => 10
ary # => [25, 10,3]
For the above to work, I played with the method_missing method.
Few things that I noticed in the Array class were it has 'first' and 'last' methods but not 'first=' and 'last=' methods. It has 'nitems' method which returns the number of non-nil elements, but no 'nilitems' method which will return nil elements in the array.
My mind started to think whether I can build some other useful methods as well and it came to a sufficiently big list which I finally moved into a gem. I named the gem as 'augmented_array' and pushed it to gemcutter.
Install:
====
gem install augmented_array
Uninstall:
====
gem uninstall augmented_array
Source Code is available at my Github repository.
Thursday, July 1, 2010
The One Minute Manager
Yesterday I read a management book - 'The One Minute Manager' written by Ken Blanchard and Spencer Johnson. I liked that book very much. It's practical. It includes some examples demonstrating how you can effectively handle the people under you. By the book definition, effective managers manage themselves and the people they work with so that both the organization and the people profit from their presence.
The metaphor, The One Minute Manager means it takes very little time for that manager to get big results from people and behind this success lie just three secrets :-
- One minute goals
- One minute praisings
- One minute reprimands
One should read this little book to know more about these secrets.
It is really good to know that the leaders of American and Japanese industry have made this book compulsory reading for all their managers.
Enjoy reading ...
The metaphor, The One Minute Manager means it takes very little time for that manager to get big results from people and behind this success lie just three secrets :-
- One minute goals
- One minute praisings
- One minute reprimands
One should read this little book to know more about these secrets.
It is really good to know that the leaders of American and Japanese industry have made this book compulsory reading for all their managers.
Enjoy reading ...
Subscribe to:
Posts (Atom)