Lost within

Alaa Abdelhaq Blog

Archive for the ‘Web Development’ Category

Send me an angel investor

In my struggle of finding an angel investor (ملاك مستثمر) to invest in one of my websites, the only angel I was able to find was the death angel :D

So I was listening to Scorpions song “Send me an angel” and the following lyrics came into my mind, some will find it stupid and maybe funny but who cares :D

Hope you will like it, I call it “Send me an angel investor”

The lyrics:

Business man said, “Just walk this way
To the dawn of the wealth
The money will blow into your face
As the VCs pass you by”

“Check your email from your laptop
It’s the call of business plan
Close your Facebook and you will find
Time to focus on your plan”

Here I am
Will you send me an angel investor?
Here I am
In the land of the broken dreams

Business man said, “Just find your place
In the MENA or KSA
Seek the investors along the way
Just beware of phony gray heads”

Here I am
Will you send me an angel investor?
Here I am
in the land of the broken dreams

Business man said, “Just upload your website
And reach out for the hits
Find the door to the investors land
Just believe in your plans”

Here I am
Will you send me an angel investor?
Here I am
in the land of the broken dreams

let say you have a group of radio buttons sharing the same name attribute for sure, and upon submit or some event you want to check if one of these radio buttons was checked or not.
you can do this simply by the following code.

$(document).ready(function(){
  $('#submit_button').click(function() {
    if (!$("input[@name='name']:checked").val()) {
       alert('Nothing is checked!');
        return false;
    }
    else {
      alert('One of the radio buttons is checked!');
    }
  });
});

hope this will help you :)

How to manipulate mysql datetime using php

You are having hard time with mysql datetime format? I wont blame you :)
I hope this short example will help you.

let say in your mysql database you are saving time on the datetime format
like this “2009-01-20 02:11:05″.

you need to pull it and add some days or time intervals and print it in a different format, thats easy do the following

1- In your query pulling the time, pull it this way:

UNIX_TIMESTAMP(time) AS time

this will covert it into unix timestamp, which will make it easier for you to manipulate it with php functions.

2- Add your time interval, let say we need to add 15 days.

$unix_timestamp_from_database = 1232410265;
$time_from_db = $unix_timestamp_from_database;
$new_time = $time_from_db + (15 * 86400);

86400seconds equals one day.
In unix timestamp we manipulate time by seconds.
so if you want to add an hour you add it like by (60 * 60)
which equals 3600 seconds.

3- Then you format it as you desire:

$new_time_format = date("d-M-Y", $new_time);
echo $new_time_format;

hope it will help you :)

How your site looks in other browsers??

Sometimes working on web design may not be as easy as you think.
Specially when it comes to browsers compatibility.
things get tricky and difficult with the lack of HTML CSS and Javascript debuggers like firebug on
other browsers specially IE!
plus you are working under your favorite OS, so it gets harder to test your work on different browsers and different platforms?
By surfing the web I came by chance with this incredible website LINK
How it helps you?
simply click on the link place your website address
then check the browsers you want to check under different platforms.
next you can put some rules like the preferred resolution you want the test to be ran under.
then you submit it.
Next the website will show you exactly how your website will look on the selected browsers.
it will get you results as a png images, yes images!
maybe some people wont like the service, for me if I was able to check exactly how my website looks on each browser that would be great, and maybe helps me to decrease bounce rate :)

give it a try :)

Javascript and browsers

Building websites with a lot of client script like javascript may be a nightmare sometimes!
there is a big possibility that the client disabled the javascript by mistake or does not know whats javascript is!
so am wondering when browsers like firefox IE or Opera will make javascript support as an mandatory thing, and the end-user will never ever be able to disable it?
or what could replace javascript??

Ubuntu – Enable mod_rewrite in Apache server

At first I should define, what is mod_rewrite?
mod_rewrite is a part of Apache server that can rewrite requested urls on the fly.

To enable mod_rewrite in Ubuntu, you just need to write this command in terminal

sudo a2enmod rewrite

ffmpeg

This post will help you to install ffmpeg and compile it with some important codecs.

First, get your dependencies:

sudo apt-get build-dep ffmpeg
sudo apt-get install liblame-dev libfaad2-dev 
libfaac-dev libxvidcore4-dev liba52-0.7.4 
liba52-0.7.4-dev libx264-dev checkinstall 
build-essential subversion

Next, grab the ffmpeg source:

svn checkout -r 8998 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

If you’re feeling adventurous, you can try the very latest code by omitting the -r 8998 part of that line. Revision 8998 is the latest at the time of writing, and worked for me.

Now you can configure and build ffmpeg. This takes a little while:

cd ffmpeg
./configure --enable-gpl --enable-pp --enable-libvorbis 
--enable-libogg --enable-liba52 --enable-libdts 
--enable-dc1394 --enable-libgsm --disable-debug 
--enable-libmp3lame --enable-libfaad --enable-libfaac 
--enable-xvid --enable-pthreads --enable-x264
make

Finally, install it.

checkinstall

gives you the option to edit some parameters: I set the name to ffmpeg and the version to 3:0.svn20070511

sudo checkinstall

To get the user’s IP use the following script:

<?php
GetHostByName($REMOTE_ADDR);
?>

To get the user’s computer name use the following script:

<?php
gethostbyaddr($_SERVER['REMOTE_ADDR']);
?>