Jul 14, 2015

GIT problem again ..!..! [ git reflog and reset ]

Accidentally, I have lost my iRobot creation project changes, very important. I will show you the mistake happen and how to avoid same situations. Also best practices we can consider while working with GIT with large user contribution.

This is my old git repo.













  • What went wrong and the reason? 
I was working on my local 'dev' branch which is link with remote repo. I keep on commit my changes at a time so that I can understand RCA in case of an exception. As I have already committed my changes I checkout for 'origin/dev'. (It has happen for whatever the reason)

I noted all of my changes has been reverted. 'God, what went wrong? I totally lost.' The reason is that I have converge dev with origin/dev, which is lost my local changes even I have commited. 
  • After checkout origin/dev






  • Recovering commits with "git reflog" and reset
Thanks to "git reflog" tool, I able to recover my lost commits.















  • Retrieving a branch of an earlier state.
Now, see the history and the mistake I have done. "git reflog" gives you a good history about what has been done to head of your branches. In this case, head is reset to origin/dev at "8d29594". I need to rest head to the commit "09a3f2a" which is my last commit of the changes. 














Here we go !!!! I pointed head to the correct commit. Also note that I need checkout the branch since I am on the right branch "dev". If history shows different checkout branch, you need to checkout to the right branch first. 

Ok. Finally here my local settings look like after pushing.










Also, keep in mind an impotent thing. If you have heavily RnD oriented thing do it in different branch then merge it with "dev". This makes less complicated other to track the changes. In above example consecutive commits are recorded in remote repo after pushing which may hard to track others of your changes.  

May 16, 2015

Useful GIT commands

Install GIT on your PC.
First thing you need to do is customize git environment.

$ git config --global user.name "Dasun"
$ git config --global user.email hmdtharaka@gmail.com
Now it is the time for your first commit...
Create a file called main.cpp. On the same directory do basic commands using Git bash.
$ git status
$ git add main.cpp
$ git commit -m "First commit"
Now I modify main.cpp content and do a commit over same branch. Still this is master.
$ git status
$ git add main.cpp
$ git commit -m "changed in main.cpp"

Now we need to do certain changes in main.cpp but we are not sure about these changes. Hence I create different branch and do my testing there.
$ git branch dev
$ git checkout dev

Suppose, I do several commits on this branch. Now I am confident that my testing was fine. Hence I need to merge these changes with original and I did my change liner. This is what we called fast forwarding. 


Now we need to do certain changes in main.cpp but we are not sure about these changes. Hence I create differen

May 15, 2015

Lat's Play with OpenGL - 1

OpenGL Introduction

OpenGL is graphic library for cross platform 3D graphics. This is same as Direct3D in directx library. There are many tutorials and example videos to learn OpenGL. In this post I am trying to make a short note to cover up most import points, I have learnt. 

Glut 

Glut is tool for creating windows and handling inputs. Use FreeGlut pre build libs for your projects. 

Glew

This is openGL extension manager and lat us easily call openGL extensions without having declare DLL entry points.


May 10, 2015

Problem with Visual Studio Immediate Exit ?

Hello,

I have faced this problem many times. Specially in visual C++ programming.
Here, few things we can to avoid this issue.

  1. Simple, cool way is press CTRL + F5. This is also known Debug-> Start without debugging.
  2. Add  system("pause"); at the end of your code.
  3. This is also mentioned in many places over the web. Somehow I tested this on my Visual C++ console application and it wasn't work for me. I am leaving this to you for trying out...            
properties -> configuration proprieties -> linker -> system
select CONSOLE(/SUBSYSTEM:CONSOLE) in subsystem option.

Also I have seen added logically correct coding tips end of the code. But according to me those looks like unprofessional !

while(1) { }
cin.get();
for(;;) ;
std::getchar();



Jul 31, 2014

එය මෙසේ සිදු විය යුතුය



මහමෙරක් වන් නුබේ වෙනස,
සීමා මායිම් නොමැතිව,
දරා ගත නොහැකි තැන,

ඉතිරි වූ එකම විසදුම,
කියා ගත නොහැකි සෙනෙහසින් බැඳී වූ,
අපම හමු වී සිනා සුනු තැන්,
හැර යාම පමණි.



විටින් විට, හරි පරිස්සමට,
එහෙව් සෙනෙහස් සිතක් මරමින්,
නුඹ පන දුන් සැකය හා යහළු, කේන්ති සිත,

තව දුරටත් දළු නොලියන නමුදු,
එලෙසම පවතීවි.

නුඹ කෙරෙහි, නුබේ සිත නොරිදවීමෙහි,
මගේ සැලකීම කොතරම්ද නම්,
අදටත්, මේ මොහොතෙත්,
නුඹ බලයෙන් පන දුන් ඒ හිතට,
පෙර තිබූ සෙනෙහසින් බැඳි සිත,
යට කර පාගා දැමිය නොහැක.

මට නුඹ ගැන දුකය.
වෙලාවකට හැගීම් නුඹ හට විහිලුවක් බව දැනෙනා විට,
මට මම ගැනම දුකය.
එහෙත් නුඹ අසවලුන් සමග ගනු දෙනු කර,
මටත් නොකියාම, නුඹ තනිවම වේදනා සිතක අතරමං වන විට,
මට මම ගැනත්, නුඹ ගැනත් දුකය.

මේවා මම කළ වැරදිය,
නුඹ මගේ හිතට සමීප කර ගත්තා වැඩිය,
ඉවසුවා වැඩිය,
එතරම් රිදුනේ ඒ නිසාය,,,

මම නුඹව හැර යමි.
නුඹටත් මටත් අතීතයටවත් නැති කලක් හැර දමමින් යන්නට යමි.
ඒ නුඹ හට රිදුනාද කියා සොයා බැලීමට නොව,
තව දුරටත් හිත් මරා දමනු හා විදවන රිදුම් දැකීමට නොහැකි බැවිනි.

නුමුදු කතාව අහවර නැත,
නැවත නැවතත් ඉතිහාසය ලියවෙන බව මම දනිමි,
ඒ දවස අද හෝ හෙට නොවන බවද මම දනිමි,,,
කවදා හෝ අපි හමු වේවි.
දොඩමළු වේවි...
කිසිවක් නොවූ ගානට හිනා වේවි...
ඒ අතරම, නුඹටත් හොරෙන් නුඹේ හිතට දැනේවි,
දුටුවාට නුඹ හා සිනා සී මේ දොඩමළු වන්නේ,
නුබේ හිතට සමීප වූ සහෝදර සෙනෙහි හිත නොවන බවට...

එහෙත් මම කළ එකම වරද,
නුඹ විසින් මරා දැමූ ඒ සෙනෙහස් සිත,
නිසි ලෙස මිහිදන් කර සැනසවීම පමණි!

Jul 5, 2014

දෙවියන් මැරීම :: අසාධාරණ හා ආත්මාර්ථකාමී මිනිස් සිත

ඒ 2007, මම AL කරල නිදහසේ ගෙවන කාලය. කඩ්ඩ හදා ගන්න කියල තිබිරිගස්යායේ කඩු ක්ලාස් ගිය කාලය. මට ඒ ක්ලාස් එකේදී සෙට් උනා යාළුවෙක්, සිත්තරෙක්, ඒ වගේම ඌ කළාකරුවෙක්. වෙනස් අදහස් තියෙන සංවාදයට කැමති පුද්ගලයෙක්. හැමදාම ක්ලාස් ඉවර වෙලා පාර එහා පැත්තේ තියෙන කඩයට රිංගල සිගරට් එකක් උරන ගමන් මොකක් හරි දෙයක් ලොකුම ලොකු කරල, සාහිතය එක්ක කියවන එක තමයි මුගේ එකම සතුට. තිබුන යාළුකම වැඩි නිසාම උබේ සමාජවාදී හිතට ඕන උනේ හැම තිස්සෙම ගණිත තර්ක දාන මාව ටිකක් වෙනස් කරන්නෙ. :P
ඒත් උඹ කියපු කතා හිනාවක් දා ගෙන අහන් ඉන්නවට වඩා මට උඹ කියනවන තරමටම අහන් ඉදීමේ උවමනාවක් ඒ දවස් වල තිබුනේ නෑ, විහිළුවක් කරල 'එහෙම වෙන්නත් බෑ නේද මචං ?' කියල ඇහුවට. ;-)

මට තාමත් මතකයි, ඒදාත් මොකක්දෝ සිංහළ පොතක් දිග ඇරගෙන මට 'දෙවියන් මැරීම' ගැන වචනයෙන් වචනය කියල දුන්නු අපූරුව. උඹ මගේ අවධානය බිඳෙන කොට, ආයිත් පේළිය මුලින්ම පටන් අරන් කියල දුන්නා. කොච්චර කලක් ගියාද...උඹ එදා මොන ගැඹුරු තේරුමකින් මේ දෙය කියල දුන්නද කියන්න මම තාමත් දන්නේ නෑ. මේ දෙය උඹ එදා හුගාක් උවමනාවෙන් කියවපු හෙතුවත්, මෙහි මුල් රචකන් මේ වගේ නිමිත්තක් වචන කරන්න හේතුවත් මම දන්නේ නෑ. ඒ වගේම මේ දේවල් කතා කරපු තර්ක කරපු කාලයත් දැන් අපෙන් ඈත් වෙලා. ඒත් මට හිතෙනව මේ දේවල් නිකම්ම අහක දමිය යුතු දේවල නොවන බව. උඹ එදා ගත්තු උත්සහය අපතේ ගියෙ නෑ මචං....




















බුද්ධිය මිත‍්‍රයෙකැයි සිතු මම,
දිනක් මග රැක සිට
මගේ දෙවියන් මරා හෙලීමි.
දැවැන්තයකු වන බුද්ධිය,
අඳුරෙහි මහ අඩි තබමින්,
මා පිටි පසින් එනු මට ඇසෙයි...


එහෙත් දෙවියන් සිටි කල මෙන්, 
දැන් මට සැක හැර ගමන් කළ නොහැක.
මා වැටුණු කල, දැන් දෙවියන් නැති හෙයින්,
මමම නැඟී සිටිය යුතු ය...


යළිත් දෙවියන් සොයා ගිය මට,
උන්වහන්සේගේ රන්වන් මළ සිරුර,
මඟ අසල නුග ගස යට තිබී සම්බ විය..


ස්වාමීනි...! 
යළිත් නැඟී සිට මා හා පෙර මෙන්,
එනු මැනවයි මම කීමි...
උන්වහන්සේ යළි නැඟී නොසිටින්නේ,,
බුද්ධිය තම දත් දෙපළ පෙන්නා විලිස්සමින්,
මා පිටිපස සිටින හෙයින් බව මම දනිමි....!


"එහෙත් මට බුද්ධිය ගසා පලවා හැරිය නොහැකිය,
-ඔහු මා අතහැර නොයයි -"


දෙවියන් මැරීම,
-ජී බී සේනානායක-

Apr 14, 2014

Spartacu's Last Words














"Spartacus"
That is not my name.
I shall finally hear it again,
Given voice by my loving wife.
in greeting longed for..

There is no greater victory,
Than to fall from this world..
A Free Man!