Skip to content

Instantly share code, notes, and snippets.

View nikolaswise's full-sized avatar
🌵

Nikolas Wise nikolaswise

🌵
View GitHub Profile
@nikolaswise
nikolaswise / jsonld2nodelinkarrays.js
Created March 29, 2024 12:25
Take a JSON-LD object and cast it into two arrays, one of nodes and one of links, for rendering with a D3 network visualization.
const fn = (jsonLD, linkType) => {
let nodes = jsonLD['@graph']
.filter(n => n)
.map(n => {
n.level = 0
return n
})
let connections = subjects["@graph"].map(node => {
return {
@nikolaswise
nikolaswise / html2jsonld.js
Created March 29, 2024 12:07
Given a directory of html, extract all the RDFa statements and write a JSON-LD file.
import fs from 'fs'
import path from 'path'
import { JSDOM } from 'jsdom'
// https://gist.github.com/nikolaswise/d3c9cc914f1168bdf244cdc797c64eb8
import { rdfa2json } from './rdfa2json.js'
let origin = process.env.origin
global.DOMParser = new JSDOM().window.DOMParser
const handleError = (err) => {
@nikolaswise
nikolaswise / rdfa2json.js
Created March 29, 2024 12:06
Given a string pf HTML and a URI, extract simple RDFa microdata into JSON
const arrayify = target => Array.isArray(target) ? target : [target]
export const rdfa2json = (htmlString, uri) => {
const parser = new DOMParser()
let html = parser
.parseFromString(htmlString, "text/html")
const propertyNodes = [...html.querySelectorAll('[property]')]
let predicates = propertyNodes
.map(node => {
@nikolaswise
nikolaswise / mdsm.js
Created August 4, 2020 15:11
Plugin for MarkdownIt (https://github.com/markdown-it/markdown-it) that turns markdown image syntax into Figure tags with syntax for responsive image sizes via lazysizes: https://afarkas.github.io/lazysizes/index.html, http://afarkas.github.io/lazysizes/rias/
const splitCDN = (uri) => {
let imgArr = uri.split('/')
let filename = imgArr.pop()
let size = imgArr.pop()
let base = imgArr.join('/')
return { base, size, filename }
}
const getCDNBase = (uri) => {
let { base } = splitCDN(uri)

SmugMug Design System

Homework for Michal

Color:

Color Name Color Hex Value
Green #6EB801
Light Green #81D600
@nikolaswise
nikolaswise / event-delegator.js
Last active March 2, 2020 16:50
this delegates events!
// 🎄🐊.js
// Advent Alligator, the Event Delegator
let delegations = new Map();
const noop = () => {}
const delegate = (node, action) => (e) => {
delegations[node]
.filter(del => del.action === action)
| CMS        | Link                        | Cloud |  Price |
| ---------- | --------------------------- | ----- | ------ |
| Contentful | https://www.contentful.com/ | Yes   |  39$/m |
| Cockpit    | https://getcockpit.com/     | No    |     $0 |
| Directus   | https://docs.directus.io    | No    |     $0 |
| Photon     | https://photoncms.com/      | No    |   $300 | 
| Ghost      | https://docs.ghost.org/     | No    |     $0 | 
| Strapi     | https://strapi.io/          | No    |     $0 | 
| Wordpress | https://wordpress.org/ | No | $0 |

7014D0000002J0WQAU
background-image: url('/map/Fish_Pin_Blue.png');

701F0000000B9oQIAS
background-image: url('./map/School_Pin_Blue.png');

701F0000000AmZrIAK
background-image: url('./map/Crane_Pin_Blue.png');

7010G000000vtMkQAI

const item = item => `
<div class="cart-item">
<a href="#" class="cart-icon-remove js-remove-from-cart"
data-remove="${item.id}">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="icon icon-close"><path fill="#444" d="M15.89 14.696l-4.734-4.734 4.717-4.717c.4-.4.37-1.085-.03-1.485s-1.085-.43-1.485-.03L9.641 8.447 4.97 3.776c-.4-.4-1.085-.37-1.485.03s-.43 1.085-.03 1.485l4.671 4.671-4.688 4.688c-.4.4-.37 1.085.03 1.485s1.085.43 1.485.03l4.688-4.687 4.734 4.734c.4.4 1.085.37 1.485-.03s.43-1.085.03-1.485z"/></svg>
</a>
<img class="cart-preview" src="${item.image}" alt="${item.product_title}" />
<div class="cart-item-description">
<p>${item.product_title}</p>
<p>
@nikolaswise
nikolaswise / cart.js
Created August 30, 2018 23:23
This is the cartjs from Weezie
import $ from 'jquery'
import {bus} from '../helpers/bus.js'
import * as template from '../templates/cart.js'
const render = (cart = window.Cart.cart, item) => {
template.confirm(item)
template.count(cart.item_count)
template.items(cart.items)
template.totals(cart.total_price)
bus.emit('cart:bind')