Ahmed El.Hussaini's Blog

RSS

Recruitment is a relationship, not a process!

I believe that recruitment should be fun a fun, knowledgeable, and easy relationship. Yes it’s a relationship, it’s not a process, someone agreeing to join a company is no different than starting a new relationship.

Before social networks, this was a very hard and tedious process, actually it’s still is a hard and tedious process, and one of the main reasons for that in my opinion is that companies and recruiters still view social networks as just another form of advertising their jobs.

In reality, it’s the complete opposite, social networks is the best place for companies and recruiters to build a multiple channels of communication with potential candidates.

How to Enable Multiple Profiles in Google Chrome

Google chrome by default comes with only one profile which is called “Default”, but no profile manager whatsoever. Now this might be acceptable for some users, but for developers, this is a whole new story. Developers new multiple profiles to be able to test multiple applications and extensions in different environments (ex: development, test, and production). What I’m about to show you is probably available through 3rd party extensions, but since the steps are so easy, there is no need to search for such extensions.

Note: The steps here were tested only on Ubuntu 10.10, but they should work perfectly on other OS

So, let’s get started, change to the folder where all Chrome’s cache and profiles are kept is located at ~/.config/google-chrome

$ cd ~/.config/google-chrome

Create a new directory to hold your new profile’s data, we’ll call it foobar, but you should choose a more meaningful name

$ mkdir foobar

Now start Chrome using the new profile directory

/opt/google/chrome/chrome --user-data-dir=/home/sandboxws/.config/google-chrome/foobar

Note that sandboxws is the name of my home directory, this should be changed to match your home directory name

Ruby Reflection Part 1

After many years developing using Java and PHP, moving to Ruby got me to think how Ruby handles reflection. And like anything that is Ruby, it’s different than what any C++ based language handles any task, but it’s also fun and new, which is pretty much what Ruby methodology is all about. Anyway I’m planning to write a series of articles that covers this topic deeply. In this article I’ll introduce basic reflection operations. Just the basic stuff like retreiving a list of available methods for an object or a class, invoking methods dynamically, and so on.

Assume that we have the following class

Now lets inspect the available public instance methods [ruby] methods = Person.public_instance_methods [/ruby]

The above variable holds an array the contains all public instance methods available for the Person module either defined in the class, inhertied from super classes, or included from modules. Lets inspect the variable a little more [ruby] puts methods.length # in my case prints 52 puts methods[0] # prints nil? [/ruby]

What about our full_name method, we can use the include? method to test [ruby] puts methods.include?(:full_name) # prints true [/ruby]

The question that raises it self now, this array of methods, what is the type of the elements in this array? Only one way to find out [ruby] puts methods[0].class # prints symbol [/ruby]

That’s odd, what we can do with a symbol, we need an object that represents the method so we can call it dynamically, and a symbol is no good. Well in Ruby as you know, there are many ways to accomplish a task, here is one way to invoke or call one of the methods in the methods’ array [ruby] puts p.send(methods[0]) # prints false [/ruby]

The send method available for all ruby objects is one of the ways to invoke methods dynamically. Well that’s it for this tutorial, see you all in part 2.

How to Install Oracle EBS R12 on Redhat Enterprise Linux 5.5

Before we begin the wild ride, there a few modifications that needs to be done to the system, a few packages need to be installed. I’ll assume that you have searched for quite a while and maybe you even tried to install the damn thing and ran into errors, so I’ll get right into the process. Here what we’re going to do:

  1. Install Development Tools
  2. Install required packages
  3. Modify the System Configuration and Kernel (don’t panic)
  4. Create Required Users
  5. Install Oracle Apps

Install Development Tools

[bash] yum groupinstall “Development Tools” [/bash]

Install required packages

You can either install the following packages using yum or download this file which include all the files.

  1. openmotif21-2.1.30-11.EL5.i386.rpm
  2. xorg-x11-libs-compat-6.8.2-1.EL.33.0.1.i386.rpm
  3. elfutils-libelf-devel-0.125
  4. elfutils-libelf-devel-static-0.125
  5. libaio-devel-0.3.106
  6. unixODBC-2.2.11
  7. unixODBC-devel-2.2.11
Note: You need to make the following modifications after installing openmotif [php] $ unlink /usr/lib/libXtst.so.6 $ ln -s /usr/X11R6/lib/libXtst.so.6.1 /usr/lib/libXtst.so.6 [/php]

Modify the System Configuration and Kernel

Open /etc/sysctl.conf as root

[php] $ su - root $ vi /etc/sysctl.conf [/php]

then add the following lines at the end of the file

[bash]

Oracle EBS R12.1.1 Kernel Settings

kernel.shmall = 2097152 kernel.shmmax = 4294967295 kernel.shmmni = 4096 kernel.sem = 256 32000 100 142 fs.file-max = 327679 net.ipv4.ip_local_port_range = 10000 65000 net.core.rmem_default=262144 net.core.rmem_max=262144 net.core.wmem_default=262144 net.core.wmem_max=4194304 [/bash]

Now lets apply the new settings

[php] $ /sbin/sysctl –p [/php]

Add the following lines to the /etc/security/limits.conf file:

[php] * hard nofile 65535

  • soft nofile 4096

  • hard nproc 16384

  • soft nproc 2047 [/php]

Add the following lines to the /etc/resolv.conf file:

[php] options attempts:5 options timeout:15 [/php]

Now we need to restart the system so the above modifications gets applied.

Create Required Users

We’ll need to create one group dba and two users, oracle and applmgr. The oracle users will be the owner of the database tier folders and services, while the applmgr user will be the owner of the applications tier.

You can either create the group and the users using GUI or use the following commands:

[php] $ su - root $ groupadd dba $ useradd –g dba –d /home/oracle oracle $ useradd –g dba –d /home/applmgr applmgr [/php]

Install Oracle Apps

Before we start the installation we need first to create the installation directory. We will name the directory ebs and create at root /.

[php] $ su - root $ cd / $ mkdir ebs $ chown oracle:dba ebs $ chmod 777 ebs [/php]

Now we can start the rapid install wizard. I’ll not be using a staging area but the following applies to both installing from a staging area or from Oracle’s EBS media pack DVDs. I’ll assume that the DVD-Rom is mounted at /media/cdrom.

[php] // run the following as the oracle user, not root $ cd /media/cdrom/Disk/rapidwiz $ ./rapidwiz [/php]

That’s it, below are some screen shots of the installation using a fresh database. Have fun.

[caption id=”attachment_484” align=”aligncenter” width=”595” caption=”Installation Screen 01”]Installation Screen 01[/caption]

[caption id=”attachment_485” align=”aligncenter” width=”587” caption=”Installation Screen 02”]Installation Screen 02[/caption]

[caption id=”attachment_486” align=”aligncenter” width=”590” caption=”Installation Screen 03”]Installation Screen 03[/caption]

[caption id=”attachment_487” align=”aligncenter” width=”589” caption=”Installation Screen 04”]Installation Screen 04[/caption]

[caption id=”attachment_488” align=”aligncenter” width=”588” caption=”Installation Screen 05”]Installation Screen 05[/caption]

[caption id=”attachment_489” align=”aligncenter” width=”592” caption=”Installation Screen 06”]Installation Screen 06[/caption]

[caption id=”attachment_490” align=”aligncenter” width=”589” caption=”Installation Screen 07”]Installation Screen 07[/caption]

[caption id=”attachment_491” align=”aligncenter” width=”590” caption=”Installation Screen 08”]Installation Screen 08[/caption]

[caption id=”attachment_492” align=”aligncenter” width=”591” caption=”Installation Screen 09”]Installation Screen 09[/caption]

[caption id=”attachment_493” align=”aligncenter” width=”591” caption=”Installation Screen 10”]Installation Screen 10[/caption]

[caption id=”attachment_494” align=”aligncenter” width=”592” caption=”Installation Screen 11”]Installation Screen 11[/caption]

[caption id=”attachment_495” align=”aligncenter” width=”592” caption=”Installation Screen 12”]Installation Screen 12[/caption]

Firefox Extensions Every Developer Should Use

There are a lot of factors that makes Firefox the best browser currently available, but what makes Firefox really stands out is it support for extensions. A Firefox extension is an addon feature to the browser. There are thousands of available addons and in this post I’ll list some of the most used extensions by developers, in fact every developer should be using them.

Firebug

Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

inspect

As you can see in the above image Firebug adds the option “Inspect Element” which appears when you right click on any element in a web page. When clicked it will display the source code of the select item along with the css styles applied on that element (see below).

firebug_thumb

Web Developer

The Web Developer extension adds a menu and a toolbar to the browser with various web developer tools. It is designed for Firefox, Flock and Seamonkey, and will run on any platform that these browsers support including Windows, Mac OS X and Linux.

toolbar

Firecookie

Firecookie is a an extension for Firebug that makes possible to view and manage cookies in your browser. Apart from all the other cookie managers and viewers available as Firefox extensions, this one is made as an extension for Firebug, so web developer has the functionality accessible within familiar Firebug’s UI.

scr-overview-thumb

Live HTTP Headers

View HTTP headers of a page and while browsing.

live_http_headers

Page Speed

Page Speed is an open-source Firefox/Firebug Add-on. Webmasters and web developers can use Page Speed to evaluate the performance of their web pages and to get suggestions on how to improve them.

page_speed_thumb

Firefinder

Firefinder is an extension to Firebug (in Firefox) and offers the functionality to, in a quick way, find HTML elements matching chosen CSS selector(s) or XPath expression. It allows you to instantly test your CSS selectors in the page while seeing the content at the same time, and matching elements will be highlighted.

firefinder_thumb

jQuery Facebook Plugins

Facebook interface is as simple as it gets, and yet many of the elements that define this interface are very powerful and have proven to be very popular, so popular that jQuery developers created plugins to imitate those elements. In this post I’ll introduce you to two jQuery plugins that imitate facebook elements.

FCBKcomplete

Fancy facebook-like dynamic inputs with auto complete & pre added values. If you have any comments or requests, please post them and I will try to include all the requested features in the upcoming release.

fcbk_complete

Usage

[javascript] <script language=”JavaScript”> $(document).ready(function() { $.facebooklist(‘#elem’, ‘#list’, ‘#complete’,{url:’ajax-url’,cache:1}, height, {userfilter:1,casesensetive:0}); }); </script> [/javascript]

elem – input element id or object list – preadded elements complete – autocomplete div id or object ajax – object with two parametrs a) url to fetch json object b) use cache height – maximum number of element shown before scroll will apear filter – object with two parametrs a)case sensitive b) show/hide filtered items newel – show typed text like a element

Facebox

Facebox is a jQuery-based, Facebook-style lightbox which can display images, divs, or entire remote pages. It’s simple to use and easy on the eyes. Download the tarball, view the examples, then start enjoying the curves. facebox

How to Create Your First WordPress Plugin

WordPress is a very powerful and popular blogging platform. Once you start using it you will fall in love with it and sooner or later you’d want to create your own plugin to extend its functionality. So if you want to learn how to create your own WordPress plugin then you have come to the right place.

A WordPress plugin is simply one or more PHP files that adhere to certain rules and conventions. All you need to understand and complete this tutorial is a basic understanding of PHP programming.

Before we get started, let me explain what does the plugin we’re going to write will do. It simply displays the most commented 5 posts. Pretty simple and straight forward plugin which makes it an ideal example to explore the concept behind a WordPress plugin. We will call the plugin "WP Most Commented".

Plugin Folder Structure

WordPress doesn’t enforce a strict folder structure unlike most frameworks available, basically all you have to do is create a folder with the desired name (wp_most_commented in our case) under the plugins folder located in /wp-content/

Let’s create the plugin folder: folder_structure

In this folder we will create the plugin main PHP file, let’s call it "wp-most-commented.php".

Activating/Deactivating the Plugin

In order for WordPress to be able to activate/deactivate a plugin, we need to add PHP comments to the main file that tells WordPress about our plugin. Just copy and paste the following in the main file.

[php] <?php /* Plugin Name: WP Most Commented Plugin URI: http://sandbox-ws.com Description: Displays Most Commented Posts Version: 1.0 Author: Ahmed El.Hussaini Author URI: http://sandbox-ws.com */ ?> [/php]

As you can see that the above comments tells WordPress some meta data about the plugin like the plugin’s name, author, version, and so on. Those meta data are used to display some info about the plugin in the Admin panel of WordPress. After saving the main file goto WordPress’ admin panel, then click “Plugins” in the left side bar and you should find that our plugin was detected by WordPress.

plugins_page

Now you can activate and deactivate the plugin, although it will make no difference since we haven’t added any logic to the plugin main file.

Most Commented SQL Query

The MySQL query we will use to retrieve the most commented 5 posts is:

[sql] SELECT ID, post_title, comment_count FROM $wpdb->posts WHERE post_status = ‘publish’ and comment_count > 0 ORDER BY comment_count DESC LIMIT 5 [/sql]

You can test the query if you like but make sure to replace $wpdb->posts with your post’s table which is probably wp_posts.

Let’s add the function that will retrieve the most commented posts and displays them in a list. Just copy and paste the following to the plugin’s main file. [php] function wp_most_commented() { global $wpdb;

// select top most commented posts that have comment count &gt; 0 and are published
$sql = &quot;SELECT ID, post_title, comment_count FROM $wpdb-&gt;posts WHERE post_status = 'publish' and comment_count &gt; 0 ORDER BY comment_count DESC LIMIT 5&quot;;

// execute query
$posts = $wpdb-&gt;get_results($sql);

$html = '';

$html .= '&lt;ul&gt;';

foreach ($posts as $post) {

    $title = $post-&gt;post_title;

    $permalink = get_permalink($post-&gt;ID);

    $comment_count = $post-&gt;comment_count;

    $html .= '&lt;li&gt;';

    $html .= '&lt;a href=&quot;'.$permalink.'&quot; title=&quot;'.$title.'&quot;&gt;'.$title.'&lt;/a&gt;';

    $html .= '&lt;/li&gt;';

}

$html .= '&lt;/ul&gt;';

echo $html;

} [/php]

Testing the Plugin

Open the sidebar.php file in your current active theme and place the following snippet:

[php] <?php if(function_exists(‘wp_most_commented’)): ?> <div id=”most_commented”> <h3>Most Commented Posts</h3> <?php wp_most_commented() ?> </div> <?php endif; ?> [/php]

In your sidebar you should see something similar to the following screenshot:

plugin_sc

You’d probably want to customize the plugin main function to allow users to specify the number of posts to be displayed instead of the hard coded 5 limit, also you can add the ability to pass css classes, but I’ll this task to you.

Textmate Ruby on Rails 2 and CSS Bundles Imported into Intype

I’ve converted Textmate Ruby on Rails 2 and CSS Bundles Imported into Intype. I’ve tested both of them but if find any errors please notify me by leaving a commend or sending me an email at eng.ahmed.elhussaini@sandbox-ws.com

Use the links below to download the bundles:

Add Tomcat6 Support to Oracle Workshop for Weblogic 10gR3

First of all I’d like to thank myloon for this guide, all I did was translating it to English and included a direct link to the files needed.

Files Needed

After downloading the above file, extract it and copy the contents of the debugger folder to BEA_WORKSHOP_HOMEworkshop_10.3workshop4WPeclipsepluginscom.m7.nitrox.debugger_3.5.100.200807251738 and the contents of the serverdef folder to BEA_WORKSHOP_HOMEworkshop_10.3workshop4WPeclipsepluginscom.m7.nitrox.serverdef_3.5.100.200807251738

Make sure to backup any file before replacement.

Now open the cmd and change to the directory BEA_WORKSHOP_HOMEworkshop_10.3 and run the following command

[sourcecode language=”plain”] workshop.exe -clean [/sourcecode]

Now you can create dynamic web projects and add JSF 1.2 support to it with Apache Tomcat 6 as the run time server.

tomcat6_workshop_1

tomcat6_workshop_2

Introduction to Subversion

Before I started using subversion I used to make backup of my projects on regular basis and I can’t emphasis enough how this process was so boring and tedious, and every know and then I forget to make a backup or maybe replace files by accident. Actually I don’t know how I survived without using some kind of version control.

I’m assuming that because you’re reading this article then you probably have some general info about Subversion and maybe some other version control system like CVS. If not, then no problem, this article will still help you to get started using Subversion.

This article assumes that you’re running windows xp/vista, but the concept is the same and should work just fine on linux and mac os x systems as well, the only difference will be in the installation which you’ll find a lot of guides on the internet.

So lets get started, here is an overview of the guide:

  1. Downloading and Installing Subversion for Windows
  2. Creating a Repository
  3. Initializing Repository Structure
  4. Creating A New Project
  5. Checking Out a Project
  6. Adding Files to the Working Copy
  7. Committing Changes
Downloading Subversion for Windows

Subversion for windows can be downloaded from here. After downloading is finished, install the package. If it asks to restart, please do so. In order to verify that the installation was successful open the command line prompt and type svn then hit enter on the keyboard. If you get an output similar to the following then the installation was successful.

[sourcecode language=”plain”] Type ‘svn help’ for usage. [/sourcecode]

Creating a Repository

Now that we have subversion installed we want to create out first repository. Normally you’ll want to store the repository on the root of a drive, for example c:\repo, so lets use this path to store our repository.

To create a new repository we use the following command: [sourcecode language=”plain”] cd c:\ svnadmin create repo [/sourcecode]

Initializing Repository Structure

Defining the structure of your repository is completely up to you, there’s no restrictions in subversion that forces you to structure your repository in a certain way but most developers around the world uses the same structure as a global convention. This structure states that the repository will be divided into three main folders: Tags, Branches, and Trunk. I’ll not dive into why this structure was agreed upon between developers around the world. I’ll leave that for another article. Maybe that reason will make you visit my blog again :).

So lets create the repository initial structure. [sourcecode language=”plain”] svn mkdir file:///c:/repo/tags file:///c:/repo/trunk file:///c:/repo/branches -m “initialized repo structure” [/sourcecode]

