Google Buzz, OAuth And Python

Google Buzz is a social networking and messaging tool from Google Inc. that’s integrated into GMail. Google Buzz was released in early February this year (9th Feb 2010), and since then it has emerged as an important social network for GMail users, and many people (including me) prefer it now to other social networking platforms such as Facebook.

Logos of Google Buzz, OAuth And Python
Logos of Google Buzz, OAuth And Python

In May Google revealed the Buzz API to the public so developers around the world could write applications to interact with Google Buzz to read and/or write.

Continue reading “Google Buzz, OAuth And Python”

Google Talk Status Countdown

A few days ago I was counting down to a presentation in my faculty. As I was setting counters all over my world (Side Bar Gadget, To Do List) I thought of a way to change my Google Talk status to a counter also.
Since I know that Google Talk uses XMPP protocol, and since my friends and I implemented XMPP last year in our faculty I tried to make a program to set my status to a counter; and here is the result:
XMPP Status Changer
Continue reading “Google Talk Status Countdown”

Display Sub-terms In Drupal Term Page

After working with Drupal in the last two months I’ve really got used to searching for modules for every problem I face and installing them.
While I was working on iCommunity website, I was creating taxonomy terms to categorize the files using them. I created terms with sub terms. The problem was that when browsing a specified term the term page doesn’t display the sub terms of that term.
Continue reading “Display Sub-terms In Drupal Term Page”

Simple AJAX Comment Preview in Drupal 6

As I said in my previous post, I’m working on upgrading Computer Science in Syria website to Drupal 6.

I wanted also to have AJAX comment preview in nodes, but I wanted it to be simple without lots of JavaScript loaded. So as usual I got pissed off and decided to create my own code to do it. 8)
Continue reading “Simple AJAX Comment Preview in Drupal 6”

Simple AJAX Quote in Drupal 6

I’ve been upgrading the forum of Computer Science in Syria for a week now.

The forum uses Drupal, and it ran a beta version of Drupal 4, and I upgraded it to the latest Drupal version now.

I wanted to have AJAX quoting in the forum, but I wanted it to be simple without lots of JavaScript loaded. So as usual I got pissed off and decided to create my own code to do it. 8)

Continue reading “Simple AJAX Quote in Drupal 6”

Notepad++ Plugin To Run Python Scripts

I use Python everyday, it has become my first tool to use when I need to do anything. In Arabic (in Syrian Arabic specifically) I’d say that Python has become my hand and leg 😛

Yesterday I was writing a small Python script to read the YACC file and generate a list of all the specified rules inside it, so I don’t have to scroll through the long file to find out what rules are inside it 😉

I use Notepad++ as my default text editor on Windows, and I was writing the script using it – Notepad++. I wanted to test if the script is working, so I ran an instance of Command Line Prompt, and as I was going to change the directory to the directory of the script I thought; “Why doesn’t Notepad++ have a Run In Python command in it?”. So as usual I got pissed off and decided to create my own plugin to have that command in Notepad++ 8)
Continue reading “Notepad++ Plugin To Run Python Scripts”

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

Continue reading “Brainfuck Python Interpreter”

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:

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).
Continue reading “Binding NetBeans with Flex”

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.

Continue reading “Get Online Users in Django”

I’m Learning Python part 10 (last one)

I'm Learning Python part 10

(last one)

Python Logo

Back to blogging

As usual, I will apologize for not blogging for a long time.
I have been very busy, university exams, university projects, job projects, teaching and learning.

Python Course

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.
As far as I know this course was the first Python course in Damascus University.
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.
As far as I know too, students understood it and found it great, and I hope they’ll be using this great language more in their programs.

Why last one?

The tour with Python ends here, while it ends here it starts here too, it ends here because so far you’ve learned what you need to start your own path in Python. And it starts here because you’re fully equipped with the base tool to discover more tools, I’ll let you discover the standard library and 3rd-party libraries on your own, because everyone differs in his/her interests.
I’ll be blogging more on more technical issues but they might not be I’m Learning Python series :).
Let’s stop talking here and move directly to the heart of our last lesson.
Continue reading “I’m Learning Python part 10 (last one)”