This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<--- Last few GCs ---> | |
[31642:0x7f9d20008000] 105486 ms: Mark-sweep 4036.6 (4130.1) -> 4029.6 (4136.2) MB, 4756.1 / 0.1 ms (average mu = 0.356, current mu = 0.022) allocation failure scavenge might not succeed | |
[31642:0x7f9d20008000] 110156 ms: Mark-sweep 4045.6 (4136.4) -> 4038.4 (4144.9) MB, 4559.2 / 0.1 ms (average mu = 0.223, current mu = 0.024) allocation failure scavenge might not succeed | |
<--- JS stacktrace ---> | |
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory | |
1: 0x1040ea3a5 node::Abort() (.cold.1) [/Users/kentcdodds/n/bin/node] | |
2: 0x102dc5869 node::Abort() [/Users/kentcdodds/n/bin/node] | |
3: 0x102dc59df node::OnFatalError(char const*, char const*) [/Users/kentcdodds/n/bin/node] | |
4: 0x102f44347 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/kentcdodds/n/bin/node] | |
5: 0x102f442e3 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/kentcdodds/n/bin/node] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Menu: New Post | |
// Description: Create a new blog post | |
// Author: Kent C. Dodds | |
// Shortcut: command option control p | |
// Twitter: @kentcdodds | |
const dateFns = await npm('date-fns') | |
const prettier = await npm('prettier') | |
const YAML = await npm('yaml') | |
const slugify = await npm('@sindresorhus/slugify') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require('make-fetch-happen').defaults({ | |
cacheManager: './node_modules/.cache/make-fetch-happen', | |
}) | |
// add a .env file that has this in it: | |
// CONVERT_KIT_API_KEY=some_api_key | |
// CONVERT_KIT_API_SECRET=some_api_secret | |
require('dotenv').config() | |
const {CONVERT_KIT_API_KEY, CONVERT_KIT_API_SECRET} = process.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getMostPopularPostSlugs({ | |
limit, | |
exclude, | |
}: { | |
limit: number | |
exclude: Array<string> | |
}) { | |
const result = await prisma.postRead.groupBy({ | |
by: ['postSlug'], | |
_count: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CacheMetadata = { | |
createdTime: number | |
maxAge: number | null | |
expires: number | null | |
} | |
function shouldRefresh(metadata: CacheMetadata) { | |
if (metadata.maxAge) { | |
return Date.now() > metadata.createdTime + metadata.maxAge | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Menu: Daily Story | |
// Description: Write a quick story | |
// Author: Kent C. Dodds | |
// Shortcut: command option control o | |
// Twitter: @kentcdodds | |
const dateFns = await npm('date-fns') | |
const filenamify = await npm('filenamify') | |
const prettier = await npm('prettier') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {typedBoolean} from './misc' | |
function headerValuesAsObject(headerValue: string) { | |
const valuesAsObject: Record<string, string> = Object.fromEntries( | |
headerValue | |
.split(', ') | |
.filter(h => h.includes('=')) | |
.map(h => { | |
const [key, valueString] = h.split('=') | |
if (!valueString) return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unified = require('unified') | |
const parseMarkdown = require('remark-parse') | |
const parseHtml = require('rehype-parse') | |
const remark2rehype = require('remark-rehype') | |
const rehype2remark = require('rehype-remark') | |
const rehypeStringify = require('rehype-stringify') | |
const visit = require('unist-util-visit') | |
async function go() { | |
const inputString = ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Menu: ConvertKit > Lookup | |
// Description: Query convertkit | |
// Author: Kent C. Dodds | |
// Twitter: @kentcdodds | |
const CONVERT_KIT_API_SECRET = await env('CONVERT_KIT_API_SECRET') | |
const CONVERT_KIT_API_KEY = await env('CONVERT_KIT_API_KEY') | |
const query = await arg('query') | |
let url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react' | |
import type {LoaderFunction, ActionFunction} from 'remix' | |
import {json, redirect, useRouteData, Form} from 'remix' | |
type LoaderData = {} | |
export const loader: LoaderFunction = async () => { | |
const data: LoaderData = {} | |
return json(data) | |
} |