The above command should result in the following output [sourcecode language=”plain”] Committed out revision 1. [/sourcecode]

Lets explain what happened now, first we used the svn command mkdir to create three folders and we also added a message using the parameter -m.

Most svn commands require adding a message while running the command. Those messages are helpful for viewing the history of your repository.

After running the mkdir command svn reports that the repository revision number is now (1). Each time you modify the repository whether by adding, modifying, or deleting, the revision number increase by one. So the repo revision number is an indication of the number of changes made to the repository since it was created.

Creating A New Project

Now that our repo structure is ready lets create our first version controlled project. For sake of testing we will name the project sandbox-ws. The sandbox-ws project will be added to the trunk folder. We will use the same mkdir command

[sourcecode language=”plain”] svn mkdir file:///c:/repo/trunk/sandbox-ws -m “created sandbox-ws project” [/sourcecode]

Checking Out a Project

The figure below outlines the basic operations done on a subversion repository. First we create the repository, then initialize the project structure, then create one or more projects in the repository, and last but not least, the developers checks out a project, modifies it, and then commits the changes back to the repository so other developers can update their working copies to reflect those changes.

If sandbox-ws was a PHP project for example, then the working copy will be in your web server’s documents root, htdocs for example if you’re using Apache. But for sake of testing we will create our working copy on the Desktop.

To check out the sandbox-ws project run the following command(NOTE: I assume that you’ve changes the cmd path to your desktop): [sourcecode language=”plain”] svn co file:///c:/repo/trunk/sandbox-ws [/sourcecode]

The above command should result in the following output [sourcecode language=”plain”] Checked out revision 1. [/sourcecode]

Now we move to the sandbox-ws project: [sourcecode language=”plain”] cd sandbox-ws [/sourcecode]

Adding Files to the Working Copy

Now that we have checked out the sandbox-ws project, it’s time to add some files to it. We will start with a simple php file, see below [sourcecode language=”plain”] // index.php <?php echo ‘Hello World!’ ?> [/sourcecode]

What we have done by adding a new file to the working copy is that we simply modified it. Lets see what subversion have to say now, run the following command from the sandbox-ws project folder [sourcecode language=”plain”] svn status [/sourcecode]

The above command output should be similar to the following: [sourcecode language=”plain”] ? index.php [/sourcecode]

The (?) next to the index.php file indicates that svn detected that the index.php status is unknown i.e. it’s new and has not been added to the working copy yet.

Most new developers to subversion get confused at this point, adding a file/folder to a working copy doesn’t mean that svn will also add the new file/folder to the repository as well, that is done by committing the file/folder to the repository as we will see in the next section.

Since svn doesn’t know the status of the index.php file, we should add it to the working copy, to do this run the following command: [sourcecode language=”plain”] svn add index.php [/sourcecode]

The output of the following command should be similar to the following: [sourcecode language=”plain”] A index.php [/sourcecode]

As you may have guessed, (A) means that the file has been added to the working copy, the next step would be committing the changes to the repository which would result in incrementing the repository revision number by one.

Committing Changes

After adding new the index.php file to the repository, we’ll want to commit it to the repository for other developers to be able to update their working copies and take advantage of our newly added file. To do so run the following command:

[sourcecode language=”plain”] svn ci -m “added index.php” [/sourcecode]

The output of the following command should be similar to the following: [sourcecode language=”plain”] Adding index.php Transmitting file data . Committed revision 2. [/sourcecode]

I think that the above doesn’t need any explanation, but the following does, run the following command: [sourcecode language=”plain”] svn info [/sourcecode]

The output of the following command should be similar to the following: [sourcecode language=”plain”] Path: . URL: file:///c:/repo/trunk/sandbox-ws Repository Root: file:///c:/repo Repository UUID: 50729929-acbb-d647-b00b-4f3555a6f6a3 Revision: 1 Node Kind: directory Schedule: normal Last Changed Author: Sandbox Last Changed Rev: 1 Last Changed Date: 2009-01-23 16:52:06 +0200 (Fri, 23 Jan 2009) [/sourcecode]

Of course some of the data displayed by the following command will differ between you and me but what is interesting about the command is that it indicates that the revision number of the working copy is less than the current revision number of the repository which is currently is 2. The reason of this is that after our commit the repository revision number as we have said increments by one but the our working copy is now out dated, we need to update it so the revision number of the working copy is similar to the repository. To do so run the following command: [sourcecode language=”plain”] svn update [/sourcecode]

The output of the following command should be similar to the following: [sourcecode language=”plain”] At revision 2. [/sourcecode]

I hope that this article successfully cleared what subversion is and how to start using it, in upcoming articles we will dive into more advanced topics.