Posts

Showing posts from 2012

Shell Profile Reload

For those of you, who are familiar with shell in Linux or Unix environment, the file .bash_profile (or .profile in Mac OS X) must already be familiar. This file is used to store initialisation commands to be used for the entire shell session. Example of things you can put into this file is putting alias for commands and registering environment variables. As the .bash_profile and .profile are just regular files, we can change it at any time. However, it will be quite a hassle if every time we change the file we need to close and open a new shell window. There is a command that we can use to re-run the profile file on the fly. Following is the full command you can use to do that. Under Linux source ~/.bash_profile Under Mac OS X source ~/.profile Hope this helps you. Have fun.

Public Key Infrastructure Fundamental (Part 2)

Image
This post is a continuation (par 2) of my post that can be found here . In this post, I am going to discuss about Public Key and Private Key . Public Key Public key can be defined as a value provided by some designated authority as an encryption key that, combined with a private key derived from the public key, can be used to effectively encrypt messages and digital signatures. Private key will be discussed below. Private Key Private key can be defined as an encryption/decryption key known only to the party or parties that exchange secret messages. Public-key Encryption Source: Globus As you can see from the above image, the public-key and private-key are both used in the encryption process in the PKI. One think you need to remember, we use the receiver's public-key as the key to encrypt the message. On the other side, the receiver, will decrypt the message using the private-key that he has. To simplify things: Think of a public key as being the lock. It’s no

Simple Paging

Paging literally means making data displayed in multiple pages. Paging is used specially for website, where displaying large amount of data can be so troublesome by making the downloaded data bigger and thus increasing the response time. Paging can be done in many ways. In this tutorial, I would like to show you a very simple method we can use to do the paging. Here, we just need to enable the user to move to the next page (if any) and back to the previous page (if any). Also, for the sake of simplicity, I will use dummy data stored hard-codedly into an array. However, the concept is similar. OK, let's start !!! /* Maximum number of items to show, per page */ $maxItemPerPage = 10 ; /* * Prepare the dummy data * Used just for the sake of this tutorial. */ $data = array ( ) ; for ( $i = 1 ; $i <= 112 ; $i ++ ) array_push( $data , "Item " . $i ) ; First of all, we define the maximum number of items to show per page. In

Faster Prime Number Checker Algorithm

Checking for prime number is actually a simple one, but can sometimes be very tricky for big number. Though there exists more powerful algorithm to check for prime number, here I want to show you one simple algorithm that is proved to be fast enough. // // main.cpp // Prime Number Checker // // Created by Handra on 5/1/12. // Copyright (c) 2012 Handra. All rights reserved. // #include <iostream> #include <cmath> using namespace std ; /* Function prototype */ int isPrime ( int number ) ; int main ( int argc , const char * argv [ ] ) { int number = 12 ; cout << "Is Prime: " << isPrime ( number ) << endl ; return 0 ; } int isPrime ( int number ) { /* Every number below 2 is not prime */ if ( number < 2 ) return 0 ; /* Calculating the limit for denominator */ int limit = ( int ) sqrt ( number ) ; /* Start the denominator from 2. We know that every number divided by 1 must have

Einstein vs Professor

Image
This story is retrieved from the Internet. Though the authenticity of this conversation is still in question, it's still worth it to read. Enjoy. Professor : You are a Christian, aren’t you, son ? Student : Yes, sir. Professor : So, you believe in GOD ? Student : Absolutely, sir. Professor : Is GOD good ? Student : Sure. Professor : Is GOD all powerful ? Student : Yes. Professor : My brother died of cancer even though he prayed to GOD to heal him. Most of us would attempt to help others who are ill. But GOD didn’t. How is this GOD good then? Hmm? (Student was silent.) Professor : You can’t answer, can you ? Let’s start again, young fella. Is GOD good? Student : Yes. Professor : Is satan good ? Student : No. Professor : Where does satan come from ? Student : From … GOD … Professor : That’s right. Tell me son, is there evil in this world? Student : Yes. Professor : Evil is everywhere, isn’t it ? And GOD did make everything. Correct? Student : Yes. Pr

