Skip to content

Instantly share code, notes, and snippets.

View andyjessop's full-sized avatar

Andy Jessop andyjessop

View GitHub Profile
@andyjessop
andyjessop / customisation.css
Last active February 22, 2023 13:02
Definition and usage of a custom element that creates equal spaces between child elements
cx-space {
--cx-space-gap-small: 2rem;
--cx-space-gap-default: 2.5rem;
--cx-space-gap-large: 5rem;
}
@andyjessop
andyjessop / component.ts
Last active March 13, 2023 08:05
Ant.d's Space component in CSS
import { spaced } from '@crux/design/styles';
...
html`
<div class=${cx(spaced.container, spaced.vertical, spaced.small)}>
<div>1</div>
<div>2</div>
<div>3</div>
</div>`;
import { cx } from './cx';
describe('classes', () => {
describe('cx', () => {
test('cx should combine class names', () => {
const result = cx('class1', { class2: true }, null, undefined, 'class3');
expect(result).toBe('class1 class2 class3');
});
@andyjessop
andyjessop / RouterLink.ts
Last active May 20, 2025 17:08
Link custom element to handle route changes in thepassle/app-tools router
@andyjessop
andyjessop / prompt.md
Last active February 16, 2024 20:08
Web Component Prompt

Web Component Development Prompt

Overview

Create a web component following best practices for architectural and stylistic elements. The component should be implemented using the lit library, with particular attention to accessibility, customisability, and reusability.

Objectives

  • The component must be fully functional, encapsulating all logic and styles necessary for its operation.
  • Implement static styles using css imported from lit, ensuring all CSS properties are exposed as custom properties on the host element for easy styling customisation.
  • Define slots and CSS parts to allow users to customise the content and style of different component parts.
  • Ensure the component is accessible, including proper ARIA attributes and roles where necessary.
@andyjessop
andyjessop / RandomizedSet.go
Last active February 29, 2024 15:39
An implementation of the RandomizedSet class
type RandomizedSet struct {
Entries map[int]bool
Values []int
Indexes map[int]int
}
func Constructor() *RandomizedSet {
return &RandomizedSet{Entries: make(map[int]bool), Indexes: make(map[int]int)}
}
@andyjessop
andyjessop / worker.ts
Last active March 7, 2024 20:30
Cloudflare Worker Auth
import { Hono } from 'hono';
import { jwt } from 'hono/jwt';
import { D1 } from '@cloudflare/workers-types';
import { hash, compare } from 'bcrypt';
import { v4 as uuidv4 } from 'uuid';
import { sendEmail } from './email';
import { isEmail, sanitize } from 'validator';
import { createHash } from 'crypto';
type Env = {
@andyjessop
andyjessop / neurflow.md
Created March 8, 2024 09:17
NeurFlow concept

NeurFlow Documentation

Introduction

NeurFlow is a revolutionary new programming language for building complex, dynamic, and reactive user interfaces. Inspired by the structure and function of neural networks, NeurFlow allows you to define your application as a network of interconnected "neurons".

Core Concepts

Neurons

@andyjessop
andyjessop / prompt.txt
Last active March 14, 2024 12:14
A prompt that gives an LLM knowledge of the file structure of a repo
Between the <list> and </list> markers are a list of files in this repo. However, in order to make them shorter, they have been compressed in the following way:
- each file path token (excluding final filename) has been swapped with a short version, and then added to a map.
- the shortened version is inserted into the file path instead of the original token.
For example:
this/is/the/file/path/for/test.ts
this/is/another/path/for/another.ts
@andyjessop
andyjessop / concatenate.ts
Created March 27, 2024 14:33
Concatenate files in folder
import * as fs from "fs";
import * as path from "path";
function readFileContents(filePath: string): string {
return fs.readFileSync(filePath, "utf-8");
}
function processDirectory(dirPath: string, outputString: string): string {
const files = fs.readdirSync(dirPath);