Skip to content

Instantly share code, notes, and snippets.

@jeromecoupe
jeromecoupe / deploy.yaml
Last active August 2, 2023 16:41
Github actions: build and deploy Craft sites (WIP)
name: Craft CMS deployments
on:
push:
branches: [master]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active June 9, 2024 19:08
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@adactio
adactio / minimal-serviceworker.js
Last active August 18, 2023 09:15
An attempt at a minimal viable service worker.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
// HTML files: try the network first, then the cache.
// Other files: try the cache first, then the network.
// Both: cache a fresh version if possible.
// (beware: the cache will grow and grow; there's no cleanup)
const cacheName = 'files';
@jeffposnick
jeffposnick / app.js
Created October 5, 2017 20:06
Example of staleWhileRevalidate + broadcastCacheUpdate
const HN_URL = 'https://hackernewsapi.example.com/';
function updateUI(hnData) {
// Update the DOM.
}
async function init() {
const channel = new BroadcastChannel('hn-updates');
channel.addEventListener('message', async (event) => {
if (event.data.payload.updatedUrl === HN_URL) {
@mirisuzanne
mirisuzanne / SassMeister-input.scss
Created October 3, 2014 15:37
Susy: nested grid classes
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// Susy (v2.1.3)
// ----
@import "susy";
@include layout(12);
@klickgists
klickgists / TWIG: Date conditional
Created August 15, 2013 18:41
Check dates from entries against current date. For use with #craft CMS.
{% if date >= entry.start|date('Y-m-d') and date < entry.end|date('Y-m-d') %}
<p>current</p>
{% elseif date < entry.start|date('Y-m-d') %}
<p>future</p>
{% elseif date > entry.end|date('Y-m-d') %}
<p>past</p>
{% endif %}
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/