Mohammad Kotb

"Talk is cheap. Show me the Code" -Linus Torvald

Ruby On Rails environment on Ubuntu 10.04

Posted by mohammadkotb on June 21, 2010

Hi,

I think this is my first technical post in the blog, so today I faced some problems while building the Ruby on Rails environment on my machine. I just like sharing this knowledge with you.

First, in this post we will make the following:

  1. Ruby 1.9.1
  2. Rails 2.3.5
  3. Thin server.
  4. MySQL server.

1. Ruby 1.9.1
The following commands mainly download the Ruby source code and compile it and so on

Just you have to install the following libraries:
sudo apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev

move to /usr/local/src to download source code and compile it in this folder
cd /usr/local/src

Download the source code, and unpack it
sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz
sudo tar xzf ruby-1.9.1-p0.tar.gz
cd ruby-1.9.1-p0

Now, you have to check the version of gcc if it is 4.4 some errors will occur
dpkg -l | grep gcc

if gcc 4.4 found then you have to edit the cont.c file to go on. Open it up, and change the lines 90, 270 and 317 from #elif to #else.
sudo gedit cont.c

then write the following commands in terminal
sudo ./configure –prefix=/usr/local/ruby-1.9.1
sudo make
sudo make install

After these steps you have finally installed Ruby 1.9.1, to check its version
cd /usr/local/ruby-1.9.1/bin
ruby -v
output like that: ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]

Now, the ruby commands such as ruby, rake, irb, … etc are accessed only from /usr/local/ruby-1.9.1/bin, and all the commands are found in /usr/local/bin so just make link for the commands in ruby-1.9.1/bin and put them in /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/ruby /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rake /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/gem /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/irb /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/ri /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rdoc /usr/local/bin

2. Rails 2.3.5
Now, Ruby 1.9.1 is installed successfully on your machine, just add this command to terminal to install the Rails 2.3.5 gem
sudo gem install rails -v=2.3.5

3. Thin server
Also to install Thin application server gem
sudo gem install thin

Then lets make links for the the recently installed commands
sudo ln -s /usr/local/ruby-1.9.1/bin/rails /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rakeup /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/thin /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/testrb /usr/local/bin

4. MySQL server
Finally to install MySQL server for DB
sudo apt-get install mysql-server
and while installing it is required to set the root password

References: http://labnotesh.wordpress.com/2009/04/28/compiling-ruby-19-with-gcc-4/

Hope that it is some how useful for you
Enjoy :)

Posted in RubyOnRails | 2 Comments »

Top Coder Chatting with ACRush

Posted by mohammadkotb on May 29, 2010

TopCoder

Hi,

This is a very interesting chat with ACRush on TopCoder, taken from this link, and thanks for my friend Mohamed Gaber for giving me this link

Enjoy :D

=================================

