23 January 2011

gdb trick for printing array content

This is taken from Fedora planet, somekind of blog aggregator of the member of Fedora Community. This post discusses about the way we can print array values in gdb.

Here is the link http://wagiaalla.com/2011/01/20/gdb-tricks-printing-arrays/, written by Sami Wagiaalla.

....And here is some excerpt from it:

 int main(){
   int *a;
   int b[3] = {1,2,3};
   a = b;

   int *c[3] = {a, b, 0};
   int **d = c;
   return 0;
 }

   While debugging the above code if you do:

 (gdb) print b
 $4 = {1, 2, 3}

   that works.

 (gdb) print a
 $5 = (int *) 0x7fffffffe0f0

   that works too, but in order to print a as an array you must do:

 (gdb) print (int []) *a
 $7 = {1}

   and when you specify the size it gets better:

 (gdb) print (int [3]) *a
 $8 = {1, 2, 3}

regards,

Mulyadi

05 January 2011

Money saving: how exactly we do that?

This is taken from a posting I received from PROFEC, an Indonesian entrepeneurship mailing list. Pretty interesting and valuable on how you're supposed to save your money. Please read on....


In a public financial training, a Financial Planner (FP) asked the participants: "How much money do you usually save every month? "

So many versions of the responses from the participants but it appears a remarks that said: "Saving? Just for a standart living alone is not even enough! "

Financial Planner (FP): "So, how many person in this room who do not have the habit of saving each month?"

Nearly half the participants raised their hands.

FP: "Why are you reluctant to save each month?"

Budi: Well, Sir, like my friend has said, was "...for living alone is just barely not even enough! "

FP: "Well now let me kindly ask you :what's the principle of saving as you know? "

Budi: "At the beginning of each month, I shall allocate my money to cover the expenditures that month, including paying existing debts and bills. If there are some amount of money left, I will save them. However, the problem is, every month there's virtually nothing left in my pocket."

FP: "(laughing) yes that is why you can not save because that is a wrong mindset. The correct principle of saving money was not from residual income but it is budgeted. Then you allocate the rest of your income to cope with the expenses".

Syamsul: "Ah yes. I read that principle too, which says that saving is done in front. Which is called "Pay yourself first?"

FP: "Yes principally, do that in front or we could say  "pay yourself first". Why? Because there is a financial law applicable universally known as Parkinson's Law. The law says that any income earned by
someone will be soo caught by the amount of expenditures. Let's say your income is 1 million rupiahs, then your spending will likely approach or exceed 1 million.

When you get to 3 million increase in income, then your spending will somehow increase to 3 million too. Hence you barely have nothing to save."

Syamsul: "It means the more income I have, the more expense I shall have too?"

FP: "Exactly and this is causing a lot of people unable to save money. Because their expenses are close to or even exceed their income."

Budi: "Then how are we supposed to save exactly?"

FP: "Take a percentage of your salary and then save or invest thme. The allocate the rest to cover the expenses accordingly."

Syamsul: "What is the ideal percentage on how much we should save?"

FP: "It's up to you. You may decide the percentage initially, then adjust it to meet your financial ability and then gradually increase up to 10-30% of your total monthly income. Practice this habit and you can always save no matter what."

Syamsul: "Yes I totally agree and this will be our new year's resolution for me and family."

-00 -

Why are people unable to save money? Actually there's no such big issue, just wrong mindset. So change your mindset and your life will change too.

-Change Your Mind Change Your Life-

regards,

Mulyadi.

02 January 2011

How to fix stuck mouse in aptosid as KVM guest ( + broken DNS resolve)

There's a small irritating problem when you install aptosid as KVM (Kernel Virtual Machine) guest: mouse "stuck"! When I take the focus to the KVM's SDL guest window, it just stays there.... For the record, I used aptosid-2010-03-apate-kde-lite-i386-201012262151.iso as the installation basis.

Turns out, you have to uninstall these packages (somehow they are installed automatically due to unknown reason). To avoid trouble, run it in either run level 2 or 3:
xserver-xorg-input-vmmouse
xserver-xorg-video-vmware

Just to be safe, uninstall virtualbox-ose-guest-x11 and virtualbox-ose-guest-utils too.

Re-run X again. You should be just fine this time.

PS: I also noticed I can't resolve any host names initially ( I used e1000 ethernet card emulation). What's the solution? Rather cheating actually: switch back to your terminal. Resolve the name of hosts mentioned inside /etc/apt/sources.list.d/ files, you may use "host", "nslookup" or "dig" command or else. Got the IP address? Good. Paste them inside those files. Then do:
$ sux

# apt-get update
# apt-get dist-upgrade
# apt-get install dnsutils

I have no idea why dnsutils is left behind.......so there you go.

regards,

Mulyadi

15 November 2010

What relationship really is? (no craps, no bulls, just reality)...

I got really nice advice today...opening up my mind about what the relationship really is:

"......
I think that you need to evaluate that very carefully. If you argue, but the underlying premise is always that you care about each other and respect each other, that's fine. But if the arguments ever turn vicious or ugly, and end up with one of you feeling like a loser... that's a pretty bad sign.

I like to think of "good" arguments as "you and me against a problem" and bad arguments as "you and me against each other"
......"

NB: It's Ben Okopnik of Linux Gazette who said that...thanks Ben...really..from the bottom of my heart...

regards,

Mulyadi Santosa

01 November 2010

Installing Microsoft True Type fonts in Linux....

Recently I got my hand dirty again on reconfiguring my notebook. One of the thing that I did was installing Microsoft True Type Fonts inside Linux. Simply follow the directions written in http://corefonts.sourceforge.net/.

The only problem lies in the fact that the spec file use somewhat wrong download URL. So, to solve that, I made a trivial patch to adjust the spec file here.

Just put the spec file and the patch at the same directory and do:

patch  < patch.txt


Replace "patch.txt" with the actual name of the downloaded patch file name. That should do it :)

regards,

Mulyadi

07 October 2010

Online discussion about what /proc/meminfo is....

Everybody has ever seen the file /proc/meminfo, right? Great, but quite likely few of you really know the meaning of each fields there.

So, to help you understand those fields, I have given short lecture (and question/answer too) about it in #ubuntu-classroom in irc.freenode.net server. It was held in October 6th 2010, 21:00 GMT+7. Yeah, it is past already, but fortunately you can read the chat log here (note: the_hydra is me):

Feel free to stop by and read it. Have feedback? Let me know at my usual contact addresses and I shall reply as soon as possible.


regards,

Mulyadi

08 September 2010

Open Letter to the President of Indonesia

Kepada Yth Presiden RI Dr. Susilo Bambang Yudhoyono, hendaknya bapak berkaca bahwa kritikan dari seorang Kolonel AU aktif, menandakan ada suatu ketidakpuasan level akut, tidak hanya di jajaran militer, namun pada sebagian rakyat Indonesia.

Bapak Presiden, selaku Presiden terpilih dengan suara mayoritas ~ 60% saat pemilu 2009, seyogyanya memperhatikan hal ini sebagai masukan positif dan memperbaiki pola kepemimpinan yang sedang Bapak jalankan.

Alam demokrasi yang sedang bertumbuh, memungkinkan rakyat memberi masukan langsung pada Bapak, tidak lagi selalu lewat kanal2x politik formal yang lebih banyak tersumbat.

Saya percaya, Bapak sebagai seorang terpelajar dengan gelar Doktor, mampu menganalisa hal ini dengan seksama dan sistematis, serta cepat tanggap mengambil langkah-langkah strategis dan terukur guna membenahi lini-lini pemerintahan yang masih belum beres.

Adapun yang saya juga harapkan adalah, Bapak bisa lebih intens mengefektifkan komunikasi dengan rakyat. Dengan demikian, syak praduga WNI bisa terkikis dengan sendirinya karena rakyat jadi tahu persis rencana2x kepemimpinan Bapak.

Kiranya Bapak juga menyadari, dalam aspek-aspek tertentu, Indonesia sudah mengalami kemerosotan yang tajam di berbagai aspek ketata negaraan. Diperlukan suatu strong leadership dari Bapak selaku presiden, juga kemampuan mengajak segala elemen bangsa untuk bersama-sama membangun. Bapak juga harus tegas, saya ulangi, TEGAS, memberi hukuman sesuai perundangan yang berlaku, pada siapapun yang mengacaukan negara ini, tanpa pandang asal usulnya.

Semoga negara ini selalu dalam lindungan Tuhan YME dan dilimpahkan rahmat agar menjadi bangsa yang bermartabat.

dari seorang warga negara yang prihatin....

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...