Author Archive for Zz85-nds

Ping Me? Meaning of Words

My housemates and I have interesting conversations at times @ home.

Mr Krishna was telling me about how he didn’t understand the meaning of ping used here, like “Ping me when you’re done” or “I’ll ping you”

So I reply that meanings of words change, and many a times it get derived so much it doesn’t reflect its original context or meaning. Nevertheless its good to know its original meaning and know how it evolved. So while the technical guys know the purpose of “ping” or the IMCP echo, some might think that ping came from “ping pong” (table tennis), as seen in the IRC days. The most likely inspiration of the word ping would be sound waves created by sonar in submarines.

Another interesting topic is “blog” (in its context have another meaning for ping too), derived from weblog, was in fact a technical term for a developer’s/designer’s tool. After some time, blog was almost a synonym to “online diary” and these days blogs has also almost become an essential part of online marketing.

Other times brand and product names affect people’s vocabulary too. For example, most people doesn’t seem to know that “Rollerblade” is in fact just a brand for the sport “In-line skating”. Photocopying could be called “Xerox” in America, and “zapping” in Singapore. I used the word “Scotch tape” for years before knowing its a trademark for a adhesive tape product.

Then the singaporean language “culture” or Singlish is a big culprit of giving new meaning to words, infecting the native English, Malay and Hokkien. And for that we have a few online Singlish dictionaries here and here.

Its interesting but whether this word morphing culture is good or not, I don’t know. We tend to get petty smart and lazy using such words, but at the same time we are adding more definitions to our dictionary entries.

Shell Script for Looping Each Directory

Let’s say you are creating a batch script to loop through each “folder” you have in an directory- run:

$./list_dirs.sh /app

inside the shell script:
#list_dirs.sh
for i in $(ls -l $1 | awk ‘/^d/ { print $NF }’) ; do
echo $i # replace with actions to be done
done
#end script

basically ls -l will display all files+folders with their attributes.
awk filters to those lines starting with d attribute (/!d/) and strips out to the last field ($NF)

blog>logout

Pickup Basketball (in the valley as usual)

Jogging in the evening breaks me out of the lethargy, and I enjoy the sky as it displays a beautiful blue gradient facing when facing eastwards and the melting golden orange at the tip of roads and houses westwards.

1 mile away from my home (away from home) is Washington park, a small area where grass and trees fills, picnic tables for gathering, and playgrounds and tennis courts for the municipal’s recreational needs. There in the park lies 2 basketball courts, some playing teams while some shoot baskets. I asked to join in shooting, and not long later I got the opportunity to play teams.

Having played basketball daily some years in high school, and I thought it doesn’t matter where I was, because the basketball, rim and net stays the same. True, the culture was similar in some ways, shooting in for teams, shooting 1s for fouls, but the mind needed some explicit translation to understand the lingos as I’ve used all those in chinese only.

The biggest exposure to me was the mix of people. Students to working adults, residents from mountain view to santa clara, from white and black americans, indians, mexicans to chinese, all mixing in teams to play. Responsibility in the game increased as I had to switch from my norm of zone defence to Man-on-Man.

And so that one of the things I didn’t expect myself to do here, yet experiencing familiarity with the scent of freshness.

For Each Loops

Looping through each item in a collection is usually mandatory in programming, yet its fun and easy.

Here’s how to do it in different languages.

> php
foreach($array as $key => $value):
# use these variables
print($key.’ -> ‘.$value.’
‘);
endforeach;

> javascript/actionscript 3
for (var obj in window){
document.write( ‘window.’+obj +’ =>’+ window[obj] );
}

note the difference between the java and javascript’s loop is that the obj in js for returns the index of the item rather than the object itself.

> java 5
for (Object var : collection) {
// Do your stuff
}

> python
for item in container:

> shell
foreach {i j} {a b c d e f}

The fun part with looping a collection is that there isn’t a need to define indexes and limits for the loop. Sometimes in situations I have a fix loop but still prefer a for-each loop, I’ll create a predefined collection, perhaps a json array for javascript and associative collection for php, then run a for each loop over them.

This should be pretty old stuff and I’ve been thinking of this post long ago but really didn’t get my fingers typing until now.

Jogging in the Valley

The air is cold.

The ears freeze

The brain spins

The fingers numb

The nose runs

The air feels thin

and

The lungs scream