Skip to content

Instantly share code, notes, and snippets.

View johnpuddephatt's full-sized avatar

John Puddephatt johnpuddephatt

View GitHub Profile
Alpine.directive('typed', (el, { expression, modifiers }, { evaluateLater, effect, cleanup }) => {
const getStrings = evaluateLater(expression);
const modifierValue = (key, fallback) => {
if (-1 === modifiers.indexOf(key)) {
return fallback;
}
const value = modifiers[modifiers.indexOf(key) + 1];
@forresto
forresto / tiptap-lite-youtube.ts
Last active February 25, 2024 18:24
tiptap-lite-youtube node type
// Registers the lite-youtube custom element
import "@justinribeiro/lite-youtube";
import { Node, mergeAttributes } from "@tiptap/core";
import { Plugin, PluginKey } from "prosemirror-state";
// Captures the YouTube ID as the first matching group.
// Vendored 2021-10-07 from https://github.com/micnews/youtube-url/blob/master/index.js
const youtubeRegExp =
/^(?:(?:https?:)?\/\/)?(?:www\.)?(?:m\.)?(?:youtu(?:be)?\.com\/(?:v\/|embed\/|watch(?:\/|\?v=))|youtu\.be\/)((?:\w|-){11})(?:\S+)?$/;
@jelleroorda
jelleroorda / TrailingNode.js
Last active July 1, 2023 16:14
Trailing node extension for TipTap 2
import { Extension } from '@tiptap/core'
import { PluginKey, Plugin } from 'prosemirror-state';
function nodeEqualsType({ types, node }) {
return (Array.isArray(types) && types.includes(node.type)) || node.type === types
}
/**
* Extension based on:
* - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js
@isuke01
isuke01 / wp-rewrite.php
Last active June 28, 2023 14:27
Change wordpress blog poss rewrite rules
<?php
/*
|--------------------------------------------------------------------------
| Fix for blog links
|--------------------------------------------------------------------------
| Add post type before single post name (fix post link on backend)
*/
function fix_blog_links($post_link, $post, $leavename) {
if($post->post_status === 'draft') return $post_link;
// assets/scripts/customizer.js
(function($) {
// Primary colour
wp.customize('primary_colour', function(value) {
value.bind(function(to) {
$('head').append('<style>.Primary-bg-c{background-color:'+ to +' !important;}</style>');
$('head').append('<style>.Primary-c{color:'+ to +' !important;}</style>');
$('head').append('<style>.Primary-c--hover:hover{color:'+ to +' !important;}</style>');
@dreampuf
dreampuf / graphit.sh
Created July 31, 2013 10:51
Creating requests per time graph from nginx or apache access log.
#!/bin/bash
# Origianl version : http://www.keepthingssimple.net/2012/10/creating-requests-per-time-graph-from-nginx-or-apache-access-log/
# This version is a port to Mac OSX
# dreampuf (http://huangx.in)
# useage :
# graphit.sh logfile.log
# open result-2013-06-04.png
@brendo
brendo / EventTutorial.md
Created April 4, 2011 11:06
Symphony Events: A Detailed Look

Forms have been an integral part of any interactive site since the dawn of time, they promote interactivity and are usually the most common way users interact with a site. It's commonplace that when a form is submitted, the website will take 'action' and do something with the data and then provide a user with the result. Symphony provides this logic layer via Events.

This tutorial assumes you have a basic understanding of how Events work in Symphony (if not, this may be a good introduction) and are semi comfortable writing some PHP code. I'll be showing you some of the lesser known features of Symphony Events, including event priority, event chaining and a brief demonstration of how to write a custom Event. The difficulty level progresses as we go through, but with any luck you'll be able to learn a thing or two :)

Getting Started

The Scenario

Our client requires a form that allows a user to submit some details about their new car purchase. Th