Source Code


Code never been perfect. Doesn’t matter the code already perfected, or established, the’re always room for improvement…endlessly. Codes being made today can be made better tomorrow. With this philosophy in mind, I would humbly seek comments and suggestions from you folks to make the codes I share in this page for better improvement. Some of the codes I share here made by me while some or part of it comes from awesome individual programmers or programmers websites everywhere that are so generous to make their codes sharable to everyone.

Codes are not to be condemned neither judged. Codes are meant to be improved. I believe this is the genuine aspiration of these coders to willing to make their codes available to everyone. I just could not credit each names over here but whoever they are, I am so thankful for your generous sharing. My code no more than their codes that I made being better.    


Here, you will find codes that I share. Please drop me comments at the bottom of this page to improve these codes. Or simply email me at: That’s my only intention sharing this code..TO IMPROVE!. I love to LEARN together, and SHARE together.

k Nearest Neighbor (kNN) Algorithm in C++. This code demonstrates the Machine Learning’s Supervised Learning classification algorithms. The distance measurement using the Distance Formula: d ⁽P,Q⁾ = √ ⁽x₂ – x₁⁾² + ⁽y₂ – y₁⁾². However, other distance formula could be tested as well to see how good the algorithm perform the classification, such as the popular Euclidean Distance.
The code can be compiled and executed using a GCC C++ compiler with command:
$g++ KNNalgo.cpp

In the Name of God for Mankind. Kerana Tuhan Untuk Manusia.

Universiti Teknologi Malaysia

Never underestimate yourself.

Yusnaidi Md Yusof

Speak good or remain silent.

Prophet Muhammad ﷺ

No two things have been than knowledge and patience.

Prophet Muhammad ﷺ

Fall seven times, stand up eight.

Japanese Proverb

You can't learn in school what the world is going to do next year.

Henry Ford

Stay hungry, stay foolish.

Steve Jobs

You don't have to see the whole staircase, just take the first step.

Martin Luther King

Design is not just what it looks like and feels like. Design is how it works.

Steve Jobs

I want to put ding in the universe.

Steve Jobs

Rule No. 1: Never lose money. Rule No. 2: Never forget rule No. 1.

Warren Buffett

You only have to do a very few things right in your life so long as you don't do too many things wrong.

Warren Buffett

Someone is sitting in the shade today because someone planted a tree a long time ago.

Warren Buffett

We enjoy the process far more than the proceeds.

Warren Buffett

I don't look to jump over 7-foot bars: I look around for 1-foot bars that I can step over.

Warren Buffett

Price is what you pay. Value is what you get.

Warren Buffett

The key is not to prioritize what's on your schedule, but to schedule your prioritizes.

Stephen Covey

Live out your imagination, not your history.

Stephen Covey

The main thing is to keep the main thing the main thing.

Stephen Covey

Happiness is not something you postpone for the future; it is something you design for the present.

Jim Rohn

Mens et manus. Mind and Hand.

Massachusetts Institute of Technology

Veritas. Truth.

Harvard University

Hinc lucem et pocula sacra. From this place, we gain enlightenment and precious knowledge.

Cambridge University

Dominus Illuminatio Mea. The Lord is my Light.

Oxford University

Die Luft der Freiheit weht. The Wind of Freedom Blows.

Stanford University

Fiat lux. Let There be Light.

University of California, Los Angeles

Zukunft denken. Thinking the Future.

RWTH Aachen University

mens agitat molem. Coat of Arms.

Newcastle University

Dei Sub Numine Viget. Under the Protection of God She Flourishes.

Princeton University

ज्ञानम् परमम् ध्येयम्. Knowledge is the Supreme Goal.

Indian Institute of Technology, Bombay

自强不息、厚德载物. Self-Discipline and Social Commitment.

Tsinghua University

Takuetsu-sei o hakken suru. Discover Excellence.

The University of Tokyo

Dare to Reach the Highest.

National University of Singapore

اقْرَأْ بِاسْمِ رَبِّكَ الَّذِي خَلَقَ Read! In the name of your Lord Who created.

King Abdulaziz University

Наука есть ясное познание истины, просвещение разума, Science is clear understanding of truth, enlightenment of the mind.

Moscow State University

Naturam Primum Cognoscere Rerum, First to learn the nature of things.

Australian National University

Discipline is the bridge between goals and accomplishment.

Jim Rohn

You don't get paid by the hour. You get paid for the value you bring to the hour.

Jim Rohn

My number one piece of adive is: You should learn how to program.

Mark Zuckerberg

If you get tired, learn to rest, not to quit.


Let's Start Something new

"Two are Better Than One". I believe Bigger Mind Sparks Bigger Idea. Let's be a Team, because we are already a Family. Let's talk research. Let's share research. I would loved to learn new things, explore new possibilities, collaborate new research, improve knowledge skills, and learn from YOU!

Let's Be a Team

7 + 8 =

I’m glad you’re here. Let’s collaborate a research project.

Drop me an email at:

Knowing worth sharing.

Yusnaidi, UTM

From The Blog

How to install TinyOS 2.1.2 in Mac OSX El Capitan

How to install TinyOS 2.1.2 in Mac OSX El Capitan

How to install TinyOS-2.1.2 on Mac OSX EI CapitanI got this works for me! There are many settings to get the TinyOS 2.1.2 up and running in the Mac machine. And the one I had here I had manage it done successfully on my Mac OSX El Capitan machine. Possibly, we can get...

How to install TinyOS 2.1.1 on Ubuntu 14.0.4 32 bit

How to install TinyOS 2.1.1 on Ubuntu 14.0.4 32 bit

How to install TinyOS-2.1.1 on Ubuntu 14.0.4 LTS 32-bitEven TinyOS has been updated to version 3 but in terms of simulation, I found few limitations hindered one to simulate particularly on micaz platform. I have been searching all over the web and other references...

How to Install TinyOS-2.1.1 on VM Ubuntu

How to Install TinyOS-2.1.1 on VM Ubuntu

How to install TinyOS-2.1.1 on Ubuntu 14.04.5 LTS 32-bit VirtualBox VMThe recent TinyOS 3 version has limitation on supporting simulation. Therefore, to leverage the use of TOSSIM, the built-in TinyOS simulator, researchers has to rely on the backdated version of the...

Install TinyOS-2.1.1: The Easiest Way

Install TinyOS-2.1.1: The Easiest Way

Install TinyOS-2.1.1: The Easiest WayEither you are using Windows, or Mac, you can install and straight away start to use Tinyos-2.1.1 on Ubuntu 14.04.5 LTS-32-bit, the EASIEST way! Simply download the ova file below and import it in your VirtualBox VM:...

Experienced Share: Installing CTP-Castalia on OMNeT++

Experienced Share: Installing CTP-Castalia on OMNeT++

Experienced Share: Install CTP-Castalia on OMNeT++I have recently researched on tree routing protocol in WSN. I had analysed the CTP routing protocol under TinyOS's nesC programming, however, due to some limitations the built-in TOSSIM simulator has to offer on energy...