Getting started with Laravel 4 on CentOS ... First Helloworld app with Laravel-4

Install PHP 5.4>:
At least PHP 5.4 is required to install laravel 4.
Uninstall old php versions php 5.3 <=
  1. yum remove php*

Install php 5.4:

  1. rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
  2. yum install php54w
Install php mcrypt extension:

  1. yum install php54w-mcrypt

Install PHP Data Objects (PDO) extension :

  1. yum install php54w-pdo

Install composer (Composer is a dependency manager for PHP.Something like Maven in Java.):

  1. cd /usr/local/bin/
  2. curl -sS https://getcomposer.org/installer | php
  3. mv composer.phar composer
  4. composer self-update

Run the following command to create your first laravel helloworld project:

  1. composer create-project laravel/laravel hello-laravel-4 --prefer-dist

This command will download and install a fresh copy of Laravel in a new hello-laravel-4 folder within your current directory.
Next run the composer install command in the root of your manually created project directory. 
  1. cd hello-laravel-4
  2. composer install
This command will download and install the framework's dependencies.
 Now give execute access to PROJECT_ROOT/app/ dir:


  1. chmod -R 777 app/

Make sure your current directory contains a file named artisan.
Now run the following command to run your first helloworld app:

  1. php artisan serve

Now browse to http://localhost:8000/ to see the output.You should see a screen saying 
"You have arrived." :)

Running web application & prerender node server on same machine

While using prerender server for making javascript heavy sites crawlable / google searchable we can map our site url to localhost:port as prerender may not work with exact urls.For setting up prerender server follow the instructions at :
http://mohiplanet.blogspot.com/2014/07/installconfigure-and-run-html-pre.html

Have a look at util.js :
https://github.com/prerender/prerender/blob/master/lib/util.js
on line 32 - line 35.You will see something like this:
  1. var newUrl = url.format(parts);
  2. if(newUrl[0] === '/') newUrl = newUrl.substr(1);
  3. return newUrl;
  4. };
Add your mapping url code there.
Something like:
  1. var newUrl = url.format(parts);
  2. if(newUrl[0] === '/') newUrl = newUrl.substr(1);
  3. newUrl=mapurl(newUrl);
  4. return newUrl;
  5. };

map url function:
  1. function mapurl(turl){
  2. var url=turl;
  3. if(url.indexOf('www.mysite.com') > -1){
  4. url=url.replace('www.mysite.com','localhost:8080');
  5. return url+'';
  6. }
  7. if(url.indexOf('mysite.com') > -1){
  8. url=url.replace('mysite.com','localhost:8080');
  9. return url+'';
  10. }
  11. return url+'';
  12. }


This will work if our app is hosted locally at http://localhost:8080/ and locally setup prerender port is 3000

xuggle-xuggler : java.lang.RuntimeException: error -1 decoding audio

Exception in thread "main" java.lang.RuntimeException: error -1 decoding audio
at com.xuggle.mediatool.MediaReader.decodeAudio(MediaReader.java:549)
at com.xuggle.mediatool.MediaReader.readPacket(MediaReader.java:469)
at com.company.toolset.crawler.common.video.DecodeAndCaptureFrames.<init>(DecodeAndCaptureFrames.java:89)
at com.company.toolset.crawler.common.video.DecodeAndCaptureFrames.main(DecodeAndCaptureFrames.java:55)

may occur if accidenly an attempt is made to take screenshot during a certain time that exceeds(>) video length.Like one can get this by trying to take screenshot at 15th second of the video but the video duration is <= 15 seconds.

Java : human readable date time difference

Using Apache Commons Duration Format Utils date-time differences can be formatted pretty easily. It formats just like SimpleDateFormatter :

  1. import org.apache.commons.lang.time.DurationFormatUtils;
  2. //...
  1. Date startTime = new Date();
  2. //...
  3. //... lengthy jobs
  4. //...
  5. Date endTime = new Date();
  6. long diff = endTime.getTime() - startTime.getTime();
  7. String hrDateText = DurationFormatUtils.formatDuration(diff, "d 'day(s)' H 'hour(s)' m 'minute(s)' s 'second(s)' ");
  8. System.out.println("Duration : " + hrDateText);

Sample Output the code:
0 days(s) 0 hour(s) 0 minute(s) 1 second(s)

Maven dependency:

  1. <dependency>
  2.     <groupId>org.apache.commons</groupId>
  3.     <artifactId>commons-lang3</artifactId>
  4.     <version>3.3.2</version>
  5. </dependency>