Generators/Coroutine using Actors 24 Jan 2014

class FibonacciGenerator extends Actor {
  import FibonacciGenerator._
 
  def receive = fib()
 
  def fib(a: Long = 0, b: Long = 1): Receive = {
    case Next =>
      val c: Long = a + b
      sender ! c
      context.become(fib(b, c))
  }
}
 
object FibonacciGenerator {
  case object Next
}

Back in first days using Akka, I didn’t notice that you can such lazy recursion using Actors. The previous piece of code let’s you generate infinite (until you hit Long.MaxValue) fibbonci numbers.

...
Playing with Scala futures 13 May 2013
A fast intro to Scala and Play, to prepare the audience for a live demo of a Play Application using Futures to get weather data from Yahoo in a non blocking way, then display to the user the results. The code is available here https://github.com/tabdulradi/weather ...
Introducion to Python 02 Jun 2012
A quick tour in Python world. First by By comparing Java code, and the equivalent Python side by side, Second by listing some cool features in Python, finally by listing downs and ups of Python in usage; when to use python and when not. ...
JDownloader 16 Oct 2008

JDownloader … One of the best Download Manager I’ve Ever used

It makes rapidshare much easier ( and megaupload too )

It doesn’t take the links in a single line inputbox, but in a BIG multiline textarea

...
Pausable Actors using Stash 06 Jan 2014

import akka.actor.{Actor, Stash}
class MyActor extends Actor with Stash {
  def receive = accepting
  def accepting: Receive = {
    case Do => 
      // Do logic here
    case Wait => 
      context.become(waiting)
  }
  def waiting: Receive = {
    case Do =>
      stash()
    case Resume =>
      unstashAll()
      context.become(accepting)
  }
}
object MyActor {
  case object Do
  case object Wait
  case object Resume
}

You should use Stash, if you want your actor to go “offline” for sometime, may be because a necessary external resource is down, like a database for example. However while the actor is offline, it should remember all the messages that it couldn’t handle right now, hoping it can recover soon, and handle those messages.

...
Classification of type systems 07 Jul 2012
How to classify the type system of programming langugaes, what is the difference between typesystems of Java, Javascript and Python?
What is the difference between Strong typed languages and statically typed languages? ...
Finished ITI Python Course 12 Apr 2012
I've just taught almost half of #Python for #ITI students in 6 hours!! These guys are awesome. #Egypt #Mansoura ...
Python Course for Developers, October 2011 21 Dec 2011

I’ve just finished my Python course, I was very glad to convert .Net developers into opensource world, they seemed to like Python, Thanks to Allah :).
We covered the basics of python, and it’s good practices, conventions and of course Magic. I gave them an fast introduction to  Django, as they were interested in Web Development .
God bless Open Source, God bless Egypt :).

...
HP TouchSmart tx2-1035ee Notebook PC 07 Mar 2009
I've just bought my TouchSmart, and this is my feedback. It came with: two manuals ( HP & Vista , A Remote Control , A Pen , 2 batteries (one 4 cell , and the other 8 cell), a tissue to clean the screen , which gets dirty with my fingerprints :D, a small bag , very bad bag , it doesn't have any handle to carry from :s , it fits only from keeping dust away from the tablet. ...