I have been following a programming course that is on Stanford University channel on You tube, it's really nice, and I made that implementation of a generic dynamic list in C, I put it on source forge, so you can have look it and tell me if there is any thing wrong with it :)
CList on source forge.
Saturday, May 22, 2010
C dynamic list
Labels:
C,
Data Structure,
Open Source,
Source Forge
Wednesday, April 21, 2010
Mercurial
Sometimes you miss up your code with some changes that cause it not to work and you are unable to remember what you did or even worse not able to recover what you deleted, that's way their is something called Source Control, this helps you keep different versions of your projects, so you can just move between them without losing any thing, there are many stuff that do Source Control like cvs or svn, any way I came across something called Mercurial which seemed a nice thing to write about.
The guide is really good and simple, but I am gonna explain things little bit more and with some examples.
Installation
You can install Mercurial easily by typing sudo apt-get install mercurial in your terminal if you don't already have it, you also need to create a file name .hgrc in your home directory, Mercurial uses this file as your preferences, so you type your user name, and your preferred editor (ex. nano, vim or emacs).
my .hgrc file looks like this
[ui]
editor = nano
username = Khaled Hady
Creating a Repository
The first thing we need to do is to create a repository which is like telling Mercurial this folder is where I work and I want you to keep tracking any changes that I do.
If you already have a folder where your projects are then you will write two commands, let's say that my project is in a folder called Test in my home directory, and I have only one file "main.c" in it, that I want to keep track of.
I used cd to go to Test folder, then I used hg init to initiate a repository. I typed hg add because I want ALL the files to be tracked, if you want only some files to be tracked use
$ hg add first.c third.cwhere first.c and third.c are the files you want to keep track of.
I also used the hg status command to know which files I am following and which I am not.
I used the nano command to edit the main file by adding few lines, then I added a new source file named newFile.c
After that I use hg diff to show the differences between the current version and the data in the files I am tracking, it tells me that there have been changes, so I type hg commit to make a new version that maintains the changes I made, and I am asked to type a comment which is important so I can keep track of my changes.
Now accidently, I changed the "newFile.c" and wrote some stupid code, then I commited the version so now I have two versions (0 and 1), I want my old version back (version 0)
first I will type hg log to see what each commit did in the project (so you must write reasonable words when you write the comment of the commit), then I will type hg update 0, I typed 0 cause I want to go to the first version which is zero, also you can use hg update tip to go to the latest version whatever it is.
Now the files are the same in version 0.
there is also a command called hg identify -n which tells you on which version you are now, if it has the form [num]+ (ex. 3+) this means you made changes to the version number 3 but hasn't commited these changes.
That's for now, there are other commands that we can talk about later.
Labels:
C++,
Linux,
Open Source
Sunday, February 28, 2010
الفندق
أسف على التأخير فى تكملة ما بدأنا سويا ً عن سيوة , ليس هناك الكثير ليقال عن الفندق , كل ما استطيع أن أقوله أنه جيد و نظيف و يبدو أنه يتعامل مع أفواج فى أغلب الأوقات , الفوج يحتل طابقين , كل طابق يحتوى على حوالى 10 إلى 15 غرفة , و الغرفة تحتوى على 3 أسرة , الشىء الذى لاحظته أن عمال الفندق و هم بالطبع من أهل سيوة يأخذون عملهم بجدية عالية التى تتحول أحيانا ً إلى جفاء , لكن الشىء الجيد أنهم يتركونك فى حالك , فلا يحملقون فى الزوار و لا ينتظرون البقشيش.
بعد أن استرحنا بضعة ساعات , ذهبنا لعين اسمها "عين فنطاس" أو "فطناس" لا أتذكر, المهم أنى كنت متحمس أن أعرف ما هو مفهوم "العين" كنت أظن أنها مجرد فتحة "خرم" فى الأرض تخرج منها المياه , هذا التصور الساذج بالتأكيد كان خاطئا ً و اكتشفت أن العين هى شىء أشبه ببئر إذا نظرت فيه تستطيع رؤية فقاقيع و المياه تكون دافئة لأنها خارجة من باطن الأرض , عين فنطاس هذه كانت أصغر من عين كليوبترا التى زرناها فيما بعد.
جلسنا حتى الغروب على بحيرة ناتجة من الصرف الزراعى لكنها نظيفة و لا توجد روائح كريهة , شربنا شاى و استمتعنا بالمكان ثم عدنا إلى الفندق.
Labels:
سيوة
Wednesday, February 10, 2010
Between pages and screens
Many novels have been turned into movies but not vice versa, this mostly takes from the novel more than it gives, even financially a person would buy a ticket rather than buying a book, but any way the authors get millions of dollars so there is no need to worry about them :D.
When a novel is turned into a movie, the movie will have two types of audience: people that read the novel and people who haven't, clearly the second type will be larger that's why the director will try to reach and satisfy them more than the first type, this leads to you watching something totally different from what you expect (in case you are of the unfortunate first type).
I just been to Sherlock Holmes by Robert Downey and Jude Law, the movie is great from the perspective of a person that never read any of Sherlock Holmes cases, but when I recall the cases and the voices (as Sherlock Holmes was presented by the BBC Radio in sixtieth) I see Sherlock Holmes as a man in his late fourties or early fifties, maybe in a good shape but not so athlete, we can say quite fat with a moustache, and as I hear the strong sound of Dr Watson, I see him similar to Sherlock Holmes but little older maybe, and with a full rounded face, a typical gentleman of London in the 19th century, well all this "imagination" of mine might be what Sir Arthur Conan Doyle wanted the reader to say or maybe not, but I am quite sure that while he was writing he never thought of Sherlock and Watson as two men destroying London while they are chasing criminals like the movie put them, actually the movie made them closer to cowboys rather than gentlemen of the 19th living in London, when you read any of the cases, you will rarely see the kind of extensive force and action that existed in the movie.
This surely puts the largest part of the audience in great satisfaction as they watch the two men jump, hit and make jokes, and they will surely enjoy Sherlock's mad acts and expressions, which doesn't match with the cases, maybe he was a little bit "weird" and unorganized but not a lunatic that is closer to insanity than geniosity.
Anyway as the director wants ALL the audience satisfied, he will make up with you be emphasising on details that might not be of importance but they were in the original Sherlock Holmes like: the address of the rooms where Sherlock and Dr.Watson lived which is 221 Baker Street, the names of the landlady "Miss.Hudson" and the detective "Lastrade". These things could have been ignored without disturbing you but the director kept them, just to tell you "hey man don't be upset this is still Sherlock Holmes of Sir Arthur".
I guess the same thing happened with "Angels and Demons" of Dan Brown and "The Twilight Saga" by Stephenie Meyer, on the other hand stories like "Troy" and "300 Spartians" were sent to life again by movies.
So what do you think about novels turning into movies.
When a novel is turned into a movie, the movie will have two types of audience: people that read the novel and people who haven't, clearly the second type will be larger that's why the director will try to reach and satisfy them more than the first type, this leads to you watching something totally different from what you expect (in case you are of the unfortunate first type).
I just been to Sherlock Holmes by Robert Downey and Jude Law, the movie is great from the perspective of a person that never read any of Sherlock Holmes cases, but when I recall the cases and the voices (as Sherlock Holmes was presented by the BBC Radio in sixtieth) I see Sherlock Holmes as a man in his late fourties or early fifties, maybe in a good shape but not so athlete, we can say quite fat with a moustache, and as I hear the strong sound of Dr Watson, I see him similar to Sherlock Holmes but little older maybe, and with a full rounded face, a typical gentleman of London in the 19th century, well all this "imagination" of mine might be what Sir Arthur Conan Doyle wanted the reader to say or maybe not, but I am quite sure that while he was writing he never thought of Sherlock and Watson as two men destroying London while they are chasing criminals like the movie put them, actually the movie made them closer to cowboys rather than gentlemen of the 19th living in London, when you read any of the cases, you will rarely see the kind of extensive force and action that existed in the movie.
This surely puts the largest part of the audience in great satisfaction as they watch the two men jump, hit and make jokes, and they will surely enjoy Sherlock's mad acts and expressions, which doesn't match with the cases, maybe he was a little bit "weird" and unorganized but not a lunatic that is closer to insanity than geniosity.
Anyway as the director wants ALL the audience satisfied, he will make up with you be emphasising on details that might not be of importance but they were in the original Sherlock Holmes like: the address of the rooms where Sherlock and Dr.Watson lived which is 221 Baker Street, the names of the landlady "Miss.Hudson" and the detective "Lastrade". These things could have been ignored without disturbing you but the director kept them, just to tell you "hey man don't be upset this is still Sherlock Holmes of Sir Arthur".
I guess the same thing happened with "Angels and Demons" of Dan Brown and "The Twilight Saga" by Stephenie Meyer, on the other hand stories like "Troy" and "300 Spartians" were sent to life again by movies.
So what do you think about novels turning into movies.
Statue of Sherlock Homes in Edinburgh
A Drawing of Sherlock Holmes
Dr.Watson (left) and Holmes (right)
The ALL NEW Holmes and Watson
COOL isn't it? :D :D
Labels:
Novels
Saturday, February 6, 2010
جبل الموتى
من الغريب أن تبدأ زيارتك للواحة بجبل يسمى جبل "الموتى" , و لكن هذا ما حدث فبعد أن وصلنا حوالى الساعة العاشرة صباحا ً اتجهنا إلى هذا الجبل الذى سمى بهذا الاسم لأن سكان الوحة القدامى كانوا من الفراعنة و كانوا يدفنون موتاهم فى هذا الجبل , ما استغربه هو لماذا تركوا الوادى و ذهبوا إلى هذه الواحة ليسكنوا فيها أم أن هذه المسافة كانت مأهولة بالسكان ؟ المهم أنهم لم يمتلكوا رفاهية بناء الأهرامات فاستخدموا الجبال المنتشرة بكثرة حول الواحة ليحفروا فيها سراديب لدفن الموتى , أحدهم يدعى سى - آمون , لم أتمكن من دخول المقبرة لأنها كانت صغيرة و عددنا كان كبيرا ً .
من فوق هذا الجبل استطيع أن أصف لك منظرا ً عاما ً للواحة , فهى محاطة بعدد من الجبال التى شكلتها الأمطار على مدار ألاف السنين على هيئة مخاريط يمكن تسلقها بدون معدات , الجبال ليست عالية و ربما كلمة تلال الوصف الأدق لها , هذا على الأفق البعيد أما إذا نظرت قريبا ً فسترى عددا ً من البحيرات ذات شواطىء مهجورة , لست متأكدا ً إذا كانت هذه البحيرات عذبة أم أنها ناتجة عن صرف زراعى , أما سفح الجبل فهو محاط ببيوت بسيطة أغلبها يتكون من طابق واحد , الشىء العجيب فعلا ً الذى لاحظته طوال الرحلة أن البيوت فى سيوة هادئة بشكل غير عادى حتى تشعر أنها مجرد مقابر كالتى تمتلأ بها الجبال . هذه البيوت تفصل مجموعات ضخمة من النخيل المتشابك حتى أنك لا تستطيع أن ترى نخلة دون أن ترى معاها 5 نخلات !!
من فوق هذا الجبل استطيع أن أصف لك منظرا ً عاما ً للواحة , فهى محاطة بعدد من الجبال التى شكلتها الأمطار على مدار ألاف السنين على هيئة مخاريط يمكن تسلقها بدون معدات , الجبال ليست عالية و ربما كلمة تلال الوصف الأدق لها , هذا على الأفق البعيد أما إذا نظرت قريبا ً فسترى عددا ً من البحيرات ذات شواطىء مهجورة , لست متأكدا ً إذا كانت هذه البحيرات عذبة أم أنها ناتجة عن صرف زراعى , أما سفح الجبل فهو محاط ببيوت بسيطة أغلبها يتكون من طابق واحد , الشىء العجيب فعلا ً الذى لاحظته طوال الرحلة أن البيوت فى سيوة هادئة بشكل غير عادى حتى تشعر أنها مجرد مقابر كالتى تمتلأ بها الجبال . هذه البيوت تفصل مجموعات ضخمة من النخيل المتشابك حتى أنك لا تستطيع أن ترى نخلة دون أن ترى معاها 5 نخلات !!
Labels:
سيوة,
واحة الغروب
Friday, February 5, 2010
الطريق
ركبنا الأتوبيس بعد منتصف الليل بقليل بعد عدة محاولات "لدفس" الشنط فى أماكنها , لن أنكر أنى كنت خائفا ً من الطريق خاصة أننا سنسافر وسط الصحراء فى الشتاء فى ظلام الليل , أضف إلى ذلك أن مناطق فى سيناء و أسوان تعرضت لسيول قوية قبل السفر بعدة أسابيع , لكن الحمد لله لم تحدث مشاكل سوى أن الأتوبيس الثانى تعطل عدة مرات و تم استبداله فى النهاية .
الطريق من الأسكندرية إلى سيوة نستطيع أن نقسمه إلى جزئين رئيسين : الجزء الأول هو الاتجاه غربا ً من الأسكندرية فى طريق مرسى مطروح أما الجزء الثانى فالاتجاه جنوبا ً فى اتجاه الواحة , لا أتذكر بالضبط كم كانت المسافة الكلية ( لم ألحظ اللافتات لأننا سافرنا بالليل ) و لكنى متأكد أنها كانت طويلة , و للأسف لست من النوع الذى ينام فى المواصلات و لكنى بعد أن التهمت 7 ساندويتشات شاورمة و قطعتين بيتزا تونة ( يمنكنك تخيل رائحة فمى ) و بعد محاولات عديدة و تجربة كل أوضاع النوم من ضم الأرجل أو ثنيها و سند الرأس للخلف أو للأمام تمكنت من النوم لأوقات قصيرة متقطعة . الشىء الذى أغاظنا جميعا ً هو أن مصطفى مشرى أحد زملائنا نام تقريبا ً طوال المسافة دون أى إنزعاج كأنه فى سريره بينما نحن نكاد نجن من أجل نصف ساعة من الراحة !!
الطريق من الأسكندرية إلى سيوة نستطيع أن نقسمه إلى جزئين رئيسين : الجزء الأول هو الاتجاه غربا ً من الأسكندرية فى طريق مرسى مطروح أما الجزء الثانى فالاتجاه جنوبا ً فى اتجاه الواحة , لا أتذكر بالضبط كم كانت المسافة الكلية ( لم ألحظ اللافتات لأننا سافرنا بالليل ) و لكنى متأكد أنها كانت طويلة , و للأسف لست من النوع الذى ينام فى المواصلات و لكنى بعد أن التهمت 7 ساندويتشات شاورمة و قطعتين بيتزا تونة ( يمنكنك تخيل رائحة فمى ) و بعد محاولات عديدة و تجربة كل أوضاع النوم من ضم الأرجل أو ثنيها و سند الرأس للخلف أو للأمام تمكنت من النوم لأوقات قصيرة متقطعة . الشىء الذى أغاظنا جميعا ً هو أن مصطفى مشرى أحد زملائنا نام تقريبا ً طوال المسافة دون أى إنزعاج كأنه فى سريره بينما نحن نكاد نجن من أجل نصف ساعة من الراحة !!
Labels:
سيوة,
واحة الغروب
Subscribe to:
Posts (Atom)























