DB Dump using JAVA

package dbsync;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.CodeSource;
import javax.swing.JOptionPane;

* @author mr
public class dbsync {

* @param args the command line arguments
public static void main(String[] args) {
// TODO code application logic here
public static void Backupdbtosql() {
Process p = null;
String dbName = "dbname";
String dbUser = "root";
String dbPass = "password";
try {
CodeSource codeSource = dbsync.class.getProtectionDomain().getCodeSource();
File jarFile = new File(codeSource.getLocation().toURI().getPath());
String jarDir = jarFile.getParentFile().getPath();
String folderPath = jarDir + "/backup";
File f1 = new File(folderPath);
String savePath = f1.getAbsolutePath() + "/backup.sql";

Runtime runtime = Runtime.getRuntime();
//for linux or where mysql is global access
//p = runtime.exec("mysqldump -u"+dbUser+" -p"+dbPass+" –add-drop-database -B "+dbName+" -r " +savePath);
//for windows
p = runtime.exec("C:\\xampp\\mysql\\bin\\mysqldump.exe -u"+dbUser+" -p"+dbPass+" –add-drop-database -B "+dbName+" -r " +savePath);
//change the dbpass and dbname with your dbpass and dbname
int processComplete = p.waitFor();

if (processComplete == 0) {

System.out.println("Backup created successfully!");

} else {
System.out.println("Could not create the backup");

} catch (Exception e) {



Amazon Elastic Transcoder API – Laravel 5

Here is simple example to create job  to transcode mp3 file to HLS-Audio for Amazon Elastic Transcoder .

include the package in composer https://github.com/aws/aws-sdk-php-laravel

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use AWS;

class DexelUploadAudio extends Controller

public function __construct()

/* ... */

public function createjob()
$result = $ElasticTranscoder = AWS::createClient('ElasticTranscoder');
//pipeline id 1489836190416-r56a8n
//pipeline id refer it in transcoder page eg : https://ap-southeast-2.console.aws.amazon.com/elastictranscoder/home?region=ap-southeast-2#pipelines:
'Input' => [
//input file, which should exist in the bucket which is specified on pipeline
'Key' => 'sample.mp3',
'FrameRate' => 'auto',
'Resolution' => 'auto',
'AspectRatio' => 'auto',
'Interlaced' => 'auto',
'Container' => 'auto',
//output prefix file name
'Key' =>'string',
//System preset: HLS Audio - 64k

//Preset id refer it in transcoder page eg : https://ap-southeast-2.console.aws.amazon.com/elastictranscoder/home?region=ap-southeast-2#presets:

//seconds to split to file
//output folder name
public function jobStatus($jobId)
 $ElasticTranscoder = AWS::createClient('ElasticTranscoder');
 $result = $ElasticTranscoder->readJob(['Id' => $jobId]);

Crinsane/LaravelShoppingcart – Model not associating correctly or empty

I was having the exact same issue, using the most recent version 2.3.0.

Cart::add($product->uid, $product->name, $qty, $product->price)->associate('App\Models\Product');

In a foreach in my view, dd($product->model) returns null.

When try $this->cart->add($product->id, $product->title, 1, $product->price)->associate(‘App\Models\Product’);

works perfectly, primary key of product table has to placed in id. In my case I have id as primary key and uid as unique in product table.

Crinsane/LaravelShoppingcart content returns empty

More over I was struggling for a day on this. Then I found that because I put dd() in same request while cart add, the so session was not created for cart.

Try to first do the Cart::add() and no dd(). Then comment the Cart::add() and uncomment the dd()

Now you should see content, and a rowId. Now you should be able to delete it.

When you perform a dd() method, it will make the script die instantly, so the session is not written.

Install 2 version of PHP

Today I got again problem with PHP 7 and PHP 5 for mysql_connect which is deprecated in PHP 7.

So, this is the way to install both version , and use it when require .

sudo a2dismod [php old] ;
sudo a2enmod [php new] ;
sudo service apache2 restart

to update the php cli to use the specific version
sudo update-alternatives –set php /usr/bin/[php new]