Saturday, September 12, 2009

Creating a Backup

It's Saturday and I am here at the office creating a backup of our backup site. :) Done installing all the needed packages and have fully configured Drupal and had restored our modules and its database. Done configuring the radius server but have not tested it yet. Done testing the scripts that runs rsync...

It's now 5:42pm and time to jog. :)

Tuesday, September 1, 2009

Installing GIMP 2.6.6 in Ubuntu 8.04


Bookmark and Share


GIMP stands for GNU Image Manipulation Program. It is a free opensource alternative software for Adobe Photoshop or CorelDraw Photopaint. For Ubuntu 9.04 Jaunty the latest GIMP version is 2.6.7 but for Ubuntu 8.04 Hardy the latest suggested version is GIMP 2.6.6.

Here are the steps I have made to install GIMP 2.6.6 in Ubuntu 8.04:
  1. Choose your right version of GIMP from this site GetDeb
    Download the following debian packages here:
    • gimp

    • libgimp2.0

    • gimp-data

    • libbabl-0.0-0

    • libgegl-0.0-0

  2. Run a terminal application, go to Applications->Accessories->Terminal

  3. Install the packages in the following order to avoid dependency problems:
    $ sudo dpkg -i libbabl-0.0-0_0.0.22-1~getdeb1_i386.deb
    $ sudo dpkg -i libgegl-0.0-0_0.0.18-1~getdeb1_i386.deb
    $ sudo dpkg -i libgimp2.0_2.6.6-1~getdeb1_i386.deb
    $ sudo dpkg -i gimp-data_2.6.6-1~getdeb1_all.deb
    $ sudo dpkg -i gimp_2.6.6-1~getdeb1_i386.deb


So there you have it, you now have installed the GIMP application in you Ubuntu 8.04 Hardy Heron machine!

To run GIMP, go to Applications->Graphics->GIMP Image Editor.

Bookmark and Share

Friday, August 28, 2009

PHP Data Types


Bookmark and Share


Two Data Type Categories


  1. Scalar - contains only one value at a time

  2. Composite or Compound - array and objects

Four scalar types supported


  1. boolean - a value that can only either be true or false

  2. int - a signed numeric integer value

  3. float - a signed floating-point value

  4. string - a collection of binary data

Numeric Values


PHP recognizes two types of numbers


  1. integers
    - the int data type is used to represent signed integers

  2. floating-point values
    - also called float and sometimes double, are numbers that have a fractional component

Numeric Notations


  1. Decimal - standard decimal notation.
    ex. 10; -11; 1452
    Note: no thousand separator is needed or allowed

  2. Octal - identified by its leading zero (like the access permission of Unix)
    ex. 0666, 0100

  3. Hexadecimal
    ex. 0x123, 0XFF; -0x100

Note
The leading 0x prefix are both case-insensitive
Note
Octal numbers can easily confused with decimal numbers and can lead to some consequences

Two supported notations for Floating-point numbers


  1. Decimal - traditional decimal notation
    ex. 0.12; 1234.43; -.123

  2. Exponential - composed of a mantissa value followed by a case-insensitive letter E then an exponent value.
    ex. 2E7, 1.2e2

Note
  1. The precision and range of both types varies depending on the platform on which your scripts run
    ex. 64-bit platforms may be capable of representing a wider range of integer numbers than 32-bit platforms

  2. PHP doesn't tract overflows

  3. Float data type is not always capable of representing numbers in the way you expect it to.
    ex. echo (int)((0.1 + 0.7) * 10);
    this results to 7 instead of 8 since the result of this simple arithmetic expression is stored internally as 7.999999 instead of 8.0.

Strings


An ordered collection of binary data.
  • could be text, content of an image file, spreadsheed or even a music recording.

Booleans


  • can only contain either TRUE or FALSE.

  • used as basis for logical operations.

Note
When converting data to and from the Boolean type, several rules apply:
  1. When a numeric variable is converted to boolean data type, the value becomes false if the variable contains zero and true otherwise.

  2. When a string variable is converted to boolean data type, the value becomes false only when the variable is empty or if it contains a single character 0. Other values, it is converted to true.

  3. When a boolean variable is converted to a numeric or string, it becomes 1 if it is true, and 0 otherwise.


Bookmark and Share

Monday, August 24, 2009

Qoutes

"Prayer is not so much an act as it is an attitude - an attitude of dependency, dependency upon God." - Arthur W. Pink

"Expect great things from God. Attempt great things for God." - William Carey

"God does not judge the condition or quality of His church by how good the meetings are on Sunday morning, but by the character of the people on Monday morning." - Rick Joyner

"If you are faithful in the small things then big things are bound to come."

"Your state is not at all to be measured by the opposition that sin makes to you, but by the opposition you make to it."

“Keep your face in the sunshine and you can never see the shadow.”

"The true follower of Christ will not ask, "If I embrace this truth, what will it cost me?" - Rather he will say, "This is truth. God help me to walk in it, come what may!"" - A.W. Tozer

"Other books were given for our information, the Bible was given for our transformation."

"Faith for my deliverance is not faith in God. Faith means, whether I am visibly delivered or not, I will stick to my belief that God is love." - Oswald Chambers

"If I find in myself desires which nothing in this world can satisfy, the only logical explanation is that I was made for another world." - C.S. Lewis

Friday, August 14, 2009

Installing Apache Webserver and PHP5 in Ubuntu 8.04


Bookmark and Share


If you are following my posts in this blog, you have already seen how quick and easy it is to install additional packages in Ubuntu Linux. This time I'll show you how quick and easy it is to install Apache plus PHP in Ubuntu Linux.

  1. Click Applications->Accessories->Terminal

  2. Execute apt-get to download and install apache.
    $ sudo apt-get install apache2

  3. Again execute apt-get to download and install the php5 package.
    $ sudo apt-get install php5

  4. Lastly, install also the apache-php module.
    $ sudo apt-get install libapache2-mod-php5


You have now a webserver application installed in your Ubuntu Linux with PHP support. To start your Apache Webserver, run this command:
$ sudo /etc/init.d/apache2 restart
Verify that your Apache Webserver is running by checking your process table and show only the apache process:
$ ps ax | grep apache
14606 ? Ss 0:01 /usr/sbin/apache2 -k start
14610 ? S 0:00 /usr/sbin/apache2 -k start
14611 ? S 0:00 /usr/sbin/apache2 -k start
14612 ? S 0:00 /usr/sbin/apache2 -k start
14613 ? S 0:00 /usr/sbin/apache2 -k start
14614 ? S 0:00 /usr/sbin/apache2 -k start
14617 ? S 0:00 /usr/sbin/apache2 -k start
19769 pts/3 R+ 0:00 grep apache2

So there you have it. The Apache Webserver my test machine has fork itself six times that why you have all in all seven apache2 daemon running in order to serve several clients accessing your webserver all at the same time.

You can now try to open your default website using your favorite Internet Browser by typing:
http://localhost/
or
http:///
You should then see this page:

It works!



You can either change this site by editing the index.html file from your terminal located at /var/www using your favorite text editor (ex. vi) but you must first execute $ sudo su to change from an ordinary user to a super user. Or, you copy index.html file to your home directory and edit it from there using the Text Editor application in your desktop then copy the file back to /var/www/.

Bookmark and Share

Tuesday, August 11, 2009

Setting the right resolution for your Ubuntu 8.04 - Take 2


Bookmark and Share


My first post about solving the resolution problem of Ubuntu 8.04 in my computer did solved it for a little while but after my reboot the problem unfortunately came back. And by the way, my monitor, keyboard and mouse where not really directly connected into my Ubuntu machine, I am using a KVM switch since I don't use my Ubuntu box much often, I need to switch to my other machine running on a different Operating System.

I did another googling and found this solution:

  1. Open the terminal application and execute this command:
    $ sudo displayconfig-gtk
    Then provide your super user/root password.

  2. A Screen and Graphics Preferences window will pop-up.
    This time my problem was that I am using a ViewSonic LCD monitor but its model does not exist under its list of known ViewSonic model. What I did was, I set the Manufacturer to Generic then for the Model I set it to LCD Panel 1280x1024 then click OK.


And so thats it, it solved my problem. Hope this will solve your problem this time too.

Bookmark and Share

Friday, August 7, 2009

Anatomy of a PHP Script


Bookmark and Share

  • every PHP script is made up of statements.

  • each statement must be terminated with a semicolon.
    Example:

    some_instruction();
    $variable = 'value';



Note:

The last instruction before a closing tag does not require a semicolon, but it is advisable to always terminate an instruction with a semicolon.

Comments


Types of PHP comments:
  1.  // Single line comment

  2.  # Single line comment

  3.  /* Multi-line
    comment
    */

  4.  /**
    * API Documentation Example
    *
    * @param string $bar
    */
    function foo($bar) { }


Note:

Because the closing tag ?> will also end a comment, code like:
// Do not show this ?> or this 

will output:
or this

  • because the single line comment was terminated by ?>

  • Normally, a single line comment should be terminated with a newline (\r, \n or \r\n)



Whitespace


PHP is whitespace-insentive, except with this few limitations:
  1. You cannot have any whitesapce between <? and php

  2. You cannot break apart keywords
    ex. whi le, fo r, and funct ion

  3. You cannot break apart variable names and function names
    ex. $var name and function foo bar()


Code Block


A series of statements enclosed between two braces:
{
// some comments
f(); // a function call
}

  • used in creating groups of script lines that must all be executed under specific circumstances, such as a function call or a conditional statement.

  • code blocks can be nested.


Language Constructs


Elements that are built-into the language that follow specific rules.
Ex.

echo 10; // will output 10
print (10); // will also output 10
exit(); // terminate the script and either output a string or return a numeric status
die(); // an alias of exit()

Note:

echo is not a function and therefore does not have a return value

Bookmark and Share