Skip to content

Instantly share code, notes, and snippets.

import {words as _words} from "popular-english-words";
let words = _words.getAll();
//let words = _words.getMostPopular(100000);
let set = new Set(words);
function findSmallestRoot(word, path=null) {
if (!path) {
path = [word];
}

Codex

Current find & replace features work well for names and single-line patterns that happen to map well to regular expressions. For more complex manipulations, something more comprehensive and purpose-built is needed.

In this article I introduce Codex, a flexible and expressive language for specifying code modifications.

Codex works like traditional find & replace, but with some extensions to make dealing with multiple lines and indentation intuitive, and to allow matching language-specific syntax elements with Tree-sitter queries.

Find expressions

let app = getContext("app");
let {
tabs,
selectedTab,
} = app;
function select({detail: tab}) {
app.selectTab(tab);
}
@gushogg-blake
gushogg-blake / call-for-cofounders.md
Last active March 16, 2022 08:49
Call for co-founders

Call for co-founders: a new platform for technical documentation

Hi, I'm working on ways to improve documentation and explanatory tutorials for software projects. The proposition is to make it easier for both newcomers and seasoned programmers to learn new tools and build up a coherent picture of how complex, interconnected systems fit together.

I'm currently looking for someone to co-found and submit a Y Combinator application with, so if this sounds interesting to you please reach out and introduce yourself (email below). This document details where the project is so far, how we might work together, and roughly what the next few milestones might look like.

Immediate goal

@gushogg-blake
gushogg-blake / entrypoints.md
Last active May 20, 2022 16:19
A proposal for // ENTRYPOINT comments to indicate where a project connects to the outside world

Entrypoints

This is a proposal to adopt the use of // ENTRYPOINT comments next to a program's top-level entrypoints, such as the main function, event handlers, and network listeners.

The idea is to allow new contributors and curious readers to quickly gain an overview of the project's main functions in a way that's easy to understand, and for the entrypoints to act as sensible starting points (and helpful mental anchor points) for further exploration.

The presence of ENTRYPOINT comments should allow the reader to quickly begin to answer questions like what does this program do? (provided the main function is sufficiently readable); what happens when I press a key?; and how does this program respond to network requests?.

Tooling

Spacer elements

When I used to look at a design I would feel a kind of anxiety about how to implement the gaps. I would try to answer the question which element should this gap be a margin of?, and there was often no logically-justifiable answer. I recently came to the realisation that gaps don't have to be margins, and it's completely lifted that feeling of anxiety and refreshed how I look at designs. With a combination of spacer elements and gap, the question simply doesn't come up any more, and the process of translating a design to a first draft of the markup is almost effortless.

Now, instead of trying to decide which element to attach a margin to, I just look at a design and write what I see:

<div id="header">
 SomeText

Open source project: Create Rollup plugin to generate static site from Svelte/Markdown files

Hi! The goal of this project is to create a static site generator system based on Rollup and Svelte - like Jekyll but for the JS ecosystem.

I'm looking for someone with significant experience developing Rollup plugins and working with Svelte, or frontend experience and an ability to quickly get up to speed with both of these.

Similar to how Jekyll and other static site generators work, this plugin(s) will take a bunch of pages as input and create a ready-to-serve folder of HTML, JavaScript, and CSS files as output.

The project should integrate nicely with the existing Svelte and Rollup ecosystem - $ rollup -c should compile everything for prod and $ rollup -cw should compile for dev with the ability to use rollup-plugin-live-reload etc. Prod and dev files should be output to separate dirs.

let Parser = require("tree-sitter");
let HTML = require("tree-sitter-html");
let parser = new Parser();
parser.setLanguage(HTML);
let code = dedent(`
<!doctype html>
<html>
#include <stdio.h>
int main() {
int arr[] = { 3, 4, 2, 1, 5, 6 };
int winter_high[6] = { NULL };
int overall_high[6] = { NULL };
int j,k;
function nextIncreasingValues(array) {
let nivs = [];
for (let i = array.length - 1; i >= 0; i--) {
let currentNumber = array[i];
let niv;
if (i === array.length - 1) {
// the last element always has a NIV of -1
niv = -1;