Skip to content

Instantly share code, notes, and snippets.

View tylerbrostrom's full-sized avatar

Tyler Brostrom tylerbrostrom

View GitHub Profile
@benpate
benpate / template-fragments.go
Last active August 7, 2025 16:19
Demonstration of Template Fragments using the standard Go template library
package main
import (
"html/template"
"net/http"
"strconv"
)
/***********************
This is a simple demonstration of how to use the built-in template package in Go to implement
@kentcdodds
kentcdodds / cachified.ts
Last active April 19, 2023 04:54
Turn any function into a cachified one. With forceFresh support and value checking (for when the data type changes). This uses redis, but you could change it to use whatever you want.
type CacheMetadata = {
createdTime: number
maxAge: number | null
expires: number | null
}
function shouldRefresh(metadata: CacheMetadata) {
if (metadata.maxAge) {
return Date.now() > metadata.createdTime + metadata.maxAge
}

Route Module Pending Component Export

There are two primary approaches to page transitions (ignoring suspense's ditched attempt at a third)

  1. Indefinitely wait on the old screen
  2. Transition immediately to spinners/skeleton

Right now Remix has picked #1, but with a new export to a route module, we could support both.

Today, if you have this, Remix will wait for all data to load before displaying the page

@monachilada
monachilada / gatsby-config.js
Last active October 16, 2020 19:03
Sample gatsby-config.js enabling live preview in Craft CMS
const { createHttpLink } = require('apollo-link-http');
const fetch = require('node-fetch');
const store = require('store');
const sourceNodes = require('gatsby/dist/utils/source-nodes');
require('dotenv').config();
const craftGqlUrl = process.env.CRAFT_GQL_URL;
const craftGqlToken = process.env.CRAFT_GQL_TOKEN;
module.exports = {
@marcveens
marcveens / NetlifyCmsConfig.ts
Last active February 28, 2023 12:09
Typescript used to generate a Netlify CMS config.yml
// See https://www.marcveens.nl/netlify-cms-generate-config-yml
// https://www.netlifycms.org/docs/configuration-options/
type PublishMode = 'simple' | 'editorial_workflow';
type ExtensionType = 'yml' | 'yaml' | 'toml' | 'json' | 'md' | 'markdown' | 'html';
type FormatType = 'yml' | 'yaml' | 'toml' | 'json' | 'frontmatter' | 'yaml-frontmatter' | 'toml-frontmatter' | 'json-frontmatter';
type WidgetType = 'boolean' | 'date' | 'datetime' | 'file' | 'hidden' | 'image'
| 'list' | 'map' | 'markdown' | 'number' | 'object' | 'relation'
| 'select' | 'string' | 'text' | string;
type MapType = 'Point' | 'LineString' | 'Polygon';
@jakub-g
jakub-g / double-fetch-triple-fetch.md
Last active April 13, 2024 12:22
Will it double-fetch? Browser behavior with `module` / `nomodule` scripts
@jgeschwendt
jgeschwendt / GoogleExample.php
Created October 24, 2018 16:02
Extending CraftQL with External Resources
<?php
namespace modules;
use Craft;
use markhuot\CraftQL;
use yii\base\Event;
const GOOGLE_API_KEY = 'YOUR_GOOGLE_API_KEY';
class Module extends \yii\base\Module
@andrewdelprete
andrewdelprete / webpack.config.js
Last active April 12, 2023 01:55
Webpack: Tailwind CSS + PurgeCSS Example
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const path = require("path");
const glob = require("glob-all");
const PurgecssPlugin = require("purgecss-webpack-plugin");
/**
* Custom PurgeCSS Extractor
* https://github.com/FullHuman/purgecss
* https://github.com/FullHuman/purgecss-webpack-plugin
*/