This blog is subject the DISCLAIMER below.

Sunday, December 11, 2011

FCIH Initiative family call for new members

FCIH initiative is group of FCIH graduates who are interested in passing their experience & knowledge to FCIH students. The kick off was on 7 November 2009; during these two years, we managed to hold number of sessions and  Java training.

We think of the initiative as our role towards the society and as a chance to help others find their way in life. Currently, we are hoping to add new members to FCIH  initiative family. Kindly, if you are interested, take a few minutes to fill  this form, if you are already a member please fill the form as well.

Please, feel free to spread the word to other FCIH graduates who might be interested.

.. more.

Wednesday, November 16, 2011


In this post we will talk about currying, why you may need it, how to implement it with different paradigms (OOP, meta-programming, and functional).

Let's first talk about motivation. Consider the simple scenario where you have a list of integers, and you want to filter it to extract only the integers you want. For instance this list could be a list of user IDs, and you want to extract only the users who are late in their payments to send them an email. 

It is pretty much straight forward to do it in a loop; but we want a clearer way that focuses on semantics. For example consider something like 

send_email_to(select_from(all_users, payment_due))

I've colored payment_due in red to make it clear its a function, not a variable. The function select_from could contain the loop structure (and maybe some database processing), where in each loop they apply the function payment_due to some user like this:

select_from(list, test)
  selected = {};
  for(i=0; i < list.length; i++)
    if(test(list[i]) == true)
  return selected;

Notice that the function payment_due must be a function that takes only one parameter, because that is how it will be called from inside select_from. In most languages which have first-class functions there is a built-in function which acts like select_from, exactly for this kind of purpose. This includes C++ and all functional programming languages. In C++11 it is called copy_if (it was dropped from C++ by accident).

Consider another «test» function that takes as argument a user ID, and returns true if the user’s monthly salary is more than 3000. That could be written as:

   return user.salary > 3000;

send_email_to(select_from(all_users, salary_greater_than_3000))

Maybe we have something like this:

   return user.salary > x;

   return salary_greater_than_x(user,3000);

send_email_to(select_from(all_users, salary_greater_than_3000))

C++ macros won’t do the same thing as above, but C++ STL bind2nd (which is also compile-time meta-programming) can do the same thing.

If we don’t know the value 3000 at compile time and instead we only have it in run-time, we can’t do this call select_from(all_users, salary_greater_than_x). This wouldn’t work because select_from expects a function taking one parameter only.

In C++ this could be fixed by using a functor, which is a class which overrides operator(), and hence could be used as a function. For example (this example is valid C++, not just pseudo code as the previous examples):

class salary_greater_than_x
   const int x;
   public: salary_greater_than_x(int x): x(x){}
   bool operator()(User user) { return user.salary() > x; }

send_email_to(select_from(all_users, salary_greater_than_x(3000)))

Lambda expressions does the same thing exactly, without the need to write a class for it. In C++11 (which supports lambda epxressions) that would be like:

send_email_to(select_from(all_users, [](User user){salary_greater_than_x(user,3000)}))

The lambda expression, just like the functor, stores the value 3000, which is a sort of a closure.

Lambda expressions is too powerful; you can define arbitrary functions. We don’t need all that power, we only need to fix one argument of another function. This is what currying does. For instance, we know that salary_greater_than_x takes two arguments. If the language we are using supports implicit currying (like Haskell) if we omitted the second parameter we end up with a function whose first parameter is fixed. Concretely speaking we can do this (notice I switched the first and second parameters in the definition of salary_greater_than_x) :

salary_greater_than_x(x, user)
   return user.salary > x;

salary_greater_than_3000 = salary_greater_than_x(3000)

send_email_to(select_from(all_users, salary_greater_than_3000))

or simply just :

send_email_to(select_from(all_users, salary_greater_than_x(3000)))

.. more.

Tuesday, July 12, 2011

Announcement: FCIH Initiative

FCIH Initiative….FCIH Revolution

If you love your country and want to take effective steps to raise Egypt
If you're seeking development, freedom, knowledge and science

So, you're a proactive Egyptian and FCIan and should join our FCIH Revolution
A revolution of knowledge, learning, working and a revolution of dreams

We're all together; FCIH Graduates and Students
We're all here to help each others; we're all here to develop our skills
Together, we'll have a better world, we'll have a better tom, and we'll have a better Egypt

We'll attend Technical & Business sessions to know
We'll be trained to learn
We'll do projects…and then we'll be ready to achieve

Let's join and train ourselves
Let's join and know the business world from experts from each field
Let's join and start building our future and career from now