Public Key Infrastructure Fundamental (Part 1)

Image
Public key infrastructure is an infrastructure developed to ensure the data security that is being transfered within insecure network. Public-Key Infrastructure Source:  Wikimedia If we talk about PKI, we will talk about some common terms used in this area, such as  encryption , digital signatures , public keys , private keys . In Part 1 of this post, we will explore about the two terms, which are encryption and digital signatures . Public keys and private keys will be discussed in Part 2 of this post. Encryption Encryption can be considered as a process to disguise something as something else. This is most likely similar with people write letter to other using words that are understood just between them. This way, even if the letter is being stolen, the bad guy will not be able to read it and understand the content of it. Besides encryption, there is another term known as decryption . Decryption is basically the reverse process of encryption. It means that, we t

Kisah Dua Buah Karung Goni

This post is in Bahasa Liu Gang adalah seorang terpidana kasus perampokan, dia sudah dipenjara selama satu tahun dan tidak ada seorang pun yang pernah datang menjenguknya. Ketika menyaksikan narapidana lainnya dalam selang waktu tertentu selalu saja ada orang yang datang menjenguk dan menghantarkan segala macam makanan enak, mata Liu Gang menjadi gatal, maka dia lalu menulis surat kepada ibunya da ... n meminta mereka untuk datang, bukan demi makanan enak, hanya karena rindu pada mereka saja. Namun setelah tiada terhingga lembar surat yang dikirimkannya bagaikan tenggelam di laut saja, Liu Gang akhirnya mengerti kalau ayah ibunya tidak menginginkannya lagi. Dalam kesedihan dan keputus-asaannya, dia kembali menulis selembar surat, di dalamnya dikatakan jika ayah ibunya masih belum datang juga, maka mereka akan kehilangan anaknya ini untuk selama-lamanya. Ini bukan lampiasan kekecewaan, tetapi dikarenakan beberapa orang terpidana hukuman berat sudah beberapa kali

Thresholding (Iterative Method)

Image
Thresholding is inevitably one of the mostly used image processing algorithm. It is told as the simplest method of image segmentation. In this post, I want to introduce one thresholding algorithm that is powerful enough yet simple enough to implement. The method called "Iterative Method." Below is the step by step used in the algorithm: An initial threshold (T) is chosen, this can be done randomly or according to any other method desired. The image is segmented into object and background pixels as described above, creating two sets: G 1  = {f(m,n):f(m,n)>T} (object pixels) G 2  = {f(m,n):f(m,n) T} (background pixels) (note, f(m,n) is the value of the pixel located in the  m t h  column,  n t h  row) The average of each set is computed. m 1  = average value of  G 1 m 2  = average value of  G 2 A new threshold is created that is the average of  m 1  and  m 2 T’ = ( m 1  +  m 2 )/2 Go back to step two, now using the new threshold computed in step four, kee

Android and Security

By Hiroshi Lockheimer, VP of Engineering, Android The last year has been a phenomenal one for the Android ecosystem. Device activations grew 250% year-on-year, and the total number of app downloads from Android Market topped 11 billion. As the platform continues to grow, we’re focused on bringing you the best new features and innovations - including in security. Adding a new layer to Android security Today we’re revealing a service we’ve developed, codenamed Bouncer, which provides automated scanning of Android Market for potentially malicious software without disrupting the user experience of Android Market or requiring developers to go through an application approval process. The service performs a set of analyses on new applications, applications already in Android Market, and developer accounts. Here’s how it works: once an application is uploaded, the service immediately starts analyzing it for known malware, spyware and trojans. It also looks for behaviors that indicate an appl

Sale Queue

