Skip to content

Instantly share code, notes, and snippets.

@argyleink
argyleink / easings.css
Created February 26, 2018 22:34
Handy CSS properties for easing functions
:root {
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
@jonathantneal
jonathantneal / sanitizeDOM.js
Last active February 25, 2019 13:50
Sanitize a document or element using a whitelisted selectors and whitelisted attributes
// sanitize an element using a whitelisted selector string
function sanitizeDOM(ELEMENT, WHITELISTED_SELECTORS, WHITELISTED_ATTRIBUTES) {
// get all elements within an ELEMENT
Array.prototype.forEach.call(ELEMENT.querySelectorAll('*'), node => {
// if the element does not match a WHITELIST_SELECTOR_STRING
if (!node.matches(WHITELISTED_SELECTORS)) {
// create a new document fragment
const fragment = document.createDocumentFragment();
// append all the children of the invalid node into the new fragment
@AdaRoseCannon
AdaRoseCannon / HTMLElementPlus.js
Last active March 3, 2023 11:33
HTML Element Plus for Web Components
'use strict';
class HTMLElementPlus extends HTMLElement {
static defaultAttributeValue() {
/* the name of the attribute is parsed in as a parameter */
return;
}
static parseAttributeValue(name, value) {
@Heydon
Heydon / observe.js
Last active December 18, 2020 11:52
// Elements with `data-observe` toggle `data-visible`
// between `true` and `false`
if ('IntersectionObserver' in window) {
const callback = (entries, observer) => {
entries.forEach(entry => {
entry.target.setAttribute('data-visible', entry.isIntersecting)
})
}
@phproberto
phproberto / explanation.md
Created October 27, 2017 11:54
Dummy router for Jooma Blank Component causing no 404 pages

Reproduce the issue:

  • You have Blank Component assigned to the home page of your Joomla! site.
  • When you manually enter a wrong url you don't get any 404 error. Your site redirects all the non-existing urls to the home page.

Explanation

Joomla redirects all the non-existing urls to the router of the component assigned as home page. Blank component does not have a router so you just get redirected to the home page.

This is a dummy empty router that will force an empty option be set if the component router is called to parse any url. This should not break anything because Blank Component cannot work without a menu item assigned to it. It only ensures that the router does not parse any url.

@mirhec
mirhec / raspi-setup-gitea.md
Created September 20, 2017 07:14
Installing Gitea on Raspberry Pi with nginx, SSL and automatic backups

Setup Gitea on Raspberry Pi (3)

These instructions are based on this article: https://www.alexruf.net/2016/05/23/setup-gogs-git-service.html.

Setup Raspberry Pi with minimal Raspbian image. You need to connect to the HDMI port and set the following:

sudo raspi-config

There you need to enable the SSH server and you should change the hostname.

@troyfontaine
troyfontaine / 1-setup.md
Last active April 15, 2025 22:02
Signing your Git Commits on MacOS

Methods of Signing Git Commits on MacOS

Last updated March 13, 2024

This Gist explains how to sign commits using gpg in a step-by-step fashion. Previously, krypt.co was heavily mentioned, but I've only recently learned they were acquired by Akamai and no longer update their previous free products. Those mentions have been removed.

Additionally, 1Password now supports signing Git commits with SSH keys and makes it pretty easy-plus you can easily configure Git Tower to use it for both signing and ssh.

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing your commits with GPG.

/**
* A simple theme for reveal.js presentations, similar
* to the default theme. The accent color is darkblue.
*
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
*
* Modified version of simple.scss by Axel Rauschmayer
*/
@import url(https://fonts.googleapis.com/css?family=Lato:400,700);
@samthor
samthor / safari-nomodule.js
Last active March 17, 2025 18:03
Safari 10.1 `nomodule` support
// UPDATE: In 2023, you should probably stop using this! The narrow version of Safari that
// does not support `nomodule` is probably not being used anywhere. The code below is left
// for posterity.
/**
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
* load <script nomodule> anyway. This snippet solve this problem, but only for script
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
*
* Again: this will **not** prevent inline script, e.g.: