Skip to content

Instantly share code, notes, and snippets.

View alexcarpenter's full-sized avatar
:shipit:

Alex Carpenter alexcarpenter

:shipit:
View GitHub Profile
import * as React from 'react';
const useIsFirstRender = (): boolean => {
const isFirst = React.useRef(true);
if (isFirst.current) {
isFirst.current = false;
return true;
} else {
@ffdead
ffdead / WistiaEmbed.js
Created November 2, 2020 09:43
React component for Wistia embed
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import classNames from 'classnames/bind'
import s from './WistiaEmbed.module.scss'
const cn = classNames.bind(s)
const WistiaEmbed = ({ id, play = false, style, options }) => {
// const el = useRef()
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
function html(strings, ...interpolations) {
return strings
.map((string, i) => {
let value = interpolations[i];
// 0 is falsy but a valid value in HTML
if (value === undefined || value === null || value === false) {
value = "";
}
// join arrays so they aren't stringified with commas
if (Array.isArray(value)) {
@Andy-set-studio
Andy-set-studio / global.js
Created June 11, 2019 19:43
Cache busting with 11ty (stick global.js in _data folder)
module.exports = {
random() {
const segment = () => {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
return `${segment()}-${segment()}-${segment()}`;
}
};
@Andy-set-studio
Andy-set-studio / .eleventy.js
Last active August 20, 2018 19:35
Eleventy sort by order
const sortByOrder = require('./sort-by-order.js');
module.exports = function(eleventyConfig) {
eleventyConfig.addFilter('sortByOrder', sortByOrder);
}
{# @var craft \craft\web\twig\variables\CraftVariable #}
{# @var entry \craft\elements\Entry #}
{#
Language Switcher
------------------------------------------------------------
{% import '_partials/macros/_macro-languageSwitcher.html' as macroLanguageSwitcher %}
{{ macroLanguageSwitcher.languageSwitcher({
sites: ['siteA', 'siteB']
@croxton
croxton / pipeline.yml
Last active July 13, 2023 01:00
Buddy.works Craft 3 Atomic deployments
- pipeline: "Build and deploy to [environment]"
trigger_mode: "MANUAL"
ref_name: "master"
actions:
- action: "Execute: gulp build"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "6"
execute_commands:
- "npm install"
@shelldandy
shelldandy / typekit.html
Last active April 27, 2018 15:25
Master Race Typekit Solution by Glen Maddern
<head>
<script>
if (window.localStorage && window.localStorage._tk_cache) {
document.documentElement.classList.add('wf-active');
var script = document.createElement('script');
script.innerHTML = localStorage._tk_cache + ";(function () {var timeout = setTimeout(function () {document.documentElement.classList.remove('wf-active');}, 300); Typekit.load({ async: false, active: function () { clearTimeout(timeout); }});})();";
document.head.appendChild(script);
}
window._tk_onload = function () {
var req = new XMLHttpRequest()
@keithjgrant
keithjgrant / abp-twitter.txt
Last active August 31, 2023 20:48
Adblock plus filters to remove the crap from twitter
twitter.com##.module.trends
twitter.com##.wtf-module
twitter.com##[data-component-context="suggest_activity_tweet"]
twitter.com##.nav>.moments
twitter.com##.LiveVideoHomePageModuleContainer