Skip to content

Instantly share code, notes, and snippets.

tim gavin timgavin

Block or report user

Report or block timgavin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
timgavin /
Last active May 17, 2018
Alfred workflow for creating a new Jekyll blog post
# In Alfred, create a new Blank Workflow and add a Keyword Input (Argument Required/uncheck With Space), mine is "new blog:" (without the quotes)
# Add a Run Script Action and make sure /bin/bash is selected in the Language dropdown
# Copy this Gist into the Run Script action (replacing the default text)
# Connect the Keyword action to the Run Script action
# Open an Alfred prompt and enter "new blog:My New Blog" without the quotes
# Watch the magic happen...
timgavin / ezsql_transaction.php
Created Apr 22, 2015
ezSQL Transaction (MySQLi)
View ezsql_transaction.php
// begin the transaction
// run all of your queries here...
// commit the queries
if($db->query('COMMIT') !== false) {
// transaction was successful
} else {
// transaction failed, rollback
timgavin / ezsql_encoding.php
Created Apr 22, 2015
Set Encoding in ezSQL
View ezsql_encoding.php
// When creating a new connection just set the fifth parameter to the encoding you desire
// and ezDB will run a 'SET NAMES' query with your preferred encoding.
$db = new ezSQL_mysqli(
timgavin / plural.php
Created Jul 12, 2012
Simple function to add smart apostrophes to the end of a string.
View plural.php
// see if a string ends in 's' and add aprostrophes accordingly
// optionally adds an 's' to the end of a string depending if $count is supplied
function plural($str,$count=null) {
if($count != null) {
if($count == 0 || $count > 1) {
if(substr($str,-1) == 's') {
return $count.' '.$str;
} else {
return $count.' '.$str.'s';
You can’t perform that action at this time.