Simple command to monitor directory changes on Mac

Sometimes you want to know if a certain App/code/IDE changed something on the disk, this little script / command may come in handy.

Install fswatch

install fswatch as a global command

The script

Only fswatch is not enough, here is the script that does the trick

Save as a script e.g. monitor.sh, then give it executable permission

Now run the script and supply the path as parameter, and you will start monitoring the directory

Enjoy!

Migrating to “Docker for Mac” from Toolbox

As Docker for Mac becomes available, it’s about time to ditch Docker Toolbox which requires a VM running in background. The migration is surprisingly easy. The Official doc recommend you to read this article “Docker for Mac vs. Docker Toolbox“, while I think it’s a pretty good read, I will simply tell you the steps to migrate if you just need the info. Continue reading

Docker commands to clean unused images

If you use docker for some time, there will be a lot of trash images, volumes that is not used by any containers. Here’s how to remove them. (warning: not reversible)

Remove dangling images

Remove dangling volumes

As seen from above commands, you may guess the nested command within the $(…) is used to list dangling images/volumes

List dangling images

List dangling volumes

Docker named volume explained

Named volume is a new feature since Docker 1.9, it allows you to manage persistent data more easily, and also the volume can be provided by other storage drivers such as Glusterfs instead of “just a directory on the host”. This new feature is particularly useful in production environment. (On the Dev side, I think we still need mounted volume) Continue reading

Install Jetty as a service on CentOS

It seems hard to find a complete step-by-step tutorial to install Jetty as a service (especially on CentOS), some of the tutorial online is somewhat outdated or does not work, so I will share what I’ve learnt. (painfully) Perhaps this tutorial will also be outdated at some point in the future, so I will state the current version of the software I use clearly. 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!