Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Heideman justinph

View GitHub Profile
@justinph
justinph / .htaccess
Last active Feb 3, 2021
Make wordpress shared password protected
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# send all users w/o this cookie to wall.php
RewriteCond %{REQUEST_FILENAME} !(wall\.php|.*\.jpe?g|.*\.m4v|.*\.png|.*\.gif)
RewriteCond %{HTTP_COOKIE} !^.*yourfancycookiename.*$ [NC]
RewriteCond %{HTTP_USER_AGENT} !^(.*Jetpack.*)$
RewriteRule .* /wall.php [NC,L,R=302]
@justinph
justinph / amp-video.html
Last active Apr 16, 2019
amp cinemgraph header
View amp-video.html
<!DOCTYPE html>
<html amp lang="en" >
<head>
<meta charset="utf-8">
<link href="self.html"
rel="canonical">
<meta content="width=device-width,minimum-scale=1,initial-scale=1"
name="viewport">
<style amp-boilerplate="">
body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
@justinph
justinph / index.js
Last active Feb 24, 2018
gcs set meta on upload
View index.js
const storage = require('@google-cloud/storage')();
exports.setMeta = function (event, doneCb) {
const file = event.data;
const gcsBucket = storage.bucket(file.bucket);
const gcsFile = gcsBucket.file(file.name);
if (file.metageneration === '1') {
return gcsFile
.setMetadata({
cacheControl: 'public, maxage=3600',
})
View gpg.key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFp5/zsBEADT01rwMLamNlsDf6QfOYjdOM8AWrok+kw7simbHQvRXKj2VgIl
PAS5TA5AKsFHZAJhrDnI3RNH8WyuUH2XADrRIa1RIfIaXvT4AyqXeXaFLaJUGw8I
urnK3jq+bYNKY7mmLGRJ7vnIZZS2pivctWb+xTRjREtp4zc8wTBnOwb4Cnwg+W6p
bu3hb6FNLiQTKheUyos3eMWPP2kygaQJGzX0pR1V2pE5y6H8TnExhGDwzqE7mgKp
vm73FjlSN8oKzgGiiDr6MWJNtDymBfS205SPuTxgURiG45IlB3VMhtsXEJCIyj1s
AHXSxaSewxBSDTc5mjN5Mmx0BJyRfmbVxggMLxZgcCYOAbm1SxN0ffB+6Q7maooH
ow1uCIrLebui+uJQr/W6qKAoDc8oZj5cIdgov0XFdHxX//2F+5+8fMRn7TTszYvz
UZXoYwFgZYy2WWnP6Kl7goii8sGfcBZr6GRn1l7ckHnFJCWTMz1ewQ5vwQKo14qq
@justinph
justinph / index.js
Last active Jan 26, 2018
set cache headers on uploaded file via cloud function
View index.js
const storage = require('@google-cloud/storage')();
exports.setMeta = function (event, doneCb) {
const file = event.data;
console.log(`Examing file ${file.name}.`);
const gcsBucket = storage.bucket(file.bucket);
const gcsFile = gcsBucket.file(file.name);
if (file.metageneration === '1') {
@justinph
justinph / wow.txt
Created Oct 12, 2017
node-sass@3.4.2 dep tree
View wow.txt
node-sass@3.4.2
├─ get-stdin@4.0.1
├─ cross-spawn@2.2.3
│ ├─ cross-spawn-async@2.2.5
│ │ ├─ which@1.3.0
│ │ └─ lru-cache@4.1.1
│ │ ├─ pseudomap@1.0.2
│ │ └─ yallist@2.1.2
│ └─ spawn-sync@1.0.15
│ ├─ os-shim@0.1.3
@justinph
justinph / runtest.sh
Created Feb 3, 2017
Webpage performance testing with nightmare.js Raw
View runtest.sh
#!/bin/bash
for run in {1..40}
do
baseline=$(node nightmare.js 'http://www.nytimes.com/2016/test-page-1.html')
secondary=$(node nightmare.js 'http://www.nytimes.com/2016/test-page-2.html')
echo $baseline, $secondary
done
@justinph
justinph / nightmare.js
Created Feb 3, 2017
Webpage performance testing with nightmare.js - solo
View nightmare.js
let Nightmare = require('nightmare');
let harPlugin = require('nightmare-har-plugin');
let options = {
waitTimeout: 1000
};
harPlugin.install(Nightmare);
let nightmare = Nightmare(Object.assign(harPlugin.getDevtoolsOptions(), options));
@justinph
justinph / nightmare.js
Last active Mar 29, 2018
Webpage performance testing with nightmare.js
View nightmare.js
let Nightmare = require('nightmare');
let harPlugin = require('nightmare-har-plugin');
let options = {
waitTimeout: 1000
};
harPlugin.install(Nightmare);
let nightmare = Nightmare(Object.assign(harPlugin.getDevtoolsOptions(), options));