Thursday, October 15, 2009

Update online status with what you are listening

It may not seem as easy as it actually is, that's why I decided to share it.
Here it is a bash script that once executed updates pidgin's status with the name of the track running Rhythmbox music player


#!/bin/bash

while [ 1 ]
do
out=$( rhythmbox-client --no-start --print-playing)
#echo "I'm now listening to $out"
echo `/usr/bin/purple-remote "setstatus?status=available&message=Listening to $out"`
sleep 5
done

Monday, July 27, 2009

Automatically attach Windows formatted partitions on booting Ubuntu

As the title say, I consider in this how-to attach windows formatted partitions (FAT32, NTFS ..), it would be a very close procedures to attach other formats.
  1. Step One: Determine Which partition do you want to mount automatically.
    You have to know your target partition's Linux name, which differs from partitions' labels (those names given to partitions in Windows like "Sources", "Entertainment" ..).
    • Installing a suitable Disk-Scanner is a good idea to give you good information about your disk if you don't already know, I suggest gparted
      sudo apt-get gparted
    • Once installed, run it
      sudo gparted
      to see something like:


      now determine which partition you'd like to attach, and know its name (the column at the most left with heading "Partition"), I'll assume it is [my_part]
  2. Step Two: Determine Where to attach the target partition
    Lets assume you want attach the partition in the directory [my_dir], you have to create the directory
    sudo mkdir [my_dir]
  3. Step 3: Tell Ubuntu to attach Partition[Step 1] in Directory[Step 2]
    • Open the file /etc/fstab as root
      gksudo gedit /etc/fstab
    • Add the line
      [my_part] [my_dir] vfat auto,users,uid=1000,gid=100,utf8,dmask=027,fmask=1 37 0 0
      And dont forget to
      • Replace [my_part] with your partition (got from step 1)
      • Replace [my_dir] with your directory (got from step 2)
      • Replace "vfat" (which is for FAT32 partitions) with ntfs for NTFS partitions
    • Save and close /etc/fstab
  4. Step Four: Try attaching new entries in the /etc/fstab
  5. , by typing
    sudo mount -a

Enjoy ..

Friday, July 10, 2009

Open Command Prompt here

Opening the command prompt/shell interpreter in a specific is handy, and is very common to much many people.
I'll be talking in this post about how to do it in three different platforms.

First Windows Vista

Recently I shared an article that shows how to do it in Vista, which is not more difficult than just holding another button before hitting mouse's right one.

Second Debian based systems

It is also as simple here as installing any other program, here is a How - to which illustrate the operations.
At the end an additional option is added to the right click.

By clicking it, the terminal should be opened in the specified directory (in my case the desktop):


Third Windows XP

Operations here are a bit more tricky, I'll go in some details:
  1. Open Control Panel => Tools Menu => Folder Options => File Types Tab
  2. Select the "File folder" file type.
  3. Click the "Advanced" button.
  4. Click New (to add new action).
  5. Enter action's name, which will be some thing like "Open Command prompt here".
  6. Enter
    cmd.exe /k cd "%L"
    against the "Application used to perform action".
    Menu state should end up to something like:


  7. Press OK, OK.
Good, but it is not the end.
We need now to assure that folders behave normally, i.e. The default action of the folder file type is to be opened by windows explorer.

  1. Press Start => Run
  2. Write
    Regedt32.exe
    and hit enter.
  3. Open HKEY_CLASSES_ROOT/Directory/Shell
  4. From the Edit list choose the name (Default).
  5. Edit Menu => Modify



  6. Enter None and hit OK.


Right click any folder now and note the new action:



Thursday, February 19, 2009

Sample Project I

Not only because some colleagues advised me to do, but also because i found it a good idea to publish a sample project of each year and/or semester ..

I'll start by this one "Sorting simulator" was done in the second year with my partner Moustafa.

Why I'm starting with that project especially? Because it had many uniqueness properties not in many other projects.

  • It 's UI is inspired from Microsoft office 2007 ribbon.
  • It's UI is developed in SWT library and the program in Java.
  • We used the Hexapixel project.
  • We used the Nebula project (The pshelf on the left).
  • Time of working in this project was directly before the final exams by 2:3 weeks, we felt that we either won't finish the project or it would affect our exams badly, but thank God all are finished and all are over.
Project size:
  • Src directory contains 9 packages.
  • Model package contains 12 classes.
  • UI main class contains 1322 lines.





Notes about the project
  • Worth mentioning that the program can simulate as long list as the screen resolution permits it to do.
  • All actual sorting algorithms are actually finished normally without being disturbed by UI rendering instructinos. How do we simulate then? After each swap of a pair of elements, a new node is pushed to the simulation queue of this sorting type, which (the queue) is popped purely asynchronously by another thread.
  • Why we did that? To make the running time of the sorting algorithm accurate and not affected by simulation.
The source is available to anyone, just send me an email or comment demanding it.

Finally Here are you some screen-shots due to the bad quality video

  • The options panel:
  • The Results panel:

  • The input panel (ribbon oriented):
  • An overall running instance:

Update The project is now opensource.

The age of embedding Web-servers

The last period witnessed a "web-server-mania". Although I'll talk about running my pc as a server but this is not the reason why I say that.
About running my PC as a server it is not very sophisticated and can be done, just five systematic steps
  • Obtain static IP address.
  • Open port 80 (The port responsible for receiving HTTP requests).
    1. Adjust local firewall settings (to let HTTP requrests pass in).
    2. Do port forwarding (To open the port from the network and direct requests to the proper computer - To do it I downloaded the manual of my Router and searched for "port forwarding").
    3. Check the port is opened.
  • Install the server software on the pc; normally the word "Server" refers to two meanings the first: the Computer running as a server and the second: The software that translates clients' requests and reply by suitable responses (like what the browser does on the client side).
  • Register for a dynamic name service; that maps a certain DNS to your static IP address.
But the process even after its success is full of disadvantages, this article which summarizes the drawbacks of hosting on your own PC.


Back to the main thing that made me write this post ..
A Japanese Company called FreeBit had announced an iphone application that "server-ize" the iphone ...

 Yes once this application is installed on the iphone, all PCs can access it exactly like a web server.
Check this post for more information.

From the ability to "attach" the server on my PC to "embedding" it to a pocket device will change many concepts or at least make them more flexible and different from long age they were.

Monday, February 16, 2009

After a semester of being the class representative II

Welcome there ..
34 people had submitted their evaluation for me as their representative.
It has been about 20 hours since number was 34 and it is still 34, It seems that ther will no be any further submission.
Submission is now closed and here are results of the form.

  • Organization, Fairness and being helpful => Satisfying results.


  • Attendence => nearly 50:50 Good : Acceptable
  • Behaviour in problems => Satisfying
  • Decision in case of diffrences in opinion => Very satisfying (a bell shaped curve biased to [shifted towards] students :D).


Check this link to view a detailed version of the results.

I have some comments on the results

  • It is not true that these results refer to the person "Mohamed Abdelatif", it refers to the helpful community lead by Mohamed Abdelatif.
  • I had fallen in mistakes, because I'm a human, the skill (that I'm trying to gain) is decreasing mistakes results, apologize for them and avoid their occurance in the future.
  • I believe strongly in our class, I think we are the most helpful, active and connected class. I do not say that we are in our best state now, but we are better than all other class (at least in our college). That's why I'm enthusiastic and encourage to go on and keep being the representative for the 2nd semester too.
  • The rest of the week is opened for any one who likes to be the class representative, If you wish to be, just send us an email saying why you think that you will be a successful representative. And elections will go on Saturday 21.02.09 (The head of the second week of the semester)

Friday, February 13, 2009

After a semester of being the class representative I

Hi all, back to blogging.
The content of this post is somehow different from others, in spite of having a plethora of ideas and things that I would blog about.
But it is time to evaluate my performance as the class representative for the previous semester.

Note: Submission is now closed