Our program will be divided into three phases:
1-      Sessions Phase:
These sessions will open us a window to the business world, discuss technical topics and tell us about the world outside FCIH
2-      Training phase:
we'll have more than one training track, each track will be delivered and leaded by a group of experts in this track, we'll learn how to learn and how to apply what we've learned
3-      Projects phase:
After all this knowledge, it'll be our chance to do and achieve. We'll develop projects simulating business cases and deliver it according to modern software engineering methodologies used in real business by leading companies.

FCIH Initiative,
Don't wait the chance, create it


.. more.

Thursday, March 03, 2011

"Note in (Google) Reader" issue Fix

Probably you're familiar with the sharing button (at least on Firefox and Chrome) offered by Google reader to help you share stuff that don't have feeds. Today, for some reason I realized that mine wasn't working!



After tweeting about it, thanks to Flavio Gomes and @mtobis, I realized what went wrong. Seems like the JavaScript file used by the button was updated, without updating the button script accordingly.


To solve this, all you have to do is set _IS_MULTILOGIN_ENABLED a variable that's not defined (but used) in the script file in the button script. So add something like:


// or


// or better



at the beginning of the button script, just to set _IS_MULTILOGIN_ENABLED before it's accessed as "undefined" in the script.

.. more.

Monday, January 17, 2011

How to solve "Silverlight.CSharp.targets was not found" problem

Friend of mine asked that she can't build any Silverlight project inside VS 2010 from
The error was similar to : 
C:\OverlappingTabs.csproj : error  : Unable to read the project file 'OverlappingTabs.csproj'.
C:\OverlappingTabs.csproj(108,3): The imported project "C:\Program Files\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

This problem runs because VS2010 came up with support for Silverlight 3 but not Silverlight 4 as Silverlight 4 had released after VS2010.

What you need is just setup "Microsoft Silverlight 4 Tools for Visual Studio 2010" about 35 MB without restarting your OS.

.. more.

Sunday, January 09, 2011

How to force undo checkout? #TFS

Sometimes you'd pop into cases where you find yourself in a situation where you have to force undo pending code changes of someone else (say a colleague who is no more around, or even temporarily) or your own pending changes if say your machine (along with your workspace on it).

Well, there a Visual Studio tool for that.. That's tf command-line utility, which you can look for in your VS directory under Common7\IDE..

Using tf has lots and lots of uses, here's a really LONG list of them. Note: there's 3 sub-lists for VS2005, 2008, 2010. But for our tiny problem here, we mainly have to options, I'm using here the most straight forward ones:

Undoing pending changes for a specific file:

That will need mainly main parameters to start with: The name/path of the file checkout, User name (of the user who did the checkout), and the Workspace in which the checkout was done (usually your machine name if you didn't create an new workspace).

You could have an issue with the third one (workspace name), so you might have to check the Workspaces command for more details, but generally a small command like the one below will do just ok in most cases:

tf workspaces /owner:UserName

Knowing the above you can easily undo the pending changes as below, note: parameters are in squiggly braces like {these}:

tf undo {file path} /workspace:{workspace};{username} /server:{TFS name/IP}

Of course the "/server" part can be removed if you're on the same server running TFS. An example with some data will look like:

tf undo $/myProject/myFile.cs /workspace:mySpace;FCIH\shady /server:FCIH_TFS

Deleting the whole workspace:

The other option is to delete the whole workspace, which in turn delete any related checkouts. A simple command for that could be:

tf workspace /delete {workspace};{username} /server:{TFS name/IP}

which with some example parameters might look like:

tf workspace /delete Shady-PC;FCIH\shady /server:


After a comment by Meligy, I think I needed to add this: Most of the above needs you to be logged in as an account with TFS admin privileges, check the exact required permissions for Undo, Workspace and Workspaces commands.

If you're not logged in as the appropriate account, you can append {/login:username, [password]} to provide the authorized username and password.

Meligy, also, mentioned another tool called TFS Sidekicks that can do similar stuff.

.. more.

Thursday, January 06, 2011

Silverlight: Image Carousel(3d Album)

Here is my "HelloWorld" Sliverlight application as in below picture for carousel by Sliverlight with source code as GNU GENERAL PUBLIC LICENSE.

The original code is here by Shine Draw then modified and enhanced by me.
The following are new features which I have added:
  1. Added Slider bar to view all items by scrolling.
  2. Linked the (Slider) with mouse wheel.
  3. Added a subject label related to every selected Item. 
  4. Added the ablilty to move next by selecting an arbitrary item (mouse click to the corresponding item only).
  5. Added a projection effect to every non-selected items.
  6. Added control panel to setup metadata on running time. 
Here is the source code with comments.
All what you need is Visual Studio 2008 or 2010 and Silverlight 3 or more (click here to get Sliverlight).
No need to setup Microsoft Expression Blend, all effects are mathematics behind.

.. more.