Skip to content

Instantly share code, notes, and snippets.

@joemaller
joemaller / gulpfile.js
Last active January 5, 2017 20:42
Example gulpfile showing how to serve Browsersync from an arbitrary subpath. Download the zip, `npm install` and `gulp watch`
var gulp = require('gulp');
var browsersync = require('browser-sync').create();
gulp.task('watch', function() {
browsersync.init({
files: './*.html',
startPath: '/some/multi/level/path',
server: {
baseDir: '-',
routes: {
@joemaller
joemaller / regexp-exec-vs-string-match.md
Created April 21, 2017 14:39
RegExp.exec and String.match are the same, right?

In JavaScript RegExp.exec() and String.match() should be interchangeable so long as the inputs are the same. Right?

const pat = /(dog).*(bird)/g;
const str = 'dog cat bird';

const foo = str.match(pat);
const bar = pat.exec(str);
@joemaller
joemaller / 4k-sizes.json
Created May 15, 2017 18:39
Approximate sizes of 4k HDTV screens
{
"55": {"w": 48.75, "h": 28.5},
"60": {"w": 53.75, "h": 31},
"65": {"w": 57, "h": 33}
}
@joemaller
joemaller / executable node module.md
Created August 25, 2017 17:51
Run node.js modules from the command line

Add one line to a node.js module and it becomes a callable script:

// hello-module.js
module.exports = function() {
return "Hello!";
};

if (!module.parent) module.exports();
@joemaller
joemaller / index.js
Created September 6, 2017 14:27
Initial, rough AWS lambda script for the webcam.
"use strict";
const aws = require("aws-sdk");
const s3 = new aws.S3({ apiVersion: "2006-03-01" });
const dynamodb = new aws.DynamoDB();
const isNum = n => !isNaN(parseFloat(n)) && isFinite(n);
exports.handler = (event, context, callback) => {
const jsonFileName = "14th-street-webcam.json";
@joemaller
joemaller / seo-framework-filters.php
Created November 2, 2017 16:49
Two filters for tweaking The SEO Framework plugin.
<?php
// Hide author's name from SEO Framework block
add_filter('sybre_waaijer_<3', '__return_false');
// Move SEO Framework metabox below all custom fields
add_filter('the_seo_framework_metabox_priority', function () {
return 'low';
});
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Version: 0.5.0-0
# Try reading package.name from ./site/package.json
begin
$hostname = JSON.parse(File.read(__dir__ + '/site/package.json'))['name']
$themename = $hostname
rescue StandardError
end
@joemaller
joemaller / luxon.md
Created January 23, 2018 14:29
Luxon Timestamps

Finding this took me longer than it should have, probably because I was impatiently looking for "timeststamp" instead of "milliseconds of the Unix epoch". For future searchers, Luxon uses the methods DateTime.fromMillis and DateTime.valueOf.

// Create a Luxon DateTime from a JS Unix timestamp
const ts = new Date().getTime();     // 1516717417146
const dt = DateTime.fromMillis(ts);  // { ts: 2018-01-23T09:23:37.146-05:00 ...
console.log(dt.valueOf());           // 1516717417146
@joemaller
joemaller / .htaccess
Last active March 29, 2018 14:23
Redirect HTTP to HTTPS from .htaccess
# .htaccess redirects can vary depending on server caching, reverse proxies and CDNs
# Try these RewriteConditions in order, starting from the top and stepping down
# until one works. Only enable one RewriteConds at a time.
RewriteEngine On
# 1. Try this first
RewriteCond %{HTTPS} off
# 2. Docs suggest on|off should work, but try this anyway
@joemaller
joemaller / Verizon FiOS - DNS servers.md
Created May 9, 2018 14:49
Nameservers for Verizon FiOS - North East US specific

Boston, MA:

  • nsbost02.verizon.net - 71.243.0.14

New York, NY:

  • nsnyny02.verizon.net - 68.237.161.14

Newark, NJ:

nsnwrk02.verizon.net - 71.250.0.14

Philadelphia, PA: