WordPress command line interface (WP-CLI) guide

WP-CLI is a tool for managing your WordPress website via the command line. This may come in handy if you want to manage your WP instance without going through the web interface, or automate certain operations (change of Settings, perform backup etc.)

For example, here is a sequence of commands for installing a fresh copy of wordpress:

Continue reading

Check if two directory is identical with sha1sum

I want to share a little script I wrote that check if two directory is identical rather efficiently. First you may need to understand what sha1sum does.

The sha1sum tool

As the name may suggest, sha1sum compute the SHA-1 checksum of a particular file / text string.

You can see from the above example that sha1sum produce a hash of the content,  Continue reading

Weird random MySQL crash solution

After moving one of my node from Linode to DigitalOcean, I have experienced strange crash that appears to be random. After I reboot the process it works for about a week and fails suddenly.

Tools for checking the data in the database

After some research, I think it could be caused by the data inside the database, since I moved all data from the old VPS to the new node and now I’m using a newer version of MySQL (Actually MariaDB). It could run into some compatibility problem.

I strongly recommand you to backup the database before running any checks, upgrade, repairs and optimize actions. You can do so with the command:

This would check the status of all databases in the DB:

This would repair the databases and tables if anything go wrong:

This would upgrade the data if you have upgraded the Mysql version:

Good Luck!

Javascript simple floating and forever moving image

In this example, I will show you how to  animate an element and make it moving up and down infinitely. And I will do it without any explicit Loop construct (no for, while loops), with the help of the jQuery.

HTML:

Javascript

 How it works

In CSS, we set the element (the IMG) to absolute position so that it “float up” and detach from the normal layout. With this, we can move the image up and down by changing the “top” CSS property.

In Javascript, we define two functions, bannerMoveDown() and bannerMoveUp(). In each function, we use the jQuery animate() method to animate the IMG element, and after the each animation ends, we call the other one respectively, thus making it loop forever.

Finally, we call bannerMoveDown() to initiate the animation loop.

Fully functional example

Please checkout a fully function example here on JSFiddle: http://jsfiddle.net/madcoda/mN3n8/

Thanks for reading, Leave your comments down below if you encounter any problem!

Extremely slow installation of OSX 10.10 Yosemite

I was experiencing very lengthy install while upgrading my Mac mini 2011 from 10 find out here now.9 Mavericks to 10.10 Yosemite Developer Preview. The install process just appeared to hang at “5mins left”.

After some research, I believe that the cause of this is the MacTex library. If you have installed the MaxTex or any Tex library, you may experience this. The solution is just to wait, it may take a good couple of hours. Leave it overnight and it should be ready the next morning 🙂