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);
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: { |
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);
{ | |
"55": {"w": 48.75, "h": 28.5}, | |
"60": {"w": 53.75, "h": 31}, | |
"65": {"w": 57, "h": 33} | |
} |
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();
"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"; |
<?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 |
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
# .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 |