/log

life.log()

Archive for the ‘software’ Category

Primes Problem in Python

with 10 comments

السلام عليكم و رحمة الله و بركاته

Lately I decided to give SPOJ website a try ..
And my first problem after the TEST problem was the “PRIME1” problem..
Which is basically finding the prime numbers between 2 given numbers ..

Yesterday, regardless the fact of being truly ill and I hardly could open my eyes ..
I decided to solve the problem ..

and after I think 1 hour It started to output relatively right solution ..

here is my code in python:

times = input()
while times > 0:
    times -= 1
    limits = raw_input()
    limits = limits.split(" ")
    downLimit = int(limits[0])
    upLimit = int(limits[1])
    numsList = []
    numsList = [i for i in range(downLimit,upLimit) if (i%2 or i==2) and i != 1 and i!=0]
    primesList = list(numsList)
    for oddNumber in numsList:
        primeNumber = True;
        for number in range( 2 , oddNumber / 2):
            if oddNumber % number == 0:
                primeNumber = False;
                break;

        if not primeNumber:
            primesList.remove( oddNumber )

    for primeNumber in primesList:
        print primeNumber

Notes:
1-in line 9, I used list() to assign the numsList value to the primesList list .. not the numsList as python-strangely- assigns the old list reference to the new list and that caused +1 hour of debug .. :@
2-As shown in page title after submitting the problem they replied that solution exceed the time limit .. so any help will be appreciated ..
3-Python version 2.6.2 on Mac

Written by me

February 5th, 2010 at 11:39 am

Posted in I code,software

Tagged with , ,

TDD using PHPUnit, NetBeans

with 5 comments

السلام عليكم و رحمة الله وبركاته

This post is more than month on my drafts ..

It’s about using NetBeans 6.7.1 PHP IDE with PHPUnit I wanted to show how easy is it to make a test and run it ..

so I’ll share the experiment ..
As shown in the following slideshow:

1-I created a PHP Class file:

2-I created empty file with a class and couple of methods

3-I generated a test for the class and it prompted me to choose the folder where I’ll put the tests

4-Finally(My favorite part) I right click the test file to run it and I get the result in green and red … obviously
green is test passed or pending and red if it’s failed ..

Note: I used to use simple test , still can’t find equivalent test method to test the HTML interface … and it always required me to view the test results in the browser ..
PHPUnit is more fun now and it’s integrated to NetBeans, the IDE I recently love at most specially on Mac

Written by me

February 4th, 2010 at 11:37 am

tadabor.com, one more 7-12 website

with 4 comments

السلام عليكم و رحمة الله وبركاته
الحمد لله والصلاة والسلام على رسول الله

أنه لمن دواعي سروري ان أعلن إني فعلا فخور بموقع الهيئة العالمية لتدبر القرآن الكريم

و شكرا لـ:

My dear framework 7-12

م.محمد العشري مدير شركة تدبر
وشكر خاص جدا ..  لماهر سيف “الماهر بأمر الله ” اللي بهدل ٧-١٢    :)
فريق التصميم في شركة تدبر و مهندس علاء الدين حسين .

وأسأل الله العظيم رب العرش العظيم أن يجعل الموقع و المواد المتاحة عليه في ميزان حسناتنا وميزان حسنات الشيوخ القائمين عليه و الهيئة وأن  ينفع الله به الكثير من الباحثين عن الهداية و  طلبة  العلم من المسلمين والمسلمات.. اللهم آمين .. اللهم آمين .. اللهم آمين ..

والحمد لله رب العالمين

Written by me

January 3rd, 2010 at 8:47 am

Posted in I code,I recommend,software,أخبار

Tagged with ,

XML, The eXtensible Markup Language

without comments

السلام عليكم و رحمة الله و بركاته

Lately, I’m interested in making more semantic web applications or at least applications that has XML meaningful output instead of XHTML or HTML..

Also I’m interested in MVC design pattern and the CRUD scaffolding technique had a great impact on my productivity, My Framework 7-12 used to create the Model View and the Controller for me automatically ..  the view file used to be HTML, which also was so complicated and dependent on my theory of web design,.. which isn’t always compatible with others .. :D

