#Linux

Convert GIF to MP4 in Ubuntu

To convert GIF file to MP4, we need implement two steps. The first step is convert git frames to png files. With this step, you need use ImageMagick. So you need make sure that your machine was installed ImaegMagick. The second step is convert the PNG file to MP4. We use AVCONV(ffmpeg) for this step. For further details, please take look to the steps below.

Convert GIF to MP4 in Ubuntu

Install ImageMagick (In Ubuntu)

Install AVCONV (ffmpeg)

Convert GIF frames to PNG images

Compress multi png images to video MP4

 

Install PHP Redis in Ubuntu

Redis is good solution to improve the performance of your system. You can use Redis as cache system or nosql DB.  I think that is is easy to use it but not easy to think how and where.

Step 1,  install redis, phpize

Test redis:

Install phpize

Step 2,  download phpredis source code from git

If you have not installed git yet, you can use this command line:

Step 3, compile and install phpredis,

Step 3, enable phpredis extension

Step 4, test

Writing a php script to test

Doing some quick and dirty benchmark

 

Good luck,

Writing shell script to deploy changed file via ftp

When you work with a cheap host, you just have FTP account to push your file to host. It will be terrible if you have to pull all changed file to host via FTP. Because you must answer many stupid question as “what files I was change?”, “Where files I was change?”, “What is ftp account?” …

0284ed8e-26be-11e4-a4aa-12313d044945-medium

So I think that it is better if you write a script to handle all task and help you answer all question. The way is posted the below will run well in linux environment.

Firstly, we need a script to upload file via FTP.  The script below requires CURL. You just need to change value of REMOTE_HOST, REMOTE_USER, REMOTE_PASSWD. It will work well.

After that, you write a script to list all file that needs to push to your FTP host. That script is similar to the script below.

With the script above, you need to provide 2 tag name, and script will check all file changes between them.  Finally, It calls fpt.sh script to push that files to FTP host.

You can see full source code in my Github: https://github.com/thanhson1085/git2ftp

[Linux] Convert SVG to PNG with background transparent

As you know, ImageMagicK is powerfully library on linux, that is used to convert or edit image.

Now, It is small command to help you convert all svg file in directory to png file with transparent background

Please make note that ImageMagick was installed on you linux.

With Ubuntu, you can use command below to install ImageMagick

It is simple.

Backup all databases of MYSQL

This is small tip to help you backup all database mysql by one command. And you also can use this command to backup database every night.

Using the command below:

Or using crontab to backup database every day:

 

[.vimrc] Add key map to comment out your code

Some times you want to add a comment to let who read your code will  understand easier. It is easy way to let every one who read your code know who and what time you did it

This tip will help do that. You just need to add the below code to [ .vimrc]. If you are using Ubuntu like me, the vimrc file will locate at / home/son.nguyen