Skip to content

Instantly share code, notes, and snippets.

View justinph's full-sized avatar

Justin Heideman justinph

View GitHub Profile
@justinph
justinph / .htaccess
Last active February 3, 2021 18:25
Make wordpress shared password protected
<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 April 16, 2019 20:46
amp cinemgraph header
<!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 February 24, 2018 04:11
gcs set meta on upload
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',
})
@justinph
justinph / gpg.key
Created February 6, 2018 19:21
my 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 January 26, 2018 17:02
set cache headers on uploaded file via cloud function
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 October 12, 2017 14:38
node-sass@3.4.2 dep tree
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 February 3, 2017 19:37
Webpage performance testing with nightmare.js Raw
#!/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 February 3, 2017 19:37
Webpage performance testing with nightmare.js - solo
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 March 29, 2018 17:57
Webpage performance testing with 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));