Skip to content

Instantly share code, notes, and snippets.

Avatar
😃

David Wells DavidWells

😃
View GitHub Profile
@DavidWells
DavidWells / reset.css
Last active Sep 17, 2021 — forked from karbassi/reset.css
CSS reset. Follow me on the twitters for more tips: https://twitter.com/davidwells
View reset.css
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
View open-color-postcss-variables.js
// via https://yeun.github.io/open-color/
const palette = {
dark: [
'#d5d7e0',
'#acaebf',
'#8c8fa3',
'#666980',
'#4d4f66',
'#34354a',
View aligning-images.md

Aligning images

left alignment

This is the code you need to align images to the left:

<img align="left" width="100" height="100" src="http://www.fillmurray.com/100/100">
@DavidWells
DavidWells / package.json
Created Sep 12, 2021
Symlink a directory for package.json scripts
View package.json
{
"if-not-ci": "pnpm ts support/scripts/run-if-not-ci.ts",
}
@DavidWells
DavidWells / aws-lambda-redirect.js
Created Jun 28, 2018
How to do a 301 redirect from an AWS lambda function
View aws-lambda-redirect.js
exports.handler = (event, context, callback) => {
const response = {
statusCode: 301,
headers: {
Location: 'https://google.com',
}
};
return callback(null, response);
}
@DavidWells
DavidWells / javascript-highlight-text.js
Created Sep 10, 2021
Highlight Search match in JS
View javascript-highlight-text.js
function highlightMatch(string, regexp) {
return escapeString(string).replace(regexp, (match) => `<mark>${match}</mark>`)
}
// Used to match HTML entities and HTML characters.
const unescapedHtml = /[&<>"']/g
const hasUnescapedHtml = RegExp(unescapedHtml.source)
const htmlEscapes = {
'&': '&amp;',
@DavidWells
DavidWells / netlify.toml
Last active Aug 25, 2021
All Netlify.toml & yml values
View netlify.toml
[Settings]
ID = "Your_Site_ID"
# Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts.
[build]
# This is the directory to change to before starting a build.
base = "project/"
# NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
# This is the directory that you are publishing from (relative to root of your repo)
View no-try-catch-async-await.js
/* Helper buddy for removing async/await try/catch litter 🗑 */
function O_o(promise) {
return promise.then(data => {
if (data instanceof Error) return [data]
return [null, data]
}).catch(err => [err])
}
/* Look ma, no try/catch */
async function usageExample(params) {
@DavidWells
DavidWells / add-wordpress-settings-page.php
Created Jan 28, 2013
WordPress :: Add Settings Page with All Fields
View add-wordpress-settings-page.php
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
View serverless.full.yml
# serverless.yml
service:
name: myService
awsKmsKeyArn: arn:aws:kms:us-east-1:XXXXXX:key/some-hash # Optional KMS key arn which will be used for encryption for all functions
frameworkVersion: ">=1.0.0 <2.0.0"
provider:
name: aws