Category Archives: MySQL

Backup or Export, Compress and upload mysql database to remote host

This is a handy command that i use to backup or export, compress and upload a mysql database to my remote host, very handy when you wanna upload your development database to the remote host after some changes.

/usr/mysql/bin/mysqldump --opt -uUsername -pPassword Databasename  | gzip -c | ssh -q user@remote-host.com 'cat > ~/Databasename.sql.gz'

Replace the following :

  • /usr/mysql/bin/mysqldump : The path for mysqldump on your localmachine
  • Username : Username for local mysql database.
  • Password : Password for local mysql database.
  • Databasename : Name of the database to export.
  • user@remote-host.com : the user and the IP or the address of the remote host.

the above command will upload the compressed database to your home directory on the remote host, to change the directoy, replace ~/ with the path you want.

Where I am ?

Looks like i have stopped blogging for a while. except from some trips and tricks I am keeping for my reference and public users.

well that’s not the case but since the team I am working with grew to around 22 developer, which i believe considered the biggest php team in one company in Egypt, things were going so crazy, lots of projects going, lots of new approaches, new integrations, and i have to be on top of it all the time.

meanwhile i am driven by four ideas for projects that i believe is gonna make a little difference in their business areas, I am prototyping each one of them, jumping from one to other, I launched one of them already which is www.lamptag.com, which is simply a crawler for LAMP resources and related technologies, after less than a month from launching he prototype, the feedback is good, the twitter page reached 100 follower. and the number of clicks on the links is good too.

Soon i will blog about the recent challenged i have encountered in the field, weather they are technically or management related.

Recruitment System – One of my projects

I wanted to post this since a while.

The recruitment system is one of the applications I built for cha-international while working there beside developing the Middle East & North Africa travel awards system, mail marketing system, and converting all their servers from windows to Linux.

In brief the system has the following features :

  • Backend :
  1. Managing countries, Nationalities, Languages, World Areas, System Announcements.
  2. Managing Education Levels, Industries, Titles, Departments, System Reply Messages, Candidate Status, Candidates Classifications, and Quotes.
  3. Testimonials section where the company can post its clients testimonials to be displayed in the frontend.
  4. Managing 2 types of resumes : Uploaded Attachments, and Detailed filled forms Resumes.
  5. Easy form for the data entry team to add the resumes from the backend.
  6. Searching for candidates, using simple forms like name, email or advanced one which contains name, different nationalities, different languages, age, sex, industry, title, keyword in resume, etc.
  7. Consultants area where they can post / close job posting, search  for candidates, export word version of resumes, add to their favorite list, recommend them to another consultant.
  8. Consultants also can comment on the resumes, change their availability status to be seen by other consultants, and communicate with the candidate through the reply messages and keep track of those sent messages.
  9. The system has a approval workflow engine, the admins have to check the resume to approve it first.
  10. The system has a privileges section where the administrator can create a new role, assign access to certain areas in the backend to certain role, and assign the roles to system users.
  11. Feedback system where the backend users can communicate with the administrator for support tickets, etc.
  12. Auditrail system where every action in the system is logged.
  • Frontend:
  1. Simple upload form where users can just upload their resume and simple details.
  2. Advanced profile form where users can fill in all the details, and add many attachments to their profiles.
  3. Listing, Simple search, advanced search for jobs, and applying to them.
  4. Clients area where they can request certain services.
  5. Featured profiles, where a certain profiles selected by the admins showed in frontend.

The project was completely built from scratch using Zend Framework, and right now it has more than 70,000 applicant in its database, and the system is as fast as you see in the videos, these demos were taken with 50,000 record in the database.

Please don’t give me any feedback on the design ;), I am just a developer.

Here is some videos describing the different features of the system, I will try to post a better quality ones later.

 

Change your Signature

