19 July 2010

Exercising my mind differently (not an "Inception" copy, guys...)

While lurking on World Wide Web (a fancy and elegant way to say "I have nothing to do, so I kill time by putting my ass on a chair and look at the monitor like plain dumb ass :)" ) I saw a picture displayed that depicting an old lady. But, it asks, "do you see a young lady?". Nice eh?

At a glance, I recall that once I already solved this, but I forgot the way I did it. And I also recall, I can't see it under split second. Thus it reveals one thing for me: I am a focused man...but probably too focusing on something.

So I start to see "in big picture". I try to shift my focus...hair, cheek, nose, all over the spots. I imagine those points as my "center of thought". And whaaalaaa, got it. I see young lady, when I shift my focus to the cheek and also "rotate" my mind thus here you are: a young lady turning her head to right.

NB: Can't tell where I get this quiz, so Google is your friend fellah.

NB2 : Inception is damn great movie, pal....move your ass and see it on cinemas right now! :) it will blow your mind and make you easier to explain to gals why you frequently dream as porn star rather than a nice boy ... :D

PS: I put Buddha Gautama words a bit fancier "when you think awful, you'll see the world as a plain shit garbage, but when you think calmly and straight, you shall see its wonders and miracles". Something to thought about....

17 January 2010

grep [s]tring anyone?

This is another grep's adventure. It started from a thought: "is there a simple way so that when I grep for something, let's say ps output, grep itself isn't shown there?"

My usual recipe is like below:

$ ps auxw | grep httpd | grep -v grep

But recently I found a neat trick:

$ ps auxw | grep [h]ttpd

Why is that working? Imagine that in the previous command , "ps auxw" would output these two lines among others:

mulyadi 30632 0.0 0.0 5852 1516 pts/8 Ss+ Jan09 0:00 httpd
mulyadi 30950 0.0 0.0 5852 1420 pts/9 Ss+ Jan07 0:00 grep httpd 

When you find for httpd, of course both of them will be caught because both of them has "httpd" string. The situation change for the 2nd command:

mulyadi 30632 0.0 0.0 5852 1516 pts/8 Ss+ Jan09 0:00 httpd
mulyadi 30950 0.0 0.0 5852 1420 pts/9 Ss+ Jan07 0:00 grep [h]ttpd

'What, how come?" you say? Recall you invoke "grep [h]ttpd", right? So, that's what displayed in ps. But grep interpret this regular expression differently. It means "I search for httpd", not "[h]ttpd". Everything enclosed in [] is something to search for, unless the "[" or "]" is escaped.

Clever trick I would say.... took me a while to understand it.

20 December 2009

Hopefully these online test results are credible enough to say something about me....



One small question: are odesk.com online tests credible enough to show whether somebody is competent or not in his/her field?

Google sense "something" about this online store :)

 Does Google smell something "fishy" with this online notebook store? Could you tell? :D

12 December 2009

Contributing to laptop mode tools

As confirmed by laptop mode tools' changelog, my patch is finally merged into their core code. I simply contribute few line to show statistics regarding write and read frequency of every programs recorded during lm-profiler's runtime.

So, how the code looks like?

—- lm-profiler.old2009-06-03 21:12:52.000000000 +0700

+++ lm-profiler2009-06-26 21:08:54.000000000 +0700

@ -209,6 +209,11 @


done
printf ’\r \r’
stop_profiling

+

+echo “Write frequency : ”; cat $WORKDIR/write_accesses_* | sed -e ’s/[ \t]*//;s/[ \t]*$//’ -e ’/$/ d’ | sort | uniq -c | sort -n

+echo “Read frequency : ”; cat $WORKDIR/read_accesses_* | sed -e ’s/[ \t]*//;s/[ \t]*$//’ -e ’/$/ d’ | sort | uniq -c | sort -n

+echo;

+
NETPROFILE=`profilenet`
echo “Profiling run completed.”

Looks awful? I admit it. In short, it grabs files created by lm-profiler during its run time, trims out the blanks and then sort them, while at the same time showing their frequencies ascendingly.

NB: Actually it's for my own reminder, but to share with you all. To easily convert text to HTML (and dealing with all those escape characters etc), you could use http://www.textism.com/tools/textile/index.php. Simply paste your text there and click the button, voila..you get the HTML-ized text!

regards,

Mulyadi

25 November 2009

Why so serious? :D

Got this quote from kernelnewbies mailing list....hehehehheheheh :D

"What happens when you read some doc and either it doesn't answer your question or is demonstrably wrong? In Linux, you say "Linux sucks" and go read the code. In Windows/Oracle/etc you say "Windows sucks" and start banging your head  against the wall."

-Denis Vlasenko on lkml

PS: s/banging your head*wall/take it for granted/g is better I guess :D I believe many Linux users also bang his/her head when learning Linux for the first time. :))

Moral: just don't bang your head too hard, it hurts, you know? :D

09 November 2009

how to catch white space(s) using grep?

My definition: White space characters are anything that appears as "blank" a.k.a nothing in screen. They include tab, space, carriage return and so on.

As you know, grep provides a way to catch certain characters class or range. Specifically for white spaces, you can use [[:space:]] or [[:blank:]]. Notice the double [[ and ]] !!!

So, suppose you have text file named test.txt that contains:

     hehe /var/www/
hehe /var/www2/
ttt hehe /var/www3/
     heho /var/www/

Executing:

$ grep ^hehe test.txt

will yield:

hehe /var/www2/

but this:

$ grep -E '^[[:blank:]]*hehe' test.txt

yields:

       hehe /var/www/
hehe /var/www2/

In human words, '[[:blank:]]*' will catch zero or more appearance of space or tab before the word "hehe". If you want to catch at least single appearance of any of them, use "+" instead. Oh and let me remind you again, use -E so that "+" doesn't lose its special meaning.

Note: initially, i thought i simply use [:space:] or [:blank:] and end up in something-is-wrong-but-I-dont-know-what land. Turns out, I didn't read the man page carefully (poor me). Since they are built-in classes, I still need to enclose them with another "[" and "]". Valuable experience.....

regards,

Mulyadi.

How to execute multiple commands directly as ssh argument?

 Perhaps sometimes you need to do this: ssh user@10.1.2.3 ls It is easy understand the above: run ls after getting into 10.1.2.3 via ssh. Pi...