Skip to content

Instantly share code, notes, and snippets.

View tlongren's full-sized avatar
🎯
Focusing

Tyler Longren tlongren

🎯
Focusing
View GitHub Profile
@tlongren
tlongren / backup.sh
Last active September 21, 2017 18:04
Quick & easy remote backups
#!/bin/sh
SERVER=backup.server.com
rsync -avz --partial --delete --bwlimit=25 --progress --stats -e ssh
/opt/backups tyler@$SERVER:/home/tyler/
@tlongren
tlongren / dockerize-meteor-app.sh
Last active June 11, 2019 06:41
Dockerize a Meteor App
#!/bin/bash
# Taken from https://blog.mvp-space.com/how-to-dockerize-a-meteor-app-with-just-one-script-4bccb26f6ff0
APP_NAME=myapp
APP_DOMAIN=localhost
APP_PORT=3000
SETTINGS_PATH=.config/staging/settings.json
MONGO_URL=localhost
MONGO_PORT=27017
MONGO_DB=myappdb
@tlongren
tlongren / compression-minify-wordpress.md
Last active May 6, 2019 01:52
Output Compression, Browser Caching, Asset Minification and Image Optimization for WordPress

Output Compression, Browser Caching, Asset Minification and Image Optimization

The following apache and nginx configurations will handle compression and browser caching. A few different WordPress plugins can be used for asset minification.

mod-pagespeed may be available for configuration as an apache or nginx module. If available, there's no need to use the individual apache or nginx configurations. Mod-pagespeed will handle compression and browser caching, making the apache and nginx configurations unnecessary. The WordPress plugins are still needed for asset minification as they ensure assets are loaded in the proper order once minified.

Image optimization should be done using the EWWW Image Optimizer plugin.

Apache Config

Output Compression

Hardening WordPress

Securing WordPress using a combination of configuration changes and plugins.

.htaccess and wp-config.php tasks

1. Add keys to wp-config.php

2. Hide .htaccess and wp-config.php

@tlongren
tlongren / function-alt.php
Last active November 24, 2017 18:03
WordPress Redirect to Previous Page on Login
<?php
function my_login_redirect( $redirect_to, $request, $user ) {
$redirect_to = home_url() . '/members/';
return $redirect_to;
}
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );
@tlongren
tlongren / sticky-alert-options.js
Last active July 15, 2017 19:19
Sticky Alert Options
$(document).ready(function() {
$('#alert-container').stickyalert({
barColor: '#222', // alert background color
barFontColor: '#FFF', // text font color
barFontSize: '1.1rem', // text font size
barText: 'I like bass and car audio :)', // the text to display, linked with barTextLink
barTextLink: 'http://test-tyler-longren.pantheonsite.io/', // url for anchor
cookieRememberDays: '2', // in days
displayDelay: '3000' // in milliseconds, 3 second default
});
@tlongren
tlongren / insert-posts.php
Created September 22, 2016 08:50
WordPress: Insert a post into WordPress from an external script
<?php
// Load WordPress
require_once 'path/to/www/wp-load.php';
require_once ABSPATH . '/wp-admin/includes/taxonomy.php';
// Set the timezone so times are calculated correctly
date_default_timezone_set('Europe/London');
// Create post
<?php
/*
Plugin Name: RSS Via Shortcode for Page & Post
Version: 1.2.b
Plugin URI: http://susantaslab.com/
Description: Makes it easy to display an RSS feed on a page
Author: Susanta K Beura
Author URI: http://susantaslab.com/
License: GPL v2
Usages: [rssonpage rss="Feed URL" feeds="Number of Items" excerpt="true/false" target="_blank|_self"]
@tlongren
tlongren / pug-bomb.php
Created February 2, 2016 04:38 — forked from retgef/pug-bomb.php
Pug Bomb API Endpoint WordPress Plugin
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{
@tlongren
tlongren / README.md
Last active November 22, 2015 04:43
WordPress on Sloppy.io

Running WordPress on sloppy.io

The official wordpress and mysql image combined for a sloppy.io project. You can extend the json with more variables from the official images.

Start it

sloppy start wordpress.json  -var=USERNAME:username,URI:mydomain.sloppy.zone,DBUSER:db-user-for-wordpress,DBPASS:db-password-for-wordpress,DBROOT:db-root-password
where USERNAME has to be your  sloppy.io username
Example: