Skip to content

Instantly share code, notes, and snippets.

View richardbporter's full-sized avatar

Richard B. Porter richardbporter

  • North Liberty, IA
View GitHub Profile
@richardbporter
richardbporter / dbsize.sh
Created May 9, 2022 12:37
Drupal database size
## Check the size of database used by Drupal (MySQL is expected).
drupal_db_name="$(drush sql-conf | grep "database" | grep -Eo "\S+$")"
if [[ -z "$drupal_db_name" ]]; then
echo "usage: run this command under a drupal instance directory."
return
fi
$(drush sql-connect) -e "SELECT table_schema AS \"Database\", SUM(ROUND(((data_length + index_length) / 1024 / 1024), 2)) AS \"Size in MB\" FROM information_schema.TABLES WHERE table_schema = \"$drupal_db_name\""
@richardbporter
richardbporter / .gitconfig
Last active May 18, 2022 20:44
git config
[user]
name = me
email = me@me.com
[color]
ui = auto
[core]
fileMode = false
editor = code --wait
excludesfile = ~/.gitignore
[push]
# Bash completions.
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
# Set the default system editor.
export EDITOR='code'
# Set CLI color.
export CLICOLOR=1
# Git prompt.
echo 'flush_all' | nc localhost 11211
find . -type d -name .git -exec sh -c "cd \"{}\"/../ && pwd && git pull" \;
@richardbporter
richardbporter / gist:485753078e91dcf871f6
Created October 15, 2014 16:12
git post-receive checkout
cd /path/to/work/tree
git --git-dir=/path/to/git/repo --work-tree=/path/to/work/tree checkout -f
@richardbporter
richardbporter / drupal_tz_offset.php
Created August 1, 2012 15:53
Drupal format_date timezone offset
<?php
$my_date = strtotime($node->field_date[0]['value']);
$tz_offset = strtotime(date("M d Y H:i:s")) - strtotime(gmdate("M d Y H:i:s"));
$my_date += $tz_offset;
print format_date($my_date, 'custom', 'D d F Y', NULL);
?>