So, here again the Meaning<->Presentation separation idea appears again ..

One more thing was going in my head … which is XML Data islands,  which is IE ONLY feature ..
Basically it’s how to bind a XML data source to your HTML keep the design attached to that source fields as long as it’s XML even if it was a dynamic ie. PHP file that send XML in response ..

After thinking on how to reach my destination I decided just to format my views XML and style them CSS and not XSLT..
And may be I’ll use XForms .. !!

And still thinking …

Written by me

January 1st, 2010 at 10:37 am

google docs children pt.2

with one comment

السلام عليكم و رحمة الله وبركاته :)

In this post I’m completing what I’ve started talking about in last post ..

I talked about online /web applications that are evolving so fast ..and I made google docs the father of these applications for a reason .

كلامي المره السابقة كان يقصد انظمة التشغيل اللي احنا فعلا ممكن نحس انها استغلت انها

WEB BASED

ببساطه كل التطبيقات اللي عرضتها المره السابقة كانت بتعمل version control ألى جانب الخدمة وكلها كان فيها collaboration

وكلها ممكن تشغلها مع services تانيه و يمكن يكون ليهم هما كمان api و هو ده بالظبط اللي مفروض يكون عليه الonline operating system….

الموضوع مش موضوع انك تخلي الdesktop applications تبقى webapplication لأن أكيد هتكون الغلبه والسرعة في الاخر للdesktop application اللي ليها حق الأستخدام المباشر لموارد الماكنه اللي انت بتستخدمها .. بعكس ال web browser اللي دايما ولأسباب أمنيه بحته هيفضل قدراته محدوده ..

وعشان كده انا كل يوم بيزيد إعجابي ب google docs لأنهم شافوا ان الdocs تبقى online احسن إزاي وعملوها ..

واللي كمان كان شاددني في البوست السابق اني لاحظت ان الoperating system اللي بفكر فيه في واقع الأمر ممكن يكون مش بعيد لأنه الوقتي -فقط- محتاج يلم الAPIs بتاعة التطبيقات الموجوده online ويلمها في موقع واحد ويبقى لما تشغل office تستخدم google docs  ولما تعمل search تستخدم google search API و كده ..

اسف على الإطاله

في أمان الله :)

Written by me

June 21st, 2009 at 9:37 am

Posted in I recommend,software

Tagged with , ,

google docs children {yUML,minmeister,www-sql-designer,creatly}

with 5 comments

السلام عليكم و رحمة الله وبركاته

Today I’m intending to talk about some of the websites that really made me feel like the online operating system idea is closer than what you may think  ..

Following websites are illustrating the idea I’m talking about:
1-yUML.me Beta websites that lets you create a very nice UML and Use cases diagrams easily and with very easy syntax, and the most important thing is you can get these resultant designs in URLs like that one:

http://yuml.me/diagram/usecase/[Super Admin]^[User],[Secondary Admin]^[User],[Customer]^[User], [Customer]>[Buyer],[Customer]>[Seller],[Seller]^[Buyer], [Buyer]-(search or browse items for sale),[Buyer]-(browse item details and its owner contacts),[Buyer]-(sign up for the seller profile)

NOTE: the code after the “usecase/” is the code you made to create the following diagram:
Free Image Hosting at www.ImageShack.us

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!


mindmeister.com : besides being a very nice and easy to edit mind maps tool.. it has a very nice option which is collaborative work ..
which means you can invite your friends and work  together in the same mind map .. which is super fun ..
And  guess what again it’s free and i tried it in some applications and the last one was CAT document and I worked on it with Mohammed Safwat and mohammed el Emam :)
Another Suppper option is the Export option .. which is the ability to export PDF, Images. rtf, and other  desktop mind map tools {mindmanager, free mind}formats if you want from the online one you made .. which saved a loooot of time to me .. and YOU HAVE TO TRY it ..!
Free Image Hosting at www.ImageShack.usزز

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!

And for programmers; you have to see this ..
http://ondras.zarovi.cz/sql/demo/

….to be continued انا رايح ألعب ينج بونج ..

في رعاية الله و أمنه

Written by me

June 12th, 2009 at 4:18 pm

Get Adobe Flash playerPlugin by wpburn.com wordpress themes