Abdullah Diab’s Blog

  • Brainfuck Python Interpreter

    What is brainfuck?

    Brainfuck is a programming language

    This is the definition from Wikipedia:

    The brainfuck programming language is an esoteric programming language noted for its extreme minimalism. It is a Turing tarpit, designed to challenge and amuse programmers, and is not suitable for practical use. Its name has been variously bowdlerized. The name of the language is generally not capitalized, although it is a proper noun.

    This programming language is very easy to learn, very hard to do work with. As the Wikipedia article describes it; the language is an esoteric language, which means it was created for fun

    I discovered the language while I was reading an article about writing the perfect settings file for Django. The author used DPaste website to link to pieces of code. DPaste website says that it uses Pygments for syntax highlighting. Pygments say that their syntax highlighter even supports brainfuck. And that’s how I got to brainfuck

    After I read articles about the language I wanted to test some code of it, I found some online interpreters, but I wanted to test some code on my machine. I found a compiler for it, but I’m using Windows 7 on my machine and the compiler is not compatible with it. I got pissed off and I decided I have to write my own interpreter

    Read more…
  • Binding NetBeans with Flex

    In my faculty – Informatics Engineering, Damascus University -, in the 4th year of Software Engineering Department, we have to build a compiler :shock:.

    I like using NetBeans for developing applications, it supports lots of languages and tools; like C, C++, Java, Python, Ruby and more. The compiler would be implemented in C++.

    The first two phases of implementing a compiler are: building a lexer (tokenizer) and building a parser. The lexer is implemented using GNU Flex while the parser is implemented using GNU Bison.

    The Problem

    The first problem I faced when starting the project was to tell NetBeans how to handle the lex file:

    The lex file must be passed to the flex tool to generate a C++ code file.

    The second problem was that when the code file is generated it contains errors:

    #ifdef __cplusplus
    
    #include <stdlib.h>
    class istream;
    #include <unistd.h>
    

    When using building the file you’ll find that it contains errors regarding the usage of istream. (You might not face this problem, then you’re a lucky programmer).

    Read more…
  • Get Online Users in Django

    I was upgrading my Django Bookmarks site, and I wanted to list the online users. I searched the internet and I found a simple method, but it doesn’t work properly. So I developed my own method.

    Why the simple method didn’t work?

    The problem with it is that it depends on the last login date in the user model. This field is updated on every login for the user.

    Imagine the following scenario:

    • The user X logs in @ 1:00 pm.

    • The user X posts a new post @ 1:30 pm.

    • The user X comments on a previous post @ 1:35 pm.

    • The user X leaves the website @ 1:40 pm.

    • The user X comes back to the website @ 3:00 pm.

    • The user X is logged in since the session cookie has not expired yet.

    • The user X posts a new post @ 3:15 pm.

    • A guest enters the website, and looks at the online users corner.

    The guest won’t see X’s name in the list of online users, simply because X’s last login date is @ 1 pm, even though user X is now online and he has just posted a new post.

    Read more…
  • I’m Learning Python part 10 (last one)

    I'm Learning Python part 10

    <p>
      <h1 style="font-size:18pt;font-family:Verdana;">
        (last one)
      </h1>
      
      <p>
        <img src="http://www.python.org/images/python-logo.gif" alt="Python Logo" title="Python Logo" /> </div> 
        
        <h1 style="font-family:Georgia;">
          Back to blogging
        </h1>
        
        <p>
          As usual, I will apologize for not blogging for a long time.<br /> I have been very busy, university exams, university projects, job projects, teaching and learning.
        </p>
        
        <h1 style="font-family:Georgia;">
          Python Course
        </h1>
        
        <p>
          At Damascus University, in the faculty of informatics we managed to create free courses to students, and I was one of the teachers there, I taught Python to students.<br /> As far as I know this course was the first Python course in Damascus University.<br /> Even though the students were a few (actually a very little few about 8 ~ 10 students) the course was great. We managed to learn Python 2.6 Syntax, a little bit of its standard library and a little bit of PyQt4 in about 7 days x 2 hours daily.<br /> As far as I know too, students understood it and found it great, and I hope they&#8217;ll be using this great language more in their programs.
        </p>
        
        <h1 style="font-family:Georgia;">
          Why last one?
        </h1>
        
        <p>
          The tour with Python ends here, while it ends here it starts here too, it ends here because so far you&#8217;ve learned what you need to start your own path in Python. And it starts here because you&#8217;re fully equipped with the base tool to discover more tools, I&#8217;ll let you discover the standard library and 3rd-party libraries on your own, because everyone differs in his/her interests.<br /> I&#8217;ll be blogging more on more technical issues but they might not be I&#8217;m Learning Python series :).<br /> Let&#8217;s stop talking here and move directly to the heart of our last lesson.<br /> 
    

    Read more…
  • Bring Down IE6

    I have copied the following post from this site.

    Discover the mission

    The premise is simple: Internet Explorer 6 is antiquated, doesn’t support key web standards, and should be phased out. This isn’t about being anti-Microsoft, it’s about Microsoft’s lack of development in the browser market. With IE7/8 not available for Windows 2000, IE6 accounts for up to 20% of web usage, primarily via business users. Clients pressure designers to ‘force’ sites to work in IE6, and designers, not wanting to lose business, comply, using hacks and workarounds. This wastes time and money. Microsoft needs to fix this, designers need to unite, and we all need to move on.

    Read the article

    <p>
      In our article, ‘<a href="http://www.bringdownie6.com/bring-down-ie-6.html">Calling time on IE6</a>’, we ask designers and developers if it’s finally time to take IE6 behind the shed and shoot it. Major names in the web industry debate our mission, talking about the pros and cons behind dumping IE6. How feasible is it to shun the browser entirely? What can you do to minimise the impact IE6 has on you and your clients (and increasingly tight budgets)? And what can and should Microsoft do to help us all move the web and web standards on? <a href="http://www.bringdownie6.com/bring-down-ie-6.html">Find out by reading the article</a>, or just ‘skip to the end’ by looking to the right and getting involved.<br /> 
    

    Read more…
  • I’m Learning Python part 9

    I’m Learning Python part 9

    <p>
      <img title="Python Logo" src="http://www.python.org/images/python-logo.gif" alt="Python Logo" /></div> 
      
      <h1 style="font-family:Georgia;">
        Classes In Python
      </h1>
      
      <div dir="ltr">
        As I told you before, Python is a powerful programming language, and powerful it won&#8217;t be without Object Oriented design.
      </div>
      
      <div dir="ltr">
        Python supports both Pure Object Oriented Programming (Every thing must be in a class) and Structural Programming (You can type code everywhere).
      </div>
      
      <div dir="ltr">
        It supports also other programming paradigms like Functional Programming. I won&#8217;t write about OOP and its uses, why we should use it, I&#8217;ll just give you the keys to use OOP in Python.
      </div>
      
      <h1 style="font-family:Georgia;">
        Defining a Class
      </h1>
      
      <p>
        Classes in Python are defined like this:
      </p>
      
      <p>
    

    Read more…
  • I’m Learning Python part 8

    I’m Learning Python part 8

    <p>
      <img title="Python" src="//www.python.org/images/python-logo.gif" alt="Python" /></div> 
      
      <h1 style="font-family:Georgia;">
        Python 3.0
      </h1>
      
      <p>
        Since the last time I wrote an article Python many changes happened in my life, one of them is the release of Python 3.0 (Which is known also as Python3K and Python3000).
      </p>
      
      <p>
        Python 3.0 is the first intentionally backwards incompatible Python release, which means that there are some changes you must notice before start coding in Python 3.0.
      </p>
      
      <p>
        Don&#8217;t worry that much, the language has become more useful, and also there is <a href="//docs.python.org/library/2to3.html">2to3 source-to-source conversion tool</a> which converts your Python 2.x code to meet the requirements of Python 3.0 🙂
      </p>
      
      <p>
        To find more about change in Python please refer to <a title="What's" href="//docs.python.org/3.0/whatsnew/3.0.html">Python website</a>.
      </p>
      
      <p>
    

    Read more…
  • iCommunity FOSS 09

    I mentioned many times before that I was planning to make a workshop about Free Open Source Software (FOSS) in Damascus, and thankfully I did 🙂

    The Idea

    The idea was to spread the culture of FOSS between the interested people here in Damascus.

    What I noticed was that almost 99% of computer science students didn’t know what Free Software is and what Open Source software is!

    Read more…
  • And we’re back

    After a month of not blogging, I’m back to blogging for Python.

    This month had a lot in it:

    • Computer Science exams @ Damascus University, so I had to study a lot.
    • Scientific Calculations Project, the project of this semester.
    • FOSS Workshop, which my friends and I arranged to in Damascus, and it was more than wonderful.

    After finishing my Scientific Calculations Project I made the choice of removing Windows for good from my computer, I’m going to make Ubuntu my only operating system to use.

    Read more…
  • FOSS Workshop

    Hello, if you don’t know already, I’m a Computer Science student from Damascus University Syria.

    My friends and I are working on an Open Source Free Software workshop here at the faculty of Computer Science, the workshop will take place on February 2009, but we are gathering some resources and information from now.

    The workshop will have lectures about Open Source, Free Software, Licenses, Open Source Free alternative for Commercial Proprietary software, and of course Linux OS.

    The workshop will also contain an Installation Festival where we are going to install Ubuntu 8.10 Intrepid Ibex for students on their devices and teach them how to use it.

    I’m gonna put some questions here and I’ll ask you to answer it, whether you own an Open Source company or you work for one.

    I’m neither a journalist nor an analyst seeker, but I want some answers from you to introduce you the way you want to students, please don’t waste this message because I’m not a journalist,  we want to spread the culture of Free Open Source Software here between students and contributing to the workshop would be very kind of you.

    Read more…