Skip to content

Instantly share code, notes, and snippets.

@ngstigator
ngstigator / backup_db-prod.sh
Last active April 21, 2018 16:46
bash script create db subdir and backup to it
#!/bin/bash
# create {year} folder if it doesn't exist
mkdir -p /home/web/db/$(date +%Y)
# dump database into {year} folder
mysqldump --opt -uweb -pPASSWORD DATABASE_NAME | gzip > /home/web/db/$(date +%Y)/DATABASE_NAME_$(date +%Y%m%d-%H%M).sql.gz
#!/bin/bash
BACKUP_DIR=/home/web/db
DB_FILE=$(ls $BACKUP_DIR -tp |grep -v /$ | head -1)
s3cmd put $BACKUP_DIR/$DB_FILE s3://{BUCKET_NAME}/db/$DB_FILE 2>&1
#echo $DB_FILE
@ngstigator
ngstigator / ssh_config.txt
Created July 31, 2017 14:42
SSH config deploy key
Host github-{repo}
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_{deploy_key}
`git remote add origin github-{repo}:username/repo.git`
@ngstigator
ngstigator / nginx_vhost.conf
Last active October 8, 2020 23:13
works with WP and Grav
server {
listen 80; ## listen for ipv4; this line is default and implied
listen 443 ssl;
root /home/PATH/public_html;
index index.php index.html index.htm;
server_name DOMAINNAME.ca;
ssl_certificate /etc/letsencrypt/live/DOMAINNAME.ca/fullchain.pem;
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:PutObjectAcl"
],
# Case sensitive
rewrite ^/[Nn][Ff][Pp]romo/?$ /now-fresh-offer/ redirect;
rewrite ^/(?i)GatherDog/?$ /for-dogs/gather/ permanent;
# URL params
location /some/path$ {
if ($query_string ~* "page=(.*)$") {
rewrite ^(.*)$ /destination? permanent;
}
}
# https://wiki.apache.org/httpd/RewriteQueryString
# Enforce HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/secure-me-1 [NC,OR]
RewriteCond %{REQUEST_URI} ^/secure-me-2 [NC]
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# re-use variable
RewriteCond %{QUERY_STRING} zoom_query=(.*)$
@ngstigator
ngstigator / wp_nginx_whitelist_admin
Created March 8, 2017 17:37
Whitelist IPs to wp-admin in Nginx
###
# SSL Detection
###
# This header would be set if an upstream source (such as an ELB) has negotiated an SSL connection.
if ( $http_x_forwarded_proto = 'https' ) {
set $ssl_enabled true;
}
# This would be set if nginx is handling the SSL connection directly.
@ngstigator
ngstigator / s3cmd_sync_policy
Created November 7, 2016 23:01
IAM policy for s3cmd sync
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
@ngstigator
ngstigator / kcseo-cpt.patch
Last active September 29, 2016 20:33
patch wp-seo-structured-data to allow custom post types
diff a/lib/classes/KcSeoHelper.php b/lib/classes/KcSeoHelper.php
43,45c43,45
< array(
< '_builtin' => true
< )
---
> // array(
> // '_builtin' => true
> // )