Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

davemac davemac

🎯
Focusing
Block or report user

Report or block davemac

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
@davemac
davemac / getups()
Created May 20, 2019
rsyncs WordPress uploads directory from staging/prod to current site, excluding .pdf files
View getups()
# rsync wp uploads directory from staging to current site, exclude .pdf files
# uses command line argument $1 for prod or staging ssh alias
getups() {
current=${PWD##*/}
cd ~/Sites/$current/wp-content/uploads || return
rsync -avzW --progress --exclude '*.pdf' --exclude '*.docx' $current-$1:~/www/wp-content/uploads/* .
cd ~/Sites/$current/wp-content/themes/$current
}
@davemac
davemac / pullstage()
Created May 17, 2019
pull a staging WP database to an existing local site
View pullstage()
# pull a staging WP database to an existing local site
# uses current directory as theme path and ssh alias
pullstage() {
# set -x
START=$(date +%s)
# get current directory name, used for database and URL
# TODO: use echo get_template_directory() and get characters from right to first /
current=${PWD##*/}
cd ~/Sites/$current
# make a backup of the current local database
View .bash_profile
# pull a staging WP database to an existing local site
# uses current directory as theme path and ssh alias
pullstage() {
# set -x
START=$(date +%s)
# get current directory name, used for database and URL
# TODO: use echo get_template_directory() and get characters from right to first /
current=${PWD##*/}
cd ~/Sites/$current
# make a backup of the current local database
@davemac
davemac / firstdeploy()
Last active Jul 16, 2019
initial deploy of local site to staging server
View firstdeploy()
# for initial site deployment to staging server, excludes dev tools and build files
# uses current directory as theme path and ssh alias
# 3 user inputs: dbname, dbuser, dbpass
firstdeploy() {
current=${PWD##*/}
cd ~/Sites/$current || return
echo "Staging database name:"
read dbname
echo "Staging database user:"
@davemac
davemac / pushstage()
Last active Apr 4, 2019
push a local WP database to an existing staging site
View pushstage()
# push a local WP database to an existing staging site
# uses current directory as theme path and ssh alias
pushstage() {
START=$(date +%s)
# make a backup of the current local database
# get current directory name, used for database and URL
current=${PWD##*/}
cd ~/Sites/$current || return
# rsync the local database to staging site
@davemac
davemac / pullprod()
Last active Apr 4, 2019
pull a production WP database to an existing local site
View pullprod()
# pull a production WP database to an existing local site
# uses current directory as theme path and ssh alias
pullprod() {
START=$(date +%s)
# get current directory name, used for database and URL
# TODO: use echo get_template_directory() and get characters from right to first /
current=${PWD##*/}
cd ~/Sites/$current
# make a backup of the current local database
wp db export _db.sql
@davemac
davemac / cloudflare ips for jetpack
Last active Mar 8, 2019
cloudflare ips for jetpack
View cloudflare ips for jetpack
103.21.244.0-103.21.244.22
103.22.200.0-103.22.200.22
103.31.4.0-103.31.4.22
104.16.0.0-104.16.0.12
108.162.192.0-108.162.192.18
131.0.72.0-131.0.72.22
141.101.64.0-141.101.64.18
162.158.0.0-162.158.0.15
172.64.0.0-172.64.0.13
173.245.48.0-173.245.48.20
View getuploads
# rsync wp uploads directory from staging to current site, exclude .pdf files
# uses command line argument $1 for prod or staging ssh alias
getups() {
current=${PWD##*/}
cd ~/Sites/$current/wp-content/uploads || return
rsync -avzW --progress --exclude '*.pdf' --exclude '*.docx' $current-$1:~/www/wp-content/uploads/* .
}
@davemac
davemac / _dmc-cards.scss
Created Jul 9, 2018
Example css grid card layout
View _dmc-cards.scss
.cards {
display: flex;
align-items: stretch;
justify-content: space-between;
max-width: $row-width;
list-style: none;
margin: 0;
@media #{$medium-up} {
> * {
@davemac
davemac / wpmu change site domain
Created Jun 28, 2018
wpmu change site domain
View wpmu change site domain
# If the sub site's site/home url can not be changed from the WP admin, the following SQL
# queries will change the necessary fields to map a domain to a sub site.
# presuming the sub site ID that we are changing is 1…
UPDATE `wp_blogs` SET domain='smsmagazine.com.au', path='/' WHERE blog_id = 1;
UPDATE `wp_options` SET option_value='https://smsmagazine.com.au/' WHERE option_name='siteurl';
UPDATE `wp_options` SET option_value='https://smsmagazine.com.au/' WHERE option_name='home';
You can’t perform that action at this time.