Skip to content

Instantly share code, notes, and snippets.

Sam Sargent samsargent

  • Vivo Group
  • Brisbane, Australia
View GitHub Profile
samsargent /
Created Mar 7, 2016
Bulk update to utf8/utf8_general_ci database + tables
DB="DBNAME"; ( echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'; mysql -u root "$DB" -e "SHOW TABLES" --batch --skip-column-names | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' ) | mysql -u root "$DB"
View OrdinalSuffix.php
function ordinal($number) {
$ends = array('th','st','nd','rd','th','th','th','th','th','th');
if ((($number % 100) >= 11) && (($number%100) <= 13))
return $number. 'th';
return $number. $ends[$number % 10];
# for the things I rarely do but often forget
# copy files via ssh
scp foobar.txt
samsargent /
Created Jul 30, 2015
Download Latest Wordpress
wget && tar xfz latest.tar.gz && rm -rf wordpress/wp-content/ && mv wordpress/* ./ && rm -rf wordpress/ && rm -rf latest.tar.gz
samsargent /
Last active Jan 16, 2020
SSH Login - No Password
echo "Enter ssh username & host you want to add your key to in the following format:"
read host
IP=$(curl -Sfs
KEY=$(cat ~/.ssh/
echo 'Adding Key to '$host': from="'$IP'"' $KEY
echo 'from="'$IP'"' $KEY | ssh $host 'cat >> ~/.ssh/authorized_keys'
View Sublime Terminal Sym Link
View Parsely.js Mobile Number Validation
<input type="text" class="text" name="mobilePhone" id="mobilePhone" value="" parsley-regex-message="Please enter a valid Australian mobile phone number." parsley-regexp="^\(?(?:\+?61|0)4\)?(?:[ -]?[0-9]){2}\)?(?:[ -]?[0-9]){5}[0-9]$"/>
samsargent / archive.php
Created May 1, 2013
Wordpress: Draft Coming Soon Teasers on archive pages
View archive.php
if ( is_tax('platform')) {
$args = array(
'post_type' => 'post',
'post_status' => 'draft',
'tax_query' => array(
'taxonomy' => 'platform',
'field' => 'slug',
samsargent / gist:5464513
Last active Dec 16, 2015
Wordpress: Change default from name & email filters
View gist:5464513
function my_wp_mail_from_name($name) {
return 'From Name';
//email from email function
function my_wp_mail_from($content_type) {
return '';
samsargent / gist:5429552
Last active Dec 16, 2015
PHP: SlimPHP PDO database connection
View gist:5429552
function getConnection() {
case 'dev':
You can’t perform that action at this time.