Skip to content

Instantly share code, notes, and snippets.

View lunelson's full-sized avatar
👀
Reading

Lu Nelson lunelson

👀
Reading
View GitHub Profile
@lunelson
lunelson / core-rules-v1.md
Created March 1, 2025 16:30
Drafts for core rules to constrain and focus over-eager/-confident LLMs like Claude Sonnet 3.7

SYSTEM PROMPT: AGENTIC CODING ASSISTANT PROTOCOL

FOUNDATIONAL PRINCIPLE: INTENT PRIMACY

User intent is the absolute guiding principle that supersedes all other considerations. Understanding this intent fully, correctly, and completely is the first and most critical responsibility in every interaction.

INTENT UNDERSTANDING PROTOCOL

1. INTENT EXTRACTION AND VALIDATION

@lunelson
lunelson / input.scss
Created July 3, 2021 16:16
Generated by SassMeister.com.
@use 'sass:string';
@use 'sass:meta';
@function var-if($cond-var, $true-val, $false-val) {
$id: string.unique-id();
@return string.unquote('var(--#{$id}, #{$false-val}); --#{$id}: var(#{$cond-var}) #{$true-val}');
}
@function var-toggle($bool) {
@return if($bool, string.unquote('/*!*/ /*!*/'), initial);
@lunelson
lunelson / use-datocms-listener.js
Last active May 15, 2021 13:36
Refresh Next.js server/static props on DatoCMS update
import { useEffect, useRef, useState } from 'react';
import { subscribeToQuery } from 'datocms-listen';
import { useRouter } from 'next/router';
import { reporter } from '../utils';
/*
references for this technique of using router.replace
- https://www.joshwcomeau.com/nextjs/refreshing-server-side-props/
- https://twitter.com/flybayer/status/1333081016995622914
@lunelson
lunelson / codeswing.json
Last active March 31, 2021 15:31
menu-layout-testing
{
"scripts": [],
"styles": []
}
@lunelson
lunelson / App.jsx
Last active March 20, 2021 23:59
react-hook-use-slot
function createSlot() {
const Slot = ({ children }) => children;
const getSlot = (children) =>
React.Children.toArray(children).find((child) => child.type === Slot) ||
null;
return [Slot, getSlot];
}
function createSlots(n) {
const SlotSets = Array(n)
@lunelson
lunelson / codeswing.json
Last active January 17, 2021 09:51
test swing
{"scripts": [],"showConsole": true}
@lunelson
lunelson / input.scss
Created November 7, 2020 20:51
Generated by SassMeister.com.
@use 'sass:math';
@use 'sass:list';
@use 'sass:map';
$theme: (
breakpoints: (
s: 20em, // 320 px alt: 20,30,45,60,75,90
m: 32em, // 512 px
ml: 48em, // 768 px
l: 64em, // 1024 px
@lunelson
lunelson / usage-yn.js
Created December 1, 2019 12:12
Usage of npm package "yn"
const yn = require('yn');
function confirm(message, callback) {
process.stdin.setEncoding('utf8');
process.stdin.resume();
process.stdout.write(`Confirm: ${message} [Y]`);
process.stdin.once('data', function(data) {
var ok = yn(data) || data.trim() == '';
try { callback(ok); } catch (e) { throw new Error(e); }
process.stdin.pause();
@lunelson
lunelson / sync-to-frames.js
Created August 15, 2019 09:30
Pattern for syncing rapid events to the AF loop
function syncToFrames(el, eventName, frameCB, postFrameCB) {
let active = false;
function deactivate() { active = false; }
function activate() {
if (!active) {
setTimeout(onPostFrame);
requestAnimationFrame(onFrame);