Unzip a compressed sql backup and import it into a database

Figured I’d put a Bash script up here since I haven’t posted any before. This is a small function that I keep inside of my .bashrc file to unzip an sql database that has been exported into a .sql.gz file (or any other sort of compressed file extension) and import it into my local database.

It takes 2 arguments, the first one is the exported file and the second is the database that you would like to import it to. Use it like so:


Pause Bootstrap’s carousel when fancyBox is loaded and play it again when fancyBox is closed

Sweet and simple!

Note: Tested using Bootstrap v3.3.5 and fancyBox v2.1.5

Get window size break-point in JavaScript

Here’s a quick and easy JavaScript code snippet that will return your window size break-point. This can be handy when writing custom JavaScript code for a mobile responsive website.

The break-points are set to the default sizes used in Bootstrap but can be changed easily if needed. It will return one of the following: xs, sm, md, or lg.

Simple function to show which template file a page is using in WordPress

When working on a WordPress site, more often than not you will run into a situation where you will need to find out which template file a page is using. Here’s a small function that you can throw into your theme’s functions.php file that will add an item to the admin bar telling you which template file the current page is using. You can also hover over it to get the full URL to that template file.

The item will only show up for administrators and it will only show up on the site’s front-end. Therefore you can just throw this code in there and leave it there!

Sort an array with dates for keys by year descending and day ascending

Here’s a PHP function that sorts an array with dates for keys by year descending and day ascending. So pretty much it’s going to take an array like this:

and sort it to look like this:


Here’s the function:

Just replace $array with the array that you’d like to sort and it’ll take care of the rest!