A big shop selling nice principal foods is doing a big sale. Early in the morning, there has already been a long queue of people waiting for the shop to open at 9 o'clock in the morning. An old man looked so inpatient and cut the queue to the front. The people there were so mad and yelling, "Hei!! On queue please....", and pushing the old man to the back again. The old man seemed not really care about this. He tried again to cut the queue and walk to the front. The second time, people there yelled at him and pushed him to the back. For the third time, he walked again to the front. This time, the people there lost their patience. Whilst cursing him, they pushed the old man 'till he felt down.... The old man then stood up and yelled, "If you guys dare to push me again, I won't open the shop!! I'll let you guys queue 'till old!! Haiya!!!"

Kisah Nyata Seorang Anak Bernama Andoy dari Filipina

This post is in Bahasa. Ada seorang anak kecil kelas 4 SD yang selalu mengucap syukur dalam keadaan apapun. Ia tinggal di suatu desa di Negara Filipina. Setiap hari untuk sampai ke sekolahnya ia harus berjalan kaki melintasi daerah yang tanahnya berbatu dan menyeberangi jalan raya yang berbahaya dimana banyak kendaraan yang melaju kencang. Setiap kali berhasil menyeberangi jalan raya tersebut, Andoy selalu mampir sebentar ke Gereja untuk berdoa. Tindakannya ini diamati oleh Pdt. Agaton. Karena merasa terharu dengan sikap Andoy yang lugu dan beriman tersebut. Suatu hari ketika Andoy hendak masuk ke Gereja Pdt. Agaton menyapanya. Bpk. Pdt : "Selamat pagi Andoy, apa kabarmu? Apakah kamu akan ke sekolah?" Andoy : "Ya, Bapa Pendeta!" balas Andoy sambil tersenyum. Bpk.Pdt : "Mulai sekarang saya akan membantu dan menemani kamu menyeberangi jalan raya tersebut setiap kali kamu akan menyeberang. Andoy : Terima kasih, Bapa Pendeta." Bpk. Pdt : "sekarang a

Whatsapp in Indonesia?

Whatsapp was establishing them-self by claiming that they will be a good replacement for SMS service provided by default by network operators (go to http://www.whatsapp.com/ for more information) . However, can whatsapp really do that good job? Below are eight reasons I found why whatsapp won't do a good job as SMS replacement in Indonesia (yet maybe): Internet connection here is not stable and reliable enough to make sure that the message will arrive instantly. Even here, we cannot make sure that SMS will arrive instantly. People tend to ignore whatsapp notification compare to SMS notification. The server is just not too stable as the number of users is increasing (for now maybe) People tend to mute the notification for whatsapp or other instant messaging (not including BBM though) but not SMS. It means, they will know if a new SMS (or BBM message) arrived, but not whatsapp. For some people, turning off internet will cost them less money and of course save more battery power

Consecutive Letters

This is an answer for test case 2 given by PT. GDI Indonesia, as can be seen from its website ( http://www.ptgdi.com/#Career ).... The code is in C++ // // main.cpp // Consecutive Letters // // Created by Handra on 5/28/11. // Copyright 2011 Handra. All rights reserved. // #include <iostream> using namespace std ; int main ( int argc , const char * argv [ ] ) { char letters [ ] = "AAAAAAAAAA" ; int number = 0 ; do { if ( number == 1000 ) { number = 0 ; for ( int i = ( int ) strlen ( letters ) - 1 ; i >= 0 ; i -- ) { if ( letters [ i ] != 'Z' ) { letters [ i ] ++ ; break ; } } } cout << letters << ( ( number < 10 ) ? "00" : ( number < 100 ) ? "0" : "" ) << number << endl ; number ++ ; if ( strcmp ( letters , "ZZZZZZZZZZ" ) == 0 && number == 1000 ) break ; } while ( true) ; return 0 ; }

1 to 1000

This is an answer from the test case 1 given by PT. GDI Indonesia ( http://www.ptgdi.com/#Career )... The code is in C++ // // main.cpp // 1 to 1000 // // Created by Handra on 5/28/11. // Copyright 2011 Handra. All rights reserved. // #include <iostream> using namespace std ; int main ( int argc , const char * argv [ ] ) { unsigned int number = 1 ; unsigned int lastStep = 3 ; unsigned int step = 0 ; for ( number = 1 ; number <= 1000 ; number ++ ) { cout << number ; step ++ ; if ( number < 1000 && ( ( lastStep == 3 && step == 5 ) || ( lastStep == 5 && step == 3 ) ) ) { lastStep = step ; step = 0 ; cout << "*" ; } } return 0 ; }

Physics Exam

The following concerns a question in a physics degree exam at the University of Copenhagen: "Describe how to determine the height of a skyscraper with a barometer." One student replied: "You tie a long piece of string to the neck of the barometer, then lower the barometer from the roof of the skyscraper to the ground. The length of the string plus the length of the barometer will equal the height of the building." This highly original answer so incensed the examiner that the student was failed. The student appealed on the grounds that his answer was indisputably correct, and the university appointed an independent arbiter to decide the case. The arbiter judged that the answer was indeed correct, but did not display any noticeable knowledge of physics. To resolve the problem it was decided to call the student in and allow him six minutes in which to provide a verbal answer which showed at least a minimal familiarity with the basic principles of physics. For five

A Short Story of Blind Woman

Once upon a time, there was a blind woman. Everyone hated her, except her lover. The woman always said, "I will marry you when I am able to see." One day, someone donated eyes to the woman. At last, she could see the world. In a hurry, she went to meet her lover. Unfortunately, she was really shocked when she saw her lover, because he was also blind. Her lover asked, "Will you marry me?" Without any reason, the woman rejected the proposal. Her lover then just smiled and went away whilst saying, "Please take care of my eyes..."

Kelompok 99

This post is in Bahasa. Apakah Anda termasuk anggota Kelompok 99? Apa yang sedang saya bicarakan? Mari dengar suatu kisah terlebih dahulu dan baru Anda bisa menjawabnya. Zaman dahulu kala, hiduplah seorang Raja. Raja ini seharusnya puas dengan kehidupannya, dengan segala harta benda dan kemewahan yang ia miliki. Tapi Raja ini tidak seperti itu. Sang Raja selalu bertanya-tanya mengapa ia tidak pernah puas dengan kehidupannya. Tentu saja, ia memiliki perhatian semua orang kemana pun ia pergi, menghadiri jamuan makan malam dan pesta yang mewah, tetapi, ia tetapi merasa ada sesuatu yang kurang dan ia tidak tahu apa sebabnya. Suatu hari, sang Raja bangun lebih pagi dari biasanya dan memutuskan untuk berjalan-jalan di sekitar istananya. Sang Raja masuk ke dalam ruang tamunya yang luas dan berhenti ketika ia mendengarkan seseorang bernyanyi dengan riang... dan perhatiannya tertuju kepada salah satu pembantunya... yang bersenandung gembira dan wajahnya memancarkan sukacita serta kepuasan. H

Five NIE Practices

IT is now indeed an indispensable component of Business. For a business to move faster and bigger, there need to be a great support by IT. This makes the management of IT and how it used accordingly to support business even more important. In the New Information Economics (NIE) era, there are five common practices that are used in managing IT so that it can give its full potential to support the bottom-line impact of the business. Below are the five NIE practices to help company manage its business and IT: Strategic Demand/Supply Planning Strategic Demand/Supply Planning means that IT acts as a service provider for business necessity. In other words, IT does something to fulfil the need of business. This is the traditional way of managing IT. There is demand, then there is supply. Innovation Innovation is fundamentally different from Strategic Demand/Supply Planning. In the innovation process, IT drives new business initiatives. Prioritisation Prioritisation is the process where t