Skip to content

Instantly share code, notes, and snippets.

@tannerhodges
tannerhodges / reset-web-component.css
Created March 9, 2022 10:37
🧠 Reset CSS for Web Components
/**
* Reset all inheritable properties.
*
* Excluded uncommon properties: azimuth, elevation, pitch-range, pitch, richness, speech-rate, stress, voice-family, volume.
*
* @see https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/
* @see https://gist.github.com/dcneiner/1137601
*
*/
:host {
@tannerhodges
tannerhodges / snap-slider-example.html
Created August 10, 2020 11:32
Examples of how to upgrade Snap Slider from older to newer versions
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Snap Slider v2.0.0</title>
<link rel="stylesheet" href="./snap-slider-v1.css">
<script defer src="./snap-slider-v2.js"></script>
</head>
@tannerhodges
tannerhodges / nginx-security-headers.conf
Last active August 7, 2020 15:21
HTTP Security Headers for Nginx & PHP
# Add HTTP Headers to improve site security.
# https://owasp.org/www-project-secure-headers/#tab=Headers
# X-Frame-Options: Stop people from loading your site in an iframe on their own site.
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
add_header X-Frame-Options "SAMEORIGIN";
# X-XSS-Protection: Stop pages from loading when the browser detects cross-site scripting (XSS) attacks.
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
add_header X-XSS-Protection "1; mode=block";
@tannerhodges
tannerhodges / functions-404.php
Last active May 6, 2020 01:20
WordPress `throw_404()` helper.
<?php
/**
* Throw a 404 error and render the current theme's 404 template.
*
* @see https://richjenks.com/wordpress-throw-404/
* @see https://developer.wordpress.org/reference/hooks/pre_get_document_title/
*/
function throw_404() {
// 1. Ensure `is_*` functions work.
@tannerhodges
tannerhodges / map.php
Created October 24, 2019 03:55
Make PHP's `array_map()` behave more like JavaScript.
<?php
/**
* Make PHP `array_map()` more like JavaScript.
*
* - Reverse paramaters so array comes first, callback second.
* - Include index as second argument to callback.
*
* @param array $arr
* @param function $callback
@tannerhodges
tannerhodges / Search my gists.md
Created May 21, 2019 15:13 — forked from santisbon/Search my gists.md
How to search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files. language:html

# https://help.github.com/articles/ignoring-files
# https://github.com/github/gitignore
#=================#
# Compiled source #
#=================#
*.class
*.dll
*.exe
*.o
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Diff Example</title>
</head>
<body>
<h1>Diff Example</h1>

Declarative Component Mapping Syntax Options

Language / Prior Art ‘Valid’ HTML HTML Mapping Example Example with Args
‘Valid’ CSS Selectable CSS Mapping CSS Select CSS Selector w Args
JavaScript MooTools Multiple instance Separate Args new Foo(element); new Bar(element) new Foo(element, {a:"a", bB:"b B", c:{c:1}}); new Bar(element, {d:"d"})
HTML attr Dojo <1.6 NO
1 Element per instance
@tannerhodges
tannerhodges / encoding-video.md
Created September 26, 2018 03:12 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus