Quick recursive PHP file syntax check

May 10, 2016

I find it handy to run a PHP syntax (lint) check on files after resolving a merge conflict in git. Here is a handy snippet that will run find every file in the current and sub-directories and run them through the PHP command line syntax checker. find . -iname “*.php” -exec php -l {} \;

MySQL: Find the size of a database

April 28, 2016

MySQL has the ability to show you size of the information contained in your database. You can find this information per database or per table in a database pretty easily. Size of databases To list the size of all the databases on the server run the following: SELECT table_schema “Database”, sum( data_length + index_length) /

MySQL who: See who is connected to your MySQL server with this script

February 29, 2016

Need to determine who is connected to your MySQL server and how many connections they have open? I tossed together this little script to display the information. [bash] #!/usr/bin/perl use DBI; use 5.010; use Getopt::Long; # Set defaults my $host = ‘localhost’; my $db = ‘information_schema’; my $user = ”; my $pass = ”; #

Autocomplete git branches and commands in bash

February 10, 2016

The tab completion for commands in bash is awesome, but it does not work for bash out of the box. Lucky for us it is relatively easy to get bash completion working. You will need two things, a copy of the completion script and an update to your bash profile. The completion script is available

Getting social media shares with php

October 9, 2015

Quick snippets to help me (and maybe you!) remember how to quickly and easily get share counts from social networks. What other networks would you like to see? Facebook [php] function facebook_share_count( $post_id ) { $api = "https://graph.facebook.com/"; $url = $api . urlencode( get_permalink( $post_id ) ); $response = wp_remote_get( $url ); if( is_wp_error( $response