Skip to content

Instantly share code, notes, and snippets.

View colinfwren's full-sized avatar

Colin Wren colinfwren

View GitHub Profile
@colinfwren
colinfwren / reversePowerTimeSig.js
Created October 25, 2022 05:29
reverse power time signature resolve
export function getTimeSignatureinSemiQuavers(timeSignature: MidiTimeSignatureEvent): TimeSignatureValues {
const { numerator, denominator } = timeSignature
const deltaFromSemiQuaver = 4 - denominator
if (deltaFromSemiQuaver > 0) {
return Array(deltaFromSemiQuaver).fill(0).reduce((agg) => {
return {
numerator: agg.numerator * 2,
denominator: agg.denominator * 2
}
}, { numerator, denominator: 2**denominator })
@colinfwren
colinfwren / gatsby-config.js
Created September 21, 2022 22:00
Gatsby config to include GIFs
// a lot of config removed for brevity
module.exports = {
plugins: [
{
resolve: `@lekoarts/gatsby-theme-minimal-blog`,
options: {
mdx: false,
}
},
@colinfwren
colinfwren / converting-posts-directory.js
Last active September 21, 2022 21:21
Script to convert posts directory
import {read} from 'to-vfile'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'
import { writeFile, promises as fs } from 'fs'
import {toHtml} from "hast-util-to-html"
import frontmatter from 'remark-frontmatter'
import path from 'path'
@colinfwren
colinfwren / clean-up-output.js
Created September 21, 2022 21:07
Clean up the Markdown output
import {read} from 'to-vfile'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'
import {visit} from "unist-util-visit";
function removeMediumExtras() {
return (tree) => {
const article = tree.children.find(x => x.tagName === 'article')
@colinfwren
colinfwren / download-convert-gists.js
Created September 21, 2022 20:43
Download and convert embedded gist code from Medium export
import fetch from 'node-fetch'
import {read} from 'to-vfile'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'
import { selectAll } from "hast-util-select";
import {toHtml} from "hast-util-to-html";
async function downloadGistCode(url) {
@colinfwren
colinfwren / download-convert-figure.js
Created September 21, 2022 20:11
Download and convert figure elements in Medium export
import fetch from 'node-fetch'
import {read} from 'to-vfile'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'
import { writeFile, promises as fs } from 'fs'
import { selectAll } from "hast-util-select";
import {toHtml} from "hast-util-to-html";
import path from 'path'
@colinfwren
colinfwren / process-frontmatter.js
Created September 20, 2022 23:01
Process Medium export to create frontmatter for post in Gatsby
import { read } from 'to-vfile'
import { unified } from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'
import frontmatter from 'remark-frontmatter'
import slugify from 'slugify'
function gatherFrontmatterData() {
return async (tree, file) => {
@colinfwren
colinfwren / convert-medium-posts.js
Last active September 21, 2022 21:18
A script to convert Medium export into Markdown usable by Gatsby
import fetch from 'node-fetch'
import {read} from 'to-vfile'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'
import { writeFile, promises as fs } from 'fs'
import { selectAll } from "hast-util-select";
import {toHtml} from "hast-util-to-html";
import slugify from "slugify";
@colinfwren
colinfwren / retool-sentry-issues.js
Created May 8, 2022 19:46
Retool Sentry Issues
return data.map((issue) => {
return {
title: issue.title,
count: issue.count,
culprit: issue.culprit,
url: issue.permalink,
level: issue.level,
ref: issue.shortId
}
})
@colinfwren
colinfwren / retool-posthog-funnel.js
Last active May 8, 2022 19:45
Retool PostHog Funnel
return data.results[0].result.map((step) => {
return {
key: step.name,
value: step.count
}
})