March 29, 2013

Install LAMP (Linux Apache MySQL PHP) & Drupal

PART 0 - DOWNLOAD DRUPAL
  1. Download the latest Drupal from here.
PART 1 - INSTALLING & CONFIGURE LAMP (Linux Apache MySQL PHP)
STEP 1 - Installing APACHE
  1. Open a terminal and type:
  2. sudo apt-get install apache2
  3. To make sure that Apache is installed open a web browser and type:
  4. http://localhost
  5. You should see something like this:
STEP 2 - Installing PHP
  1. Again open a terminal and type:
  2. sudo apt-get install php5 libapache2-mod-php5
  3. Now you must restart Apache:
  4. sudo /etc/init.d/apache2 restart
  5. To ensure that there are no issues with PHP run:
  6. sudo gedit /var/www/testphp.php
  7. A file called testphp.php will open.
  8. Copy and paste the following into the testphp.php
  9. 
    
  10. Save the file and exit
  11. Now open a web browser and type:
  12. http://localhost/testphp.php
  13. If it works then PHP is installed!
STEP 3 - Installing MySQL
  1. Open a terminal and type:
  2. sudo apt-get install mysql-server
  3. The above command will install MySQL
  4. Now comes the tricky part!
  5. Log in MySQL by typing:
  6. mysql -u root -p
  7. Now you need to set a password (Change yourpassword with the password you want. Do not remove ' '. Type your password between ' '.)
  8. SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
  9. For example:
  10. SET PASSWORD FOR 'root'@'localhost' = PASSWORD('12345');
  11. The next step is installing phpMyAdmin (A tool for editing your databases)
  12. sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
  13. Now you must edit the php.ini file in order to get PHP to work with MySQL
  14. gksudo gedit /etc/php5/apache2/php.ini
  15. Uncomment the following line by removing the semicolon (;)
  16. ;extension=mysql.so
  17. For example:
  18. extension=mysql.so
  19. Finally restart Apache:
  20. sudo /etc/init.d/apache2 restart
That's it your web server is up and running!
PART 2 - DRUPAL
  1. Open a terminal and type:
  2. sudo gedit /etc/apache2/apache2.conf
  3. apache2.conf will open
  4. In order for Drupal to functioning properly with Apache and PHP type the following at the the end of the file:
  5. AddType application/x-httpd-php.html
  6. Click Save
  7. Now it's time to create a Database
  8. Type the following and enter your password:
  9. mysql -u root -p
  10. To create a Database type:
  11. //Use whatever name you like instead of drupal
    CREATE DATABASE drupal;
  12. Now you need to create a user
  13. CREATE USER yourname@localhost;
  14. Finally define a password for the newly created user
  15. SET PASSWORD FOR yourname@localhost = PASSWORD('yourpassword');
  16. Now you need to grand permissions for the user
  17. GRANT ALL PRIVILEGES ON drupal.* TO yourname@localhost IDENTIFIED BY 'yourpassword'
  18. Go to the location that your Drupal was downloaded in PART 0 and unpack it
  19. Then copy the unpacked Drupal folder to /var/www/
  20. cp /home/user/Downloads/drupal-7.21 /var/www/
  21. Now head to /var/www/ and change directory to drupal
  22. cd drupal-7.21
  23. Change the permissions
  24. sudo chmod a+w sites/default
    cd sites/default
  25. Copy default.settings.php to settings.php
  26. cp default.settings.php settings.php
  27. Change the permissions
  28. sudo chmod a+w settings.php
  29. Finally create a directory named files
  30. sudo mkdir files
  31. and change permissions
  32. sudo chmod a+w files
  33. That's it!
  34. Now open a web browser and type:
  35. http://localhost/drupal-7.21
  36. Finally follow the on screen Drupal instructions to install Drupal

March 28, 2013

[HOW TO] Extract frames from video - Linux

To extract frames from a video do the following:

Install ffmpeg:

sudo apt-get install ffmpeg
Then decide how many frames you want to extract and do one of the following:

To extract each and every frame:

ffmpeg -i Video.mpg Pictures%d.jpg
For example:
ffmpeg -i /home/user/Desktop/Video.mpg Pictures%d.jpg
If you want to specify the number of frames to be extracted, the quality of the extracted frames or to start extracting from a particular point adjust your command by adding one of the following flags or all of them.
  • -r How many frames you want to be extracted per second (The default value is 25).
  • -f Defines the format.
  • Picture%3d.jpg %3d means that the names of the images will be like Picture001, Picture002 and so on. You can use any format you like.
  • -s You can define the image size.
  • -t You can set the duration of the extraction.
  • -vframes You can define how many frames you want to be extracted.
  • -ss Defines the time you want the extraction to start.
For example:
To extract 1 frame every second type:
ffmpeg -i Video.mpg -r 1 Picture%3d.jpg
To extract the frames from the first 10 seconds of the video type:
ffmpeg -i Video.mpg -t 10 Picture%3d.jpg
To start the extraction at a given time type: (for example: 0:34:14)
ffmpeg -i Video.mpg -ss 0:34:14 Picture%3d.jpg
To define the number of frames you want to be extracted type: (for example 80)
ffmpeg -i Video.mpg -vframes 80 Picture%3d.jpg
You can also be more specific by using all of the above flags together:
ffmpeg -i Video.mpg -r 2 -t 150 Picture%3d.jpg
The above command will extract 2 frames per second for 150 seconds.

March 24, 2013

[HOW TO] Install Guitar Pro - Linux Ubuntu 64bit

  1. Download the latest .deb from Guitar Pro's website.
  2. install ia32-libs by typing:
  3. sudo apt-get install ia32-libs
  4. Now you need to edit the .deb file to remove the gksu dependency.
    1. To do that you must create a script first.
      • To create the script open a terminal and type:
        vi debscript
      • This will create a new file named debscript.
      • debscript is just an example name. You can use whatever name you want.
      • Now type or copy/paste the following:
        #!/bin/bash
        
        if [[ -z "$1" ]]; then
          echo "Syntax: $0 debfile"
          exit 1
        fi
        
        DEBFILE="$1"
        TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1
        OUTPUT=`basename "$DEBFILE" .deb`.modfied.deb
        
        if [[ -e "$OUTPUT" ]]; then
          echo "$OUTPUT exists."
          rm -r "$TMPDIR"
          exit 1
        fi
        
        dpkg-deb -x "$DEBFILE" "$TMPDIR"
        dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN
        
        if [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then
          echo DEBIAN/control not found.
        
          rm -r "$TMPDIR"
          exit 1
        fi
        
        CONTROL="$TMPDIR"/DEBIAN/control
        
        MOD=`stat -c "%y" "$CONTROL"`
        vi "$CONTROL"
        
        if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then
          echo Not modfied.
        else
          echo Building new deb...
          dpkg -b "$TMPDIR" "$OUTPUT"
        fi
        
        rm -r "$TMPDIR"
      • Press Esc.
      • Now to save the file
        type :w
      • Finally to quit vi
        type :q
    2. Now its time to edit the .deb file.
    3. Move the script in the same folder as the Guitar Pro .deb file.
    4. You now need to make debscript executable.
    5. Open a terminal and type:
    6. chmod +x debscript
    7. Then type:
    8. debscript gp6-full-linux-r11201.deb
    9. Now delete gksu.
    10. To delete gksu move next to gksu and press x.
    11. To save the edited .deb file hit Esc and
    12. type :w
    13. Exit by
    14. typing :q
    15. A new file named gp6-full-linux-r11201.modfied.deb will be created.
    16. Do not close the terminal until the new .deb file is created.
  5. You can now install Guitar Pro 6.
  6. In the same terminal or in a new one type:
  7. sudo dpkg -i gp6-full-linux-r11201.modfied.deb
  8. That's it! Enjoy!

[HOW TO] Create a script - Linux

This tutorial will show you how to create a script in Linux. In this tutorial I am going to use vi. You can also use gedit or anything else if you want.
Open a terminal and type:
vi (name of the script)
For example "testscript". This will create a script named testscrip.
vi testscript
vi editor will open.
Now its time to start writing your script. Below is an example of a basic script that launches Firefox:
#!/bin/sh
echo “welcome”
firefox
Save your script by pressing Esc. Then:
Type :w
Quit vi by:
Typing :q 
Next type the command below to make the script executable:
chmod +x testscript
Finally to run the script type:
./testscript
That's it! Enjoy creating scripts!

March 22, 2013

[HOW TO] Install Cinnamon - Ubuntu/Fedora


To install the latest Cinnamon on your Linux Ubuntu/Fedora do the following:
  • Ubuntu
    • 12.04/12.10
Open the terminal and add the repository
sudo add-apt-repository ppa:gwendal-lebihan-dev/cinnamon-stable
Update the database
sudo apt-get update
Install Cinnamon
sudo apt-get install cinnamon
After the installation is complete log out and choose cinnamon.
    • 11.04/11.10
Open the terminal and add the repository
sudo add-apt-repository ppa:merlwiz79/cinnamon-ppa
Update the database
sudo apt-get update
Install Cinnamon
sudo apt-get install cinnamon
After the installation is complete log out and choose cinnamon.
  • Fedora
Before the cinnamon installation check if your system is up-to-date
Open the terminal
Once inside the terminal login as root
su --login
Check for updates
yum updates
Install Cinnamon
yum install cinnamon
After the installation is complete log out and choose cinnamon by clicking Session.

[HOW TO] Access files/folders with spaces - Linux

If you want to access a folder that has a name with a space for example the folder named New Folder do one of the following:
// If it's the only file/folder that starts with Ne

$ cd Ne*

// Or by using \ after each space

$ cd New\ Folder

// By using " "

$ cd "New Folder"

// By pressing Tab

$ cd (press tab)