Skip to content

Instantly share code, notes, and snippets.

View vivianspencer's full-sized avatar

Vivian Spencer vivianspencer

View GitHub Profile
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags
@vivianspencer
vivianspencer / gist:a60eac4079c1d41b82b6
Created January 7, 2016 12:38
Password Authentication for Nginx
sudo sh -c "echo -n 'username:' >> /var/www/example.com/.htpasswd"
sudo sh -c "openssl passwd -apr1 >> /var/www/example.com/.htpasswd"
@vivianspencer
vivianspencer / functions.php
Created December 29, 2015 09:23
Wordpress Virtual Page
<?php
function my_rewrite_init()
{
add_rewrite_rule( 'your-desired-path', 'index.php?your-query-var=1', 'top' );
}
add_action( 'init', 'my_rewrite_init' );
function my_rewrite_query_vars( $query_vars )
{
@vivianspencer
vivianspencer / generate.sh
Created September 23, 2015 12:55
Bulk generate WordPress posts using WP-CLI and the Bacon Ipsum API
for n in {1..5}; do curl 'https://baconipsum.com/api/?type=meat-and-filler&paras=5&format=html' | wp post generate --count=1 --post_content; done
@vivianspencer
vivianspencer / server_hardening.md
Last active January 28, 2025 09:00
Debian 8 Hardening

Debian 8 Hardening

  1. Update root's mail recipient. Open /etc/aliases replacing [email protected] with an administrator's email address. This is where logs will be emailed.

    root:     [email protected]
    
  2. Update the the default umask to 027. Edit the file /etc/init.d/rc and change the following setting:

umask 027

@vivianspencer
vivianspencer / setup.md
Last active August 18, 2016 14:20
Debian 8 (Jessie) LEMP Setup

Debian 8 LEMP

  1. Set the hostname of the server

    hostnamectl set-hostname johnsmith
    
  2. Make the hostname resolvable. Open the file /etc/hosts in your favourite editor and assign the IPv4 & IPv6 records of the server to your chosen hostname & FQDN.

    127.0.0.1       localhost.localdomain   localhost
    
@vivianspencer
vivianspencer / example.com
Last active August 29, 2015 14:26
Wordpress Nginx server configuration (live, staging with htpasswd)
server {
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
root /usr/share/nginx/www/example.com/www/web;
index index.php index.html index.htm;
@vivianspencer
vivianspencer / 00-header
Last active January 12, 2018 16:27
Debian Wheezy Dynamic MOTD
#!/bin/sh
#
# 00-header - create the header of the MOTD
# Copyright (c) 2013 Nick Charlton
# Copyright (c) 2009-2010 Canonical Ltd.
#
# Authors: Nick Charlton <[email protected]>
# Dustin Kirkland <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
@vivianspencer
vivianspencer / gist:c7d400dd3c4dfd5b201e
Created June 10, 2015 07:53
Wordpress Database migration
wp db export
scp -r [email protected]:path/to/files/ .
wp db import example_com.sql
wp search-replace example.com newexample.com --dry-run
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo "Installing Xcode Command Line Tools..."
xcode-select --install
echo Install Homebrew