Skip to content

Instantly share code, notes, and snippets.

@wkentdag
wkentdag / richTextFields.ts
Last active December 6, 2024 23:40
Lexical rich text field for PayloadCMS with custom HTML conversion
import {
consolidateHTMLConverters,
convertLexicalToHTML,
lexicalEditor,
sanitizeEditorConfig,
} from '@payloadcms/richtext-lexical'
import { createHash } from 'crypto'
import stringify from 'json-stable-stringify'
import { SerializedEditorState } from 'lexical'
import { FieldBase, RichTextField, TextField } from 'payload/types'
import { createHeadlessEditor } from '@lexical/headless'
import {
EditorConfig,
getEnabledNodes,
sanitizeEditorConfig,
} from '@payloadcms/richtext-lexical'
import { $getRoot, SerializedRootNode } from 'lexical'
import { Validate } from 'payload/types'
import { simple } from '../config/lexical'
@wkentdag
wkentdag / feature.ts
Created September 27, 2024 17:59
DisableAutoLinkFeature WIP
import { FeatureProvider } from '@payloadcms/richtext-lexical'
export const DisableAutoLinkFeature = (): FeatureProvider => {
return {
key: 'disable-auto-link',
feature: () => {
return {
props: null,
plugins: [
{
1. erell ranson - if we never try (sw amnesia interpretation) [kalahari oyster cult]
2. george t - force majeure [honchos]
3. junkie sartre - you can turn it on [decore]
4. russ gabriel - bossatronic [freshstart]
5. halo varga - in da groove [ng trax]
6. souldoubt - haunted house [surreal]
7. skee mask - trackheadz [ilian tape]
8. bandulu - long count [foundation sound]
9. bandulu - repercussions [foundation sound]
10. dj sports - akrasia (central mix) [help]

Debugging Memory Issues in Node

This guide summarizes some helpful strategies and resources encountered while debugging memory usage in the hashicorp/learn repository.

Diagnosing memory issues

In JS, memory issues occur when old objects aren't garbage collected, and pile up on the heap. We can observe the issue by noting performance degradation over time, or by maxing out memory within a single program.

Typically memory issues are discovered because performance slows down. You might also encounter this fun error if your program runs out of memory:

@wkentdag
wkentdag / README.md
Last active August 20, 2019 21:33
make commands for installing and exporting fb keyframes for designers

Installation

  1. Download and install the Keyframes Player application.
  2. Download our custom install script to your desktop. It should be saved as install-keyframes.sh.
  3. Open the Terminal application (inside your /Applications folder - it might be under the Applications/Utilities subdirectory)
  4. Type sh ~/Desktop/install-keyframes.sh, and hit enter in order to install the Keyframes extension and its dependencies.
    1. At some point the script will ask permission to install Xcode Tools. Say yes.
    2. At some point it will ask you to enter your password. When you type it in, the characters will not display for security reasons. So type carefully, and then hit enter. If you mistype, it will ask you again.
  5. Some error messages and warnings may appear.
@wkentdag
wkentdag / serialize.js
Created October 22, 2016 02:10
serialize an object into a query string
const serialize = (params) => {
let whitelist = ['category', 'order', 'search', 'number']
return (!params) ? '' : '?' + Object.keys(params)
.filter(p => whitelist.includes(p))
.map(p => `${p}=${params[p]}&`)
.reduce((p, c) => p + c)
.slice(0, -1)
}
@wkentdag
wkentdag / dd_vs_community_20161010121137.txt
Created October 10, 2016 20:00
full install log for msvs
This file has been truncated, but you can view the full file.
[17E8:1B4C][2016-10-10T12:11:36]i001: Burn v3.7.4906.0, Windows v10.0 (Build 14393: Service Pack 0), path: C:\Users\will\AppData\Local\Temp\{8FD4FD17-D36B-45A1-88F3-6C7580B36C40}\vs_community.exe, cmdline: '/ChainingPackage ct3!!a6ae4dbe0137be43afb0291c5d53530f-ct!!4A7F21E333A544F990406B9347064B63'
[17E8:1B4C][2016-10-10T12:11:36]i000: Initializing string variable 'SKUFriendlyName' to value 'VS Community'
[17E8:1B4C][2016-10-10T12:11:36]i000: Initializing numeric variable 'SKUFriendlyID' to value '1800'
[17E8:1B4C][2016-10-10T12:11:36]i000: Initializing string variable 'ExtraEditionDisplayName' to value '#loc.slipstream'
[17E8:1B4C][2016-10-10T12:11:36]i000: Initializing string variable 'EditionDisplayName' to value 'Community 2015'
[17E8:1B4C][2016-10-10T12:11:36]i000: Initializing string variable 'SKUFullName' to value 'vs_community_SlipStream_3'
[17E8:1B4C][2016-10-10T12:11:36]i000: Initializing numeric variable 'VSUpdateGeneralVersion' to value '3'
[17E8:1B4C][2016-10-10T12:11:36]i000: Initializing string
@wkentdag
wkentdag / childpx-snip.md
Created October 2, 2016 00:48
good way to call child processes inside a node script

elegantly call child processes within node

const node = require('when/node')
const {exec} = require('child_process')
const tplTestPath = path.join(__dirname, 'example')

function npmInstall (dir) {
  return node.call(exec, 'npm install', { cwd: dir })
}
let relevant = ['ID', 'author', 'date', 'modified', 'title', 'URL', 'content', 'excerpt', 'slug', 'status', 'type', 'comment_count', 'featured_image', 'tags', 'categories', 'attachments']
return Object.keys(post).filter(prop => relevant.includes(prop)).map(prop => {
switch (prop) {
case 'foo':
break
default:
console.log(prop)