FameofLight ACRush: Finally the god of programming arrives
FameofLight ACRush: do you follow a random practice , or you practice question by topic , in your early days
ACRush FameofLight: No, our team practiced 3 or 4 full contests a week.
pt1989 ACRush: Can u tell us whom or what do u credit for ur success?
ACRush pt1989: I think more practice is the way.
ktuan ACRush: how can you arrange your study with 3-4 contests a week ?
ACRush ktuan: UVA, SGU , ZJU and PKU is enough.
pt1989 ACRush: what is ur method of practising? random or organised?
ACRush pt1989: contest env. We always solve programs in contest env.
Sunny_05 ACRush: wat is ur daily routine ?? i mean hw do u practice everyday ??
ACRush Sunny_05: We only have weekly routine for practice.
binarywithme ACRush: what u think about world final problems..level of difficulty
ACRush binarywithme: A little harder than 1000p.
MB__ ACRush: Which of these do you do after you submit your solution on TC: test solution, re-read problem statement, check code line by line
ACRush MB__: test for at least 10 cases.
martins256 ACRush: how many problems have you solved on OJ ?
ACRush martins256: about 2000.
kcm1700 ACRush: How many problems have you proposed on OJ or anything like this competition or something…?
ACRush kcm1700: about 2000.
vijay_comc ACRush: Who is your Arch Rival in Programming ? ;)
ACRush vijay_comc: Petr, I think.
SomethingWrong ACRush: What is your favourite Online Judge?
ACRush SomethingWrong: SGU.
vexorian ACRush: Why SGU?
ACRush vexorian: More tricky testcases.
Dee2306 ACRush: Being one of top programmers, do u believe its just practice which makes u perfect.. or some of u are born genius ??
ACRush Dee2306: It’s at least 80% due to practice
stormsky ACRush: how to practice ACM for a ACM beginner?
ACRush stormsky: practice in contest env.
piva ACRush: Do you train more of one category of problems? Or you just solve problems at random?
ACRush piva: I do more practice in the ones I have troubles with.
pt1989 ACRush: what are ur interests other than programming?
ACRush pt1989: WarCraft.
vijay_comc ACRush: Petr is already married. No plans to compete him in that area ?
ACRush vijay_comc: ….not yet.
Sarkin ACRush: Is analyzing algorithms an essential part of learning algorithms?
ACRush Sarkin: Not all, I think coding is in practice room is the rest way.
abdessamad ACRush: can believe it! when i see your challengers
ACRush abdessamad: It’s one thing that Petr did much better than me.
stjepan ACRush: where did/do you practice most and how?
ACRush stjepan: And join contest.
binarywithme ACRush: why u choose c++ as a default programming language
ACRush binarywithme: er.. Stl is the first reason. Another one may be efficient.
geekru2 ACRush: during contest, what kind of problems do u enjoy doing? as in type of problem?
ACRush geekru2: dp and network-flow.
reginachris ACRush: What’s the best OJ to start with for practice (UVa, SPOJ, TC, etc.)?
ACRush reginachris: USACO
ferry ACRush: What do you do when you can’t solve a problem or you don’t know what’s wrong?
ACRush ferry: I will try to pass it in practice room. I always do that.
geekru2 ACRush: Do you solve puzzles and mind bending questions to improve your problem solving techniques?
ACRush geekru2: no. I don’t like such problems like suduko.
Sarkin ACRush: What algorithm types helped you in the IOI?
ACRush Sarkin: dp.
abdessamad ACRush: did you like chess?
ACRush abdessamad: yes.
geekru2 ACRush: when in a team event(IOI etc), do you dominate while programming?
ACRush geekru2: yes. I guess.
kcm1700 ACRush: how do you prepare data for the challenge phase?
ACRush kcm1700: The trickiest one, of course.
binarywithme ACRush: sir what is the best way to learn DP.
ACRush binarywithme: TC contest.
[dasha] ACRush: When u were beginning to compete,did u have any problems? Like low speed of sloving, or maybe some particular method u couldn’t understend for a long time, sth else? If yes, how did u get over that?
ACRush [dasha]: USACO is a really good place. Especially for the beginners.
frank44 ACRush: how long did the usaco practice take you?
ACRush frank44: half one year.
binarywithme ACRush: what u think math should b strong to become a Gud programmer
ACRush binarywithme: The mathematical foundation is helps.
khanhptnk ACRush: excuse me, do you think what we should prepare before an important contest ?
ACRush khanhptnk: relax, and rush some s i m p l e problems. And solve some problems in a contest env. is also helpful.
Sarkin ACRush: Do you recommned reading “Introduction to Algorithms”? if you know?
ACRush Sarkin: Really good.
coder29 ACRush: which parts do u advice to read in “Introduction to Algorithms”?
ACRush coder29: All parts are perfect. except complexity.
MB__ ACRush: do you do any sports but topcoding?
ACRush MB__: soccer.
vijay_comc ACRush: Complexity in CLRS is flawed ??
ACRush vijay_comc: 7-8
Sarkin ACRush: What do you mean except comlexity?
ACRush Sarkin: That’s only my opinion.
pcaldeira ACRush: which skill do you consider most important on TCHS/ioi-style contests?
ACRush pcaldeira: algorithm skills and coding ability.
coder29 ACRush: I am newbie…which OJ is better fr me…USCO or UVA?
ACRush coder29: USACO
hakami ACRush: Are you useing library or typing from first for SRMs?
ACRush hakami: some includes and basic untilities.
vrajesh1989 ACRush: Will you try to prove your algorithms to yourselves during contest time or just believe your intuition and start coding?
ACRush vrajesh1989: Yes, it’s very important for me.
Sarkin ACRush: Do you use algorithm analyzis when solving a problem to see it’s effeciency?
ACRush Sarkin: Yes. the effeciency sometimes is more important than correctness in TC contest.
coder29 ACRush: basically i want 2 to do pratice on DP and greedy types…is TCs’ room are sufficient..?
ACRush coder29: A bulk of dp tasks in SRMs. TC’s room is good.
rajeshsr ACRush: In short, what is the strategy for becoming a good coder, according to u?
ACRush rajeshsr: Practice is the way.
Lingmum ACRush: How can we improve our speed of solving the problems,more problems?
ACRush Lingmum: More practice.
stormsky ACRush: do you often practice TC?and how to practice?
ACRush stormsky: Yes. But in fact, I prefer to doing past Regionals and finals.
sahiltiwari ACRush: how many hours you practise per day ?
ACRush sahiltiwari: 4-5
MohammadReza ACRush: What do you do to make your code becomes bugfree although the big size?
ACRush MohammadReza: test more tricky cases.(corner cases)
rajeshsr ACRush: Sorry to be repetitious, But I want to know what is the strategy of practice you employed? U select some random problems from OJs and solve or try to master a particular domain like DP by solving problems based on that or any other thing?
ACRush rajeshsr: set problems of past regionals and finals.
puneetkp444 ACRush: Can you suggest some ways to improve problem solving abilities
ACRush puneetkp444: practice all kinds of problems.
alft7 ACRush: what do you usually do before a very important competition, practise or something else?
ACRush alft7: practice until 3 days before it.
ferry ACRush: What is the hardest problem you’ve done?
ACRush ferry: I in WF2007


Bye :)

Posted in Algorithms Contests, TopCoder | 4 Comments »

تعبير عن اللي جوايا

Posted by mohammadkotb on May 5, 2010

أنا مش متعود خالص إني أقرأ شعر أو زجل أو حتى روايات، و مش بفهم فيهم حاجة خالص، بس ساعات كده في حاجات بتشد الواحد وبيحب يكملها للاخر، زي القصيدة ديه لأحمد فؤاد نجم

نفسى فى صنف حشيش
> ينمل الدماغ وينضف النخاشيش
> علشان انسى طابور العيش
> واخش فى الغيبوبه وانسى مشكلة الانبوبه
> وانسى بلدنا المنهوبه
> وانسى اللى بيجهزوه علشان يبقى رئيس للمخروبه
> وابقى مسطول
> وانسى اى مسئول
> من اللى سابوا الناس فى السيول
> وانسى ان نظيف اتجوز وبقى بيعول
> وانسى مجلس الشعب وفتحى سرور
> وانسى البرادعى وايمن نور
> وانسى شوبير ومرتضى منصور
> وانسى تعديل الدستور
> وانسى اللى ساكنين فى القبور
> وانسى انفلونزا الطيور
> وانسى مشاريعنا الفاشله
> فى توشكى وابو طرطور
> واخش فى الاستهبال
> وانسى علاء وجمال
> وانسى التوريث
> و النيل اللى نازلين فيه تلويث
> وانسى ان منتخبنا كويس زى ماقال الريس
> وانسى تصدير الغاز
> واحناعندنا ازمة بوتاجاز
> وانسى الاضهاد واللى بيحصل للاقباط
> وانسى قطر العياط
> وانسى قطر الصعيد
> وانسى احمد عز واحتكار الحديد
> وانسى زحمة المواصلات
> وانسى الانتخابات
> وانسى فتاوى الفضائيات
> وانسى العشوائيات
> وانسى فشل التعليم
> وانسى هشام طلعت وسوزان تميم
> وانسى الاهرام وانسى الاخبار
> وانسى ثروة الريس ال40 مليار
> اللى مش بالجنيه المعفن لا بالدولار
> وانسى انه خلى بلدنا افقر من زنزبار
> وانسى المعارضه وانسى الاحزاب
> وانسى تامر حسنى وعمر دياب
> وانسى مشكلة النقاب
> وانسى ارضاع الكبير وشرب بول البعير
> وانسى انفلونزا الخنازير
> وانسى اوربا وامريكا وانسى الصين
> المتقدمين عننا بسنين
> وانسى البيت بيتك و تامر امين
> وانسى ان كيلو اللحمه بقى بتمانين
> وانسى اننا فى الزباله غرقانين
> وانسى الماده سته وسبعين
> والماده سبعه وسبعين
> وانسى فريق الساجدين
> وانسى الزمالك والاهلى
> وانسى اليسا وهيفاء وهبى
> وانسى الفول والطعميه
> وازهى عصور الديموقراطيه
> وجامعة الدول العربيه
> والجماهيريه الليبيه
> والكفيل فى السعوديه
> وانسى بطرس غالى و الضريبه العقاريه
> وانسى الطلعه الاولى الجويه
> والمصالحه الفلسطينيه
> وانسى فتح وانسى حماس
> وانسى هنيه ومحمود عباس
> وانسى العراق وافغانستان
> وانسى ايران و انسى باكستان
> وانسى ماما سوزان
> وانسى الاخوان
> وانسى محمد ابراهيم سليمان
> وانسى ان حد بالمليون يطلع كسبان
> وانسى انى مديون
> بيطلعوه مجنون
> وانسى كل ممثله حيزبون
> بتاخد فى المسلسل كام مليون
> وانسى ايامنا السوده
> وانسى القذافى والبشير
> وانسى كل ملك وكل امير
> اللى حاكمين من سنين
> من غير تغيير
> وعلشان اعرف ان الصنف كويس
> لازم ارشح نفسى وابقى الريس