[youtube=http://www.youtube.com/watch?v=KXMg4q43Vf0]

 


Search Resumes

[youtube=http://www.youtube.com/watch?v=UUCuQ3XZmHg]

 


Apply as New Candidate

[youtube=http://www.youtube.com/watch?v=UNMVIahQAeU]

 


Send Feedback to support

[youtube=http://www.youtube.com/watch?v=-QiwYphCi2k]

 


Consultant Functionality walk through

[youtube=http://www.youtube.com/watch?v=wU6MDYO-xsw]

 


Check who applied for your job

[youtube=http://www.youtube.com/watch?v=X7_ZNVjksKg]

 


Apply for Posted Job

[youtube=http://www.youtube.com/watch?v=B06xlZr8A-w]

 

How to Add & Subtract time code in Python

I have been developing some tools for the media production lately, i found a neat way to add or subtract certain amount of seconds to a given time code.

for example i have a video that starts from 12:45:05 and i want to add 59 seconds to it and use the new time.

from datetime import datetime
from datetime import timedelta

time = datetime(2009, 1, 1, 12, 45, 05, 0)

diff = timedelta(seconds = 59)

final_time = time + diff

Zend Certified Engineer

Hi mates,

finally i have got certified as Zend Certified Engineer on 10th of this month.

i have been decided to take the exam since a year, but was too busy to hold myself at home and revise the manual and prepare for the exam, but this month i said this is it.

The exam is very tricky with lots of confusing questions, it tests your ability of thinking and your real experience with php, web development, security and many other topics that some people will not expect to exist in PHP exam, it is  real benchmarking to your abilities.

I must say that preaparing for the exam has opened various topics for me to dig deep in, and it was a great experience.

And being one of the only 2 certified in Egypt is cool 😉

Build MySQL insert Query from Array that contains fields and values

The following function takes table name, and array where its keys are the table fields and it’s values are the values to insert in each field, it constructs the MySQL Query based on the input and executes it to insert the data.

function insertRow($table_name, $input_array){
	$link = mysql_connect(SERVER, USER, PASS);
	mysql_select_db(DATABASE, $link);
	$SQL = "INSERT INTO $table_name ";
	$fields = "(";
	$values = "(";
	foreach ($input_array as $k => $v) {
		$fields .= "`$k` ,";
		$values .= "'$v' ,";
	}
	$fields .="#";
	$values .="#";
	$fields = explode(",#", $fields);
	$fields = $fields[0];
	$values = explode(",#", $values);
	$values = $values[0];
	$fields .= ")";
	$values .= ")";
	$SQL .= $fields . " VALUES " . $values;
	mysql_query($SQL);
	mysql_close($link);
}

how to enable mod_rewrite in apache2.2 (debian/ubuntu)

Here i am going to describe how to enable mod_rewrite in apache2.2 -specaily for debian.

In default installion of apache2.2 on debian never enable mod_rewrite default. So you may need to enable .

First install the apache2.2 with this command :
debian user please use

Architectural principles

  1. Each project must have a clear customer and deliver a real benefit.
  2. Don’t Repeat Yourself (DRY). Life is too short to spend your time re-inventing things.
  3. Be as simple as possible. Just do what we need to do now.
  4. Be as open as possible. Assume that all services can be accessed from outside the BBC, by default.
  5. Start simple, then iterate. Build the smallest thing you could possibly need, deploy it, then build applications on top of it. Think building blocks, not monoliths.
  6. Don’t optimise prematurely. The service might not grow the way we think it will.
  7. Build to scale. Think stateless, think content delivery networks, think database resilience.
  8. Test often. So you know when you need to optimise. So you can maintain your code. So you can maintain your platform.
  9. Evolve. Teams, systems, support structures. The platform. These principles!
  10. Let it die. Be prepared to turn your system off, or change it unrecognisably.

The future is PHP

With PHP continuing to gain massive support from programmers looking to expand their programming horizon, new versions of the language are likely to be geared towards solidifying its position as opposed to revolutionising.


The job market is telling nothing but good news

When Perl 6 was being designed, many huge changes were brought that alienated a lot of developers – hopefully PHP will not go the same way.In the meantime, be happy that you have chosen such a popular language that is advancing so quickly – PHP is here to stay, and things are only going to get better.The simplicity of scripting language PHP means it will be more popular than Java for building Web-based applications, Internet browser pioneer Marc Andreessen predicted in a speech in Burlingame, California, at the Zend/PHP Conference.

Fix the MySQL PHP issue in Leopard (mysql.sock file)

This is a known issue in Leopard, basically the system is looking for the mysql.sock file in the wrong place. Just need to create a symlink and you should be in business:

sudo mkdir /var/mysql/
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock