This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 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... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// begin the transaction | |
$db->query('BEGIN'); | |
// run all of your queries here... | |
// commit the queries | |
if($db->query('COMMIT') !== false) { | |
// transaction was successful | |
} else { | |
// transaction failed, rollback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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( | |
'username', | |
'password', | |
'database', | |
'localhost', | |
'UTF-8' | |
); |