بغض النظر عن التجاوزات و التشبيهات اللى موجودة، لكنها معبرة جدا جدا والصراحة بتوصف اللى جوايا جدا جدا جدا

مش عارف ديه هتكون اخر مرة هكتب فيها حاجة زي كده ولا لأ، بس أنا كتبتها دلوقتي عشان مخنوق جدا من حاجات كتير حوليا


سلام

Posted in 7'an2a, Free | 1 Comment »

8th ACM Egyptian National Contest 2009

Posted by mohammadkotb on October 19, 2009

Alexandria University Faculty of Engineering Teams

Alexandra University - Faculty of Engineering teams

Dear friends,

How are you all, today is the next day after coming back from the 8th ACM Egyptian National Contest in Cairo (Faculty of Computer and Information Cairo University).

In the train with eng. Bassiouny asking him in some problems :)

In the train with eng. Bassiouny asking him in some problems :)

Really yesterday was a very hard day, I have slept for only 1 or 1:30 hours before waking up to go to the contest, then I went to the Railway station to start our traveling  journey. But unfortunately the train was very bad, it come to the station after 20 mins from its original time :S and when we enter to our car some of our friends saw a mouse in running under the chairs :D (Wow mouse in the train), the train was very slow, and we reached Cairo with a delay not less than 1 or 1:30 hour.

Alex Uni Engineering teams in the Opening session

Alex Uni Engineering teams in the Opening session

Then we reached to the FCI after the registration was closed :) , but we went before the Opening Session, really it was very hot and we are very tired, then we started our practice session to try everything as in the contest environment, then we went to pray and then have a break till the contest start..

AlexCSE 1 during the practice session

AlexCSE 1 during the practice session

In the contest we my colleague Abdel-Rahman have found the easy problem, so I got it to code this problem and I have submitted it in 4 mins only, that it want to get the number of even number and odd numbers in a group of given numbers, I thought that I was the first one to solve this problem in the contest but I found that FCI-CU 1 team have solved it in 2 mins only (ma sha2 Allah)  :D, after solving this problem we went pending for 1:30 to 2:30 hours without solving any other problem, we tried to solve more than one problem but we got time limit or WA :S, then el hamd L Allah we started submitting problem and got other 3 YES mesages :) , and went to the 10th place but we solved the 4th problem in the blind hour and don’t get its balloon :(

AlexCSE 1 after the contest before announcing results

AlexCSE 1 after the contest before announcing results

Finally, it was very good day el hamd L Allah, and our teams got the 10th, 15th, 18th, 29th, and 31th ranks in the contest. Really the FCI-CU guys were very tired to organize such event, but of course there are some problems but really Good Work. Really all our teams want to thank eng. Mahmoud Bassiouny for his hard work with us, really he is a very good person that rarely you can meet.

On the metro station after the contest (on our way back to Alex)

On the metro station after the contest (on our way back to Alex)

And one of the comic situations that we have during the contest we have, in the submission system in the contest you can request a Clarification to the judge and he can reply to you only, or reply to all this clarification and publish it all the contestants. The judge has to reply to the important clarifications only and if it is a silly one he have to reply with standard reply which is “No Response, read the problem statement“, but the judge who is responsible for the clarifications in this contest wasn’t a good one as I think, first of all he was publishing all the clarifications even the ones who are replying to them with the standard reply, and also he is answering the silly questions such as “In cpp how can I use method sort, #include <algorithm> or not??“.. so I really bothered from these messages that popup during the contest so I sent to him a clarification asking him “Please don’t publish any clarification except the important ones“, so after a few minutes he replied to my clarification and published it too :D and said “No Response, read the problem statement:D looool, I can’t say anything except looooool :D

And in our way back we went to abdel men’em riyad and took a bus at 11:00 pm and I have reached my home at the end at 3:00 am, I can’t wake up at the morning to go to the faculty and I waked up at 3:00 pm then after an hour I went to bed again to start my day at 8:30 pm :)

Thanks to all my friends in this journey, and a great than to eng. Mahmoud Bassiouny. And here are the Results for who want to check it :)

Salam,

Posted in ACM, ACM ICPC, Algorithms Contests | 3 Comments »

A week ago

Posted by mohammadkotb on October 13, 2009

Eng. Bassiouny with organizers and AlexCSE teams

Eng. Bassiouny with organizers and AlexCSE teams

Elsalam 3alikom

wow, It long ago since I wrote my last post it was in the summer when I was in eSpace :) , today I will take about an important event done in our faculty in the last week (Thursday 8th October 2009), we held an ACM contest practicing with other faculties as FCI-CU, AAST, GUC, and AlexCSE :)

Really, it was a very great day el Hamd L Allah (of course it contains some problems but it is a good day for the first time), we stayed in the college for 2 days before the contest preparing for it, really all of us we very tired before and after the contest all of us were working to finish all the tasks as soon as possible especially eng. Mahmoud Bassiouny, really this man exerted great effort in preparing this contest.

AlexCSE 1 during the Contest

AlexCSE 1 during the Contest

Before the contest I was one of the main organizers in the contest, but during the contest I was a contest in “AlexCSE 1” team :) with my friends Abdel-Rahman El-sergani and Hussien Nomier, we are very tired in the contest and I want to sleep after two hours and can’t concentrate :) but we tried to concentrate but we can’t solve more than 5 problems :) and there are 3 problems we are working but we can’t finish them before the deadline of the contest :( so el hamd L Allah.

Problems are with different levels, one of them is very easy Adhoc problem solved at the beginning of the contest in 7 minutes, then a Prime Generating problem we solved it quickly in less than 25 mins but there is a small bug in the code :( I discovered it after 50 mins from the contest. Also there is an easy counting techniques problem solved by Hussien and other  2 problems (I think dynamic programming) solved by Abdel-Rahman. And then we can’t accpet any other problem :( but we were working in  2 tree problems one solved by DFS and the other solved by Backtracking, and the third problem is making a Java Compiler but very simple contains only if, for, while and assignment statements, really I liked this problem and wrote the regex of the assignment statement and boolean expression but it doesn’t work during the contest, and worked after the contest when I went home :(

Teams after the contest

Teams after the contest

After the contest I was very sad as there is an easy problem we didn’t finish but el hamd L Allah, after announcing the results we were in the 7th place. The standings “FCI-CU 1, FCI-CU 2, FCI-CU 3, AlexCSE 2, Gold Ace (GUC), IOI, AlexCSE 1

Really I liked this contest too much especially that it is the first contest to be held in our college, and organized by Alexandria University ACM Student Chapter. I hope that my team get higher rank in the next contest, as there is ACM Egyptian National Contest next Saturday (17th October 2009) will be held in FCI-CU. Pray to us :)

regard,
Mohammad Kotb

Posted in ACM, ACM ICPC, Algorithms Contests | 2 Comments »

 
Follow

Get every new post delivered to your Inbox.