Skip to content

Instantly share code, notes, and snippets.

View johndigital's full-sized avatar

John Robson johndigital

View GitHub Profile
import linkResolver from './linkResolver'
import prismicDOM from 'prismic-dom'
const Elements = prismicDOM.RichText.Elements
// https://prismic.io/docs/vuejs/getting-started/prismic-nuxt
export default function (type, element, content, children) {
// Generate links to Prismic Documents as <router-link> components
// Present by default, it is recommended to keep this
if (type === Elements.hyperlink) {
<template>
<div class="scrolling-layout">
<!-- This is just an 800vh spacer,
it ensures the page is tall
enough to scroll -->
<div class="spacer" />
<!-- This is the actual content that gets scrolled.
It is position fixed and the "scrolling" is done
with transforms -->
<template>
<div class="shared-gradient-playground">
<fragment-shader :uniforms="uniforms" :timescale="60">
<script type="shader/fragment">
precision highp float;
uniform vec2 uResolution;
uniform float uTime;
uniform vec3 color1;
uniform vec3 color2;
uniform vec3 color3;

Keybase proof

I hereby claim:

  • I am johndigital on github.
  • I am johndigital (https://keybase.io/johndigital) on keybase.
  • I have a public key ASCOkHYF0Viv9M_3T0SuPYJg5fKss09ugqDP2ineqQM3KAo

To claim this, I am signing this object:

/*
home.js
--
This script takes the JSON data from the home page for posts and tweets and
randomly displays them into a randomly selected template which is then
Variables from Home HTML:
@johndigital
johndigital / kMeans.js
Last active November 1, 2017 23:04
K-Means strategy for finding groups of related posts in a blog
const distance = require( 'compute-cosine-distance' )
const _ = require('lodash')
// helper to average an array of vectors
// down to a single vector
const average = points => {
return _.range(points[0].length).map(dim => {
return _.mean(points.map(p => p[dim]))
})
}
@johndigital
johndigital / naiveSort.js
Last active November 1, 2017 22:42
"Naive" Solution for finding related posts on a blog
const _ = require('lodash')
const tokenize = string => {
return string.split(' ').map(w => {
return w.trim().toLowerCase().replace(/[^a-zA-Z]/g, '')
}).filter(w => w)
}
const similarPosts = (posts, targetPost) => {
@johndigital
johndigital / functions.php
Last active March 29, 2016 18:29
Move metadata from one Wordpress site to another (quick and dirty)
<?php
// Add this to the functions.php file of the SENDING site
function fh_export_page_metadata(){
$post = get_post();
// change this to target site URL
$target_site = 'http://www.example-site.com';
// add 'run' to URL query string to run this
@johndigital
johndigital / vimeo-oembed.php
Last active June 16, 2016 22:22
Override Wordpress oembed defaults for Vimeo
<?php
/*
* Override default vimeo oembed behavior
*/
function set_vimeo_defaults(){
// set vimeo oembed args
// see full list here: developer.vimeo.com/apis/oembed
$args = array(