Chunked Array

Posted on February 25, 2007
Split an array of elements into a set of smaller arrays of equal size. Extra elements are preferentially assigned to earlier arrays. If there are no elements in a given returned array it will be [] (empty array)

# use as standalone function 
def chunk_array(array, pieces=2) 
len = array.length; 
mid = (len/pieces) 
chunks = [] 
start = 0 
1.upto(pieces) do |i| 
last = start+mid 
last = last-1 unless len%pieces >= i 
chunks << array[start..last] || [] 
start = last+1 
end 
chunks 
end 

# use as array.chunk 
class Array 
def chunk(pieces=2) 
len = self.length; 
mid = (len/pieces) 
chunks = [] 
start = 0 
1.upto(pieces) do |i| 
last = start+mid 
last = last-1 unless len%pieces >= i 
chunks << self[start..last] || [] 
start = last+1 
end 
chunks 
end 
end 

Colorzilla finally up and running on Mac Intel

Posted on February 13, 2007
A few months ago since switched over to my new Intel-based MacBook from Windoze based notebook, I been using Colorzilla all along, the support on Mac is not available way back, and finally now it comes with sweet Intel Mac and Firefox support. Beside, alternatively before this, i also use Color Schemer which is also a cool software, but its not free :-) Try it out, friends.

Colorzilla

Color Schemer

Web 2.0 Digital Ethnography

Posted on February 11, 2007


This video really illustrate what I am doing now, its time to think about my life and grasp the essence of life, again there is nothing right or wrong situation. Web is something changing my lives now and I also being too exaggerated about it.

Web 2.0 ... The Machine is Us/ing Us

Programmers don't like coding, they like problem solving.

Posted on February 06, 2007

If programmers liked to code, we'd all be writing in machine language to this day. You can write that stuff all day and get precious little of the real problem solved. If programmers liked to code, they wouldn't value a language by its libraries. If programmers liked to code, every last one of us would be overjoyed to write our own HTTP client.

Instead, programmers get pissed when they have to write code. They will abandon languages/platforms wholesale that lack the features they need (either built-in or as libraries). From an outsider's vantage, I can see why they'd think we like coding. We solve problems by coding, and we're all happy and enthused while typing away or talking code. But they're confusing the action and the intention. It's not pulling the trigger that makes me happy, it's hitting the target. The action approaches incidental.

Another reason outsiders think we like to code is that we're always talking about rewriting things. Even coders themselves fall into the delusion we rewrite because it's more fun than reading other people's code. Bad source bases irritate programmers because it shakes their foundation of understanding necessary to solve the problem. I reject the explanation that programmers capriciously want to rewrite code for the fun of it.

Programmers desire to rewrite because they know that after starting with a clean sheet of paper and building it all again, at the end they'll understand the whole. Programmers write code to learn. Software has this double-edged sword where you can't just wave your hands instead of implementing a particular function. It all has to be crystal. Programmers know this. They know when they're done, they'll have a complete understanding. It's a noble desire.

Programmers don't like to code, we like to solve problems. Coding is not problem solving, but software problem solving usually involves some coding. Even when we talk about rewriting something, the objective is not to code, it's usually to get a better understanding of the problem for solving in the best possible manner.

Windows Vista Recommendation

Posted on February 01, 2007