Skip to content

Instantly share code, notes, and snippets.

View webinista's full-sized avatar

Tiffany Brown webinista

View GitHub Profile
@webinista
webinista / expandRGB.js
Last active June 5, 2017 00:42
Expand a 3-character hex string (beginning with #) into a 6 character one
export function expandRGB(string) {
if(!(/#[a-f0-9]{3}$/i).test(string)) return string;
const rgb = string.split('');
return `#${rgb[1]}${rgb[1]}${rgb[2]}${rgb[2]}${rgb[3]}${rgb[3]}`;
}
@webinista
webinista / hsltorgb.js
Last active June 7, 2017 23:16
Convert from hsl to rgb string
const percentToFloat = (percentString) => {
return parseInt(percentString, 10) / 100;
}
/*
* Copied, pasted, and modified straight from the CSS4 spec
* https://drafts.csswg.org/css-color-4/#hsl-to-rgb
*/
const hueToRgb = (t1, t2, hue) => {
let hueValue;
@webinista
webinista / index.js
Created December 13, 2017 17:23
Content-Security-Policy and other security-related headers for Node.js and AWS Lambda (for webinista.com, tiffanybbrown.com)
'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"
@webinista
webinista / gist:29a7bace0c181104b00e6165edf7d8bc
Last active January 21, 2018 00:12
Apache won't start MAMP Pro 4.2, OS X
If you've recently added a self-signed SSL certificate to your keychain, try deleting it.
@webinista
webinista / pelicanconf.py
Last active May 28, 2024 04:08
A Pelican configuration for having a home page and blog index or landing page.
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
# --------------------------------------
# Now compatible with Pelican 4.0.x!
# --------------------------------------
# Added by me
import time
@webinista
webinista / range.js
Last active April 13, 2018 03:51
Get a range of numbers that includes the min and max values. Integers only.
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);
@webinista
webinista / ucfirst.js
Created July 4, 2018 16:12
Uppercase the first letter of a word with JavaScript
function ucfirst(word) {
const wordarray = word.split('');
wordarray[0] = wordarray[0].toUpperCase();
return wordarray.join('');
}
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.
@webinista
webinista / DialogModal.jsx
Last active October 4, 2018 20:05
A work-in-progress React component for modals. Uses the <dialog> element.
/*
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';
@webinista
webinista / HowToFixPycURLErrorMacOS.md
Last active April 23, 2021 07:18
PycURL error: ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually.

Partly pulled from the comments here: pycurl/pycurl#526

May also be a fix for this error:

ImportError: pycurl: libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)

If you try to install PycURL and receive this error: