This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function flatten2d($multi_dimensional_array) { | |
$flattened = []; | |
$flatten = function($value, $index) { | |
global $flattened; | |
array_push($flattened, $value); | |
}; | |
array_walk_recursive($multi_dimensional_array, $flatten); | |
return $flattened; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatUSPhoneNumber(number) { | |
var x = 0, groups = [], len, num; | |
/* Force string conversion */ | |
num = number+''; | |
/* Remove non numeric characters */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
PHP function for converting an ISO8601 duration (the kind used by YouTube's API) | |
to something more readable. | |
*/ | |
make_readable_duration($duration) | |
{ | |
$duration = new DateInterval($duration); | |
return $duration->format('%H:%I:%S'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
DialogModal. Depends on the presence of dialog-polyfill.js | |
and dialog-polyfill.css with the page in non-Chrome browsers. | |
https://github.com/GoogleChrome/dialog-polyfill | |
MIT licensed. | |
*/ | |
import React from 'react'; | |
import PropTypes from 'prop-types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Writing this as a note to myself :-) | |
Install a Python 3 binary from python.org, then add the path to that Python binary | |
(e.g. /Library/Frameworks/Python.framework/Versions/3.6/bin) to your /etc/paths file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ucfirst(word) { | |
const wordarray = word.split(''); | |
wordarray[0] = wordarray[0].toUpperCase(); | |
return wordarray.join(''); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const numberFormat = (number, separator = ',') => { | |
const num = Number.isNaN(+number) ? 0 : +number; | |
let x = 0; | |
let fnum = []; | |
const digits = (num + '').split(''); | |
const seg = digits.length / 3; | |
while(x < seg){ | |
fnum[x] = digits.splice(-3).join(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const range = (min, max) => { | |
const diff = max - min; | |
const spread = [...Array(diff).keys()].map(n => {return n + min}); | |
spread.push(max); | |
return spread; | |
} | |
// Example usage | |
range(2,100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you've recently added a self-signed SSL certificate to your keychain, try deleting it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.handler = (event, context, callback) => { | |
const request = event.Records[0].cf.request; | |
const response = event.Records[0].cf.response; | |
// frame-src is deprecated, but Chrome AFAIK doesn't yet support child-src. Using both here. | |
response.headers['content-security-policy'] = [{ | |
key: 'Content-Security-Policy', | |
value: "default-src 'self'; script-src 'self' https://webinista.us3.list-manage.com; font-src https://*; frame-src 'self' *.tiffanybbrown.com *.webinista.com; child-src 'self' *.tiffanybbrown.com *.webinista.com; img-src https://*; block-all-mixed-content" |