Roshan Book

My Tech Notebook

Category Archives: TechTalk

Improve battery life and reduce overheating in Ubuntu/Debian

Feeling the heat from your laptop? Overheating and reduced battery life is common ‘phenomenon’ in Linux Mint. Jupiter was the best tool to reduce overheating in Linux desktop but since its development has stopped, you can use TLP or CPUFREQ instead of Jupiter. Install TLP using the following command:

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp tlp-rdw
sudo tlp start

No configuration required for using TLP. Install it and forget about it. If you want to use CPUFREQ, read this article how to use CPUFREQ to reduce overheating in Ubuntu.

Advertisements

Magento Product imgae not uploading

There are several speculations for the problem of product image not uploading in Magento. Solution that worked for me is by reducing the image size to 150kb. I have a shared hosting account and uploading file size limit is there.
In addition to that in your .htaccess file change “php_flag magic_quotes_gpc off” to php_flag magic_quotes_gpc ON

Installing Oracle JDK 7 On ubuntu

  • Download he 32bit or 64bit Linux “compressed binary file” – it has a “.tar.gz” file extension i.e. “[java-version]-i586.tar.gz” for 32bit and “[java-version]-x64.tar.gz” for 64bit
  • Uncompress it

    tar -xvf jdk-7u2-linux-i586.tar.gz (32bit)

    tar -xvf jdk-7u2-linux-x64.tar.gz (64bit)

JDK 7 package is extracted into ./jdk1.7.0_02 directory. – Now move the JDK 7 directory to /usr/lib

sudo mv ./jdk1.7.0_02 /usr/lib/jvm/jdk1.7.0

  • Now run
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
  • Run
sudo update-alternatives --config java

You will see output similar one below – choose the number of jdk1.7.0 – for example 3 in this list:

$sudo update-alternatives –config java There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ———————————————————— * 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode 3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode Press enter to keep the current choice[*], or type selection number: 3 update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode. 

Check the version of you new JDK 7 installation:

java -version

java version “1.7.0” Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode) 

Repeat the above for:

sudo update-alternatives --config javac sudo update-alternatives --config javaws

Howto Install Mysql Database Server with Phpmyadmin Frontend

Source:http://www.ubuntugeek.com/howto-install-mysql-database-server-with-phpmyadmin-frontend.html

MySQL is a widely used and fast SQL database server. It is a client/server implementation that consists of a server daemon (mysqld) and many different client programs/libraries.

Installing Mysql database in Ubuntu

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev

This will complete the installation of mysql server 5.0.45 in ubuntu gutsy.

Configuring Mysql in ubuntu

MySQL initially only allows connections from the localhost (127.0.0.1). We’ll need to remove that restriction if you wish to make it accessible to everyone on the internet. Open the file /etc/mysql/my.cnf

sudo gedit /etc/mysql/my.cnf

Find the line bind-address = 127.0.0.1 and comment it out

#bind-address = 127.0.0.1

You can check your configuration using the following command

#netstat -tap

Output Looks like below

tcp 0 0 *:mysql *:* LISTEN 4997/mysqld

MySQL comes with no root password as default. This is a huge security risk. You’ll need to set one. So that the local computer gets root access as well, you’ll need to set a password for that too. The local-machine-name is the name of the computer you’re working on. For more information see here

sudo mysqladmin -u root password your-new-password

sudo mysqladmin -h root@local-machine-name -u root -p password your-new-password

sudo /etc/init.d/mysql restart

Manage Mysql using Phpmyadmin

phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, manage keys on fields, manage privileges,export data into various formats and is available in 54 languages. GPL License information.

Install phpmyadmin in ubuntu

sudo aptitude install phpmyadmin

This will complete the installation.

Now you need to goto http://serverip/phpmyadmin/

Login using your mysql root as username and password


 

Easy CakePHP in Ubuntu

Source:http://php-developer.co.za/2009/12/08/easy-cakephp-in-ubuntu/

I’ve always setup a new CakePHP project by extracting the current stable build into a project directory and editing the core.php and database.php files manually. I usually then change to the /cake/console directory of the project and run php cake.php bake (having already installed the php-cli) to bake my code.

I know there are other ways to make this process simpler but its always just worked for me and I am usually to lazy/busy/unmotivated to try something new.

Today, however, I stumbled across a great way to set up CakePHP in Ubuntu so that building new projects is a simple matter of running one line from the command line and you are ensured of using the same stable “shell” version of Cake each time. It is also extremely easy to upgrade your “shell” version whenever you want. (It also makes baking even easier than the way I was doing it but that’s just an added bonus !)

(This may or may not also be possible in other Ubuntu like systems that have the same CakePHP repositories eg Mint, Debian etc)

1) Download and extract the latest stable version of CakePHP to a folder on your machine.

2) Install cakephp-scripts from the Ubuntu repositories

$ sudo apt-get install cakephp-scripts

This will install the current version of CakePHP in the Ubuntu repository, as well as the php-cli (command line interface) and setup the Cake console for easy use from the command line.

3) Copy the folders from the latest stable version to your system

Currently you have installed whatever version of cake was included in your version of Ubuntu’s repositories. If you are running an older version of Ubuntu or just want to run the very latest stable version, you need to update your Cake version by copying it from the extracted folder in step 1.

The “shell” version of CakePHP you installed in step 2 is located in /usr/share/php/cake. You will notice that the directory structure is slightly different from the extracted version, but a little common sense will enable you to see what needs to be copied to where (basically, from the extracted directory, copy the app directory and everything from inside the cake directory into the /usr/share/php/cake directory).

You can also upgrade your “shell” by downloading/extracting a newer stable version of CakePHP and repeating the above step.

Now baking with Cake becomes even easier.

Change to your web root (usually /var/www/ or wherever you usually develop your PHP applications) and run

$ cake bake projectname

where projectname is the name of a new project you want to create. You will be presented with the Cake console, which will set up your project folder and copy over all the code from the CakePHP “shell”. It will also set up a random Security Salt value, add some default CAKE_CORE_INCLUDE_PATHs and guide you through setting up your database configuration(s).

You can then change directory to your projectname directory and run

$ cake bake

to bake your Models, Views and Controllers.

Happy Baking…

UPDATE: I just noticed another nice side effect of this way of creating Cake projects, default app_controller.php, app_helper.php and app_model.php files are created in the project root folder.

FFmpeg cheat sheet

Source: http://www.webupd8.org/2009/08/ffmpeg-cheat-sheet-19-best-practices.html

ffmpeg is a multiplatform, open-source library for video and audio files. It is usualy available in your distribution repositories, so search for it and install it. For Ubuntu:

sudo apt-get install ffmpeg

Because certain codecs are not activated for FFmpeg in Ubuntu Jaunty, I suggest you download and install these ffmpeg fixed packages (unfortunately they are available for 32bit only).

Now that you have installed ffmpeg, you can start trying these commands which cover almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more:

Getting info from a video file

ffmpeg -i video.avi

Turn X images to a video sequence

ffmpeg -f image2 -i image%d.jpg video.mpg

This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.

Turn a video to X images

ffmpeg -i video.mpg image%d.jpg

This command will generate the files named image1.jpg, image2.jpg, …

The following image formats are also available : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.

Encode a video sequence for the iPpod/iPhone

ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4

Explanations :

* Source : source_video.avi
* Audio codec : aac
* Audio bitrate : 128kb/s
* Video codec : mpeg4
* Video bitrate : 1200kb/s
* Video size : 320px x 180px
* Generated video : final_video.mp4

Encode video for the PSP

ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :

* Source : source_video.avi
* Audio codec : aac
* Audio bitrate : 32kb/s
* Video codec : xvid
* Video bitrate : 1200kb/s
* Video size : 320px x 180px
* Generated video : final_video.mp4

Extracting sound from a video, and save it as Mp3

ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :

* Source video : source_video.avi
* Audio bitrate : 192kb/s
* output format : mp3
* Generated sound : sound.mp3

Convert a wav file to Mp3

ffmpeg -i source_song.wav -vn -ar 44100 -ac 2 -ab 192 -f mp3 final_song.mp3

Convert .avi video to .mpg

ffmpeg -i source_video.avi final_video.mpg

Convert .mpg to .avi

ffmpeg -i source_video.mpg final_video.avi

Convert .avi to animated gif (uncompressed)

ffmpeg -i source_video.avi animated_gif.gif

Mix a video with a sound file

ffmpeg -i song.wav -i source_video.avi final_video.mpg

Convert .avi to .flv

ffmpeg -i source_video.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv final_video.flv

Convert .avi to dv

ffmpeg -i source_video.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 final_video.dv

Or:

ffmpeg -i source_video.avi -target pal-dv final_video.dv

Convert .avi to mpeg for dvd players

ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 final_video.mpeg

Explanations :

* target pal-dvd : Output format
* ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
* aspect 16:9 : Widescreen

Compress .avi to divx

ffmpeg -i source_video.avi -s 320x240 -vcodec msmpeg4v2 final_video.avi

Compress Ogg Theora to Mpeg dvd

ffmpeg -i source_video.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 final_video.mpg

Compress .avi to SVCD mpeg2

NTSC format:

ffmpeg -i source_video.avi -target ntsc-svcd final_video.mpg

PAL format:

ffmpeg -i source_video.avi -target pal-svcd final_video.mpg

Compress .avi to VCD mpeg2

NTSC format:

ffmpeg -i source_video.avi -target ntsc-vcd final_video.mpg

PAL format:

ffmpeg -i source_video.avi -target pal-vcd final_video.mpg

Multi-pass encoding with ffmpeg

ffmpeg -i source_file -pass 2 -passlogfile ffmpeg2pass final_file-2

19 ffmpeg commands for all needs

 

Source:http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

ffmpeg is a multiplatform, open-source library for video and audio files. I have compiled 19 useful and amazing commands covering almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more.

 

 

Getting infos from a video file
ffmpeg -i video.avi
Turn X images to a video sequence
ffmpeg -f image2 -i image%d.jpg video.mpg

This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.

Turn a video to X images
ffmpeg -i video.mpg image%d.jpg

This command will generate the files named image1.jpg, image2.jpg, …

The following image formats are also availables : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.

Encode a video sequence for the iPpod/iPhone
ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4

Explanations :

  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 128kb/s
  • Video codec : mpeg4
  • Video bitrate : 1200kb/s
  • Video size : 320px par 180px
  • Generated video : final_video.mp4
Encode video for the PSP
ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :

  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 32kb/s
  • Video codec : xvid
  • Video bitrate : 1200kb/s
  • Video size : 320px par 180px
  • Generated video : final_video.mp4
Extracting sound from a video, and save it as Mp3
ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :

  • Source video : source_video.avi
  • Audio bitrate : 192kb/s
  • output format : mp3
  • Generated sound : sound.mp3
Convert a wav file to Mp3
ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3
Convert .avi video to .mpg
ffmpeg -i video_origine.avi video_finale.mpg
Convert .mpg to .avi
ffmpeg -i video_origine.mpg video_finale.avi
Convert .avi to animated gif(uncompressed)
ffmpeg -i video_origine.avi gif_anime.gif
Mix a video with a sound file
ffmpeg -i son.wav -i video_origine.avi video_finale.mpg
Convert .avi to .flv
ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv
Convert .avi to dv
ffmpeg -i video_origine.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 video_finale.dv

Or:

ffmpeg -i video_origine.avi -target pal-dv video_finale.dv
Convert .avi to mpeg for dvd players
ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg

Explanations :

  • target pal-dvd : Output format
  • ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
  • aspect 16:9 : Widescreen
Compress .avi to divx
ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi
Compress Ogg Theora to Mpeg dvd
ffmpeg -i film_sortie_cinelerra.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 film_terminée.mpg
Compress .avi to SVCD mpeg2

NTSC format:

ffmpeg -i video_origine.avi -target ntsc-svcd video_finale.mpg

PAL format:

ffmpeg -i video_origine.avi -target pal-svcd video_finale.mpg
Compress .avi to VCD mpeg2

NTSC format:

ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpg

PAL format:

ffmpeg -i video_origine.avi -target pal-vcd video_finale.mpg
Multi-pass encoding with ffmpeg
ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2

Download Youtube playlist videos on ubuntu

Source:http://www.ubuntubuzz.com/2011/10/how-to-download-all-videos-of-youtube.html

Imagine you have a playlist on YouTube that contains hundreds of videos in it and you want to download them, what will you do? Do you really want to download them one by one? I think that’s not a good idea. So, in this my first post, I’d like to show you how download all videos of YouTube playlist by simply type a few commands.

Applications used:
In order to getting this trick done, we have to install two applications called umph and youtube-dl. Umph is such an application that can parse YouTube feeds, it can parse playlists, favourite lists, and user upload lists. Youtube-dl is well-known command line tool for downloading YouTube videos by giving their video links.

Installing applications:
Fortunately, I’ve created a PPA contains those two applications. Simply type the following command to install them:

  • sudo add-apt-repository ppa:tldm217/tahutek.net
  • sudo apt-get update
  • sudo apt-get install umph youtube-dl

Usage instructions:

  • umph playlist_ID | youtube-dl -l -a –

You can get playlist_ID from playlist URL, for example, we will download all videos in PHPAcademy 200 JQuery Tutorials, see the picture below for more details.

Take a look at part marked with red box, you will get the weird phrase “PL46408891B63317A4”. By removing the “PL” characters, now you have the playlist ID: 46408891B63317A4. You’re ready to go:

  • umph 46408891B63317A4 | youtube-dl -l -a –

By default, umph will parse 25 videos. So, by executing the above command you will download the first video until 25th video. If you want to download all videos (200 videos) you must add an argumen “-m 200”.

  • umph -m 200 46408891B63317A4 | youtube-dl -l -a –

The tricky part is in umph command line arguments, please take look at this documentation for further information.

Install unity 5.0 in ubuntu 11.10

Source

Unity 5.0 installed in Ubuntu 11.10

Unity 5.0 hit Ubuntu 12.04 last night, but Ubuntu 11.10 users don’t need to miss out: Unity 5.0 is also available to install in Oneiric.

The packages are housed in the Unity Team Staging PPA. As this is not a ‘Stable releases’ PPA you should expect things to break after upgrading – as such only those who feel confident enough in handling any bugs should upgrade.

Two apps that won’t work under Unity 5.0 on Ubuntu 11.10 are the Marlin file browser and the stable release of Nuvola Player. Nor will many of the third-party Lenses and Scopes we’ve featured over the last month.

On to the good stuff. Unity 5.0 feels every bit as snappy under Ubuntu 11.10 as it does under 12.04. All of the options and features we’ve previously mentioned are available including the menu discovery fading, support for custom Dash colouring, force-quit action, and the Bfb ‘Lenses Quicklist’.

And yes – you can also disable the ‘Apps for Download’ section using Unity 5.0.

Install Unity 5.0 in Ubuntu 11.10

Add the following PPA to your Software Sources per these instructions:

  • ppa:unity-team/staging

After adding, pen the Update Manager, click ‘Check for Updates’, and proceed to install those you’re prompted to do.

This can also be achieved via the Terminal by running: –

  • sudo add-apt-repository ppa:unity-team/staging
  • sudo apt-get update && sudo apt-get dist-upgrade

All done? Restart your computer then begin enjoying Unity 5.0.

Downgrade Unity 5.0

“It’s all gone wrong! Halp!”

Open a terminal and enter the following commands: –

  • sudo apt-get install ppa-purge
  • sudo ppa-purge ppa:unity-team/staging

Make .sh file executable in linux

Source: http://www.digimantra.com/linux/how-to-make-shell-or-sh-bin-file-executable-in-ubuntu/

Somehow somwhere or in most of the stuff you need to make your shell file .sh or .bin file as executable. So to do that simple open the terminal and write the following command

chmod +x filename.sh

Well that gonna make your file executable which can be run from terminal by simple command

sudo ./filename.sh

There is another way of doing it through GUI, when you right click on the file and goto permissions tab then you get an option to make the file executable show as below :

executable shell How to make shell or sh , bin file executable in ubuntu

%d bloggers like this: