Skip to content

Instantly share code, notes, and snippets.

View mwpastore's full-sized avatar

Mike Pastore mwpastore

  • Chicago, Illinois
View GitHub Profile
@mwpastore
mwpastore / 00README.md
Last active April 18, 2024 06:21
Lightning Fast WordPress: Caddy+Varnish+PHP-FPM

README

This gist assumes you are migrating an existing site for www.example.com — ideally WordPress — to a new server — ideally Ubuntu Server 16.04 LTS — and wish to enable HTTP/2 (backwards compatibile with HTTP/1.1) with always-on HTTPS, caching, compression, and more. Although these instructions are geared towards WordPress, they should be trivially extensible to other PHP frameworks, other FastCGI backends, and even non-FastCGI backends (using proxy in lieu of fastcgi in the terminal Caddyfile stanza).

Quickstart: Use your own naked and canonical domain names instead of example.com and www.example.com and customize the Caddyfile and VCL provided in this gist to your preferences!

These instructions target Varnish Cache 4.1, PHP-FPM 7.0, and Caddy 0.10. (I'm using MariaDB 10.1 as well, but that's not relevant to this guide.)

@mwpastore
mwpastore / README.md
Last active October 15, 2023 01:01
pfSense unbound+dnsmasq

What is this?

This guide shows how to replace the DHCP Server function in pfSense with dnsmasq. You can do this for some or all of your subnets. This addresses a 12+-years old [bug][1] in pfSense.

While it is possible to replace the DHCPv6 Server & RA and/or DNS Resolver functions in pfSense with dnsmasq as well, these are out of scope for this guide. Unbound can run in recursive mode and it has some performance advantages over dnsmasq; generally speaking pfSense seems "happier" with it enabled.

DISCLAIMER: While I have done profesionally network administration in the past, I am not per se a professional network administrator. I'm just a guy with an overly-complicated homelab who's been using dnsmasq for many years. Follow this guide at your own risk—and please take a backup before you start!

Pros

@mwpastore
mwpastore / -with-state.js
Last active April 5, 2023 17:29
Ember/Glimmer computed getter with access to previous value
import { resource } from 'ember-resources';
const withState =
({ ...state }, fn) =>
resource(() => Object.assign(state, fn({ ...state })));
export default { withState };
@mwpastore
mwpastore / on-key.js
Created May 19, 2020 16:27
{{on-key}} modifier for Ember.js
import { modifier } from 'ember-modifier';
import { isArray } from '@ember/array';
import { capitalize } from '@ember/string';
import { isEmpty, isPresent, typeOf } from '@ember/utils';
const { isInteger } = Number;
const parseKeys = arr => arr
.filter(_ => typeOf(_) === 'string')
@mwpastore
mwpastore / controllers.application\.js
Created March 9, 2020 00:54
(action (mut foo)) vs (fn (mut foo))
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
@tracked
prop;
@tracked
propDidUpdate = false;
@mwpastore
mwpastore / shares.conf
Last active January 9, 2020 16:21
Example of Samba ACL changes from 4.10 to 4.11
[tank_active]
browsable = yes
read only = no
guest ok = no
valid users = @users
path = /tank/active
block size = 4096
write cache size = 131072
@mwpastore
mwpastore / cmdline.sh
Last active December 20, 2019 03:35
VCL snippets
mkfs.ext4 -b 4k -C 128k -E num_backup_sb=0,packed_meta_blocks=1,root_owner=111:118 -O bigalloc,extent,flex_bg,^has_journal,mmp,sparse_super2 -L varnish-cache -N 64 -v /dev/sdc
@mwpastore
mwpastore / rg-refresh.sh
Last active June 4, 2018 05:52
Automated VLAN flop for AT&T RG workaround
#!/bin/bash
###
# PURPOSE
#
# Execute a VLAN "flop" to allow the AT&T Residential Gateway (RG) to perform
# 802.1x authentication via the Optical Network Terminal (ONT) before falling
# back to the subscriber's "own" router/gateway hardware. The RG is toggled off
# and on as needed via a remote-controlled power outlet (see below).
#
# For more information about this procedure, please see brianlan's original
@mwpastore
mwpastore / -computed-promise.js
Last active September 28, 2017 22:16
Promise-aware compute macros
import computed from 'ember-macro-helpers/computed';
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
import { typeOf } from '@ember/utils';
import { all } from 'rsvp';
export default function(Proxy) {
const PromiseProxy = Proxy.extend(PromiseProxyMixin);
@mwpastore
mwpastore / components.my-component.js
Last active September 19, 2017 23:22
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
greeting: 'Hello',
actions: {
showAlert(message) {
const greeting = this.get('greeting');
alert(`${greeting}, ${message}!`);