Skip to content

Instantly share code, notes, and snippets.

View aleclarson's full-sized avatar

Alec Larson aleclarson

View GitHub Profile
var e=e=>"function"==typeof e,t=()=>{},s=DEV&&"undefined"!=typeof __OBSERVABLE_HOOKS__&&__OBSERVABLE_HOOKS__,r=e=>e._value,i=1,h=1,o=r,n=Symbol.for("alien:refType"),u=class{constructor(e){this._value=e,this._version=0,this._observers=new Set}get _depth(){return 0}_isObserved(e,t){DEV&&s&&s.isObserved(this,e,t),t?this._observers.add(e):this._observers.delete(e)}get[n](){return"ReadonlyRef"}get value(){return o(this)}get version(){return this._version}peek(){return this._value}},d=class extends u{get[n](){return"Ref"}get value(){return super.value}set value(e){const t=this._value;e!==t&&(this._value=e,this._version=i,this._observers.forEach((s=>{s.observe(this,e,t)})),h===i&&O()&&(h++,Promise.resolve().then(y)))}set(t){return e(t)&&(t=t(this._value)),this.value=t,t}},a=Object.getOwnPropertyDescriptor(d.prototype,"value");Object.defineProperties(d.prototype,{0:a,1:{get(){return this.set.bind(this)}},[Symbol.iterator]:{value:function*(){yield this[0],yield this[1]}}});var v=Symbol("empty"),l=class extends u{const
@aleclarson
aleclarson / required-nesting-selector.js
Last active February 22, 2023 07:32
Add missing & prefix to nested CSS rules that start with identifiers
// https://github.com/w3c/csswg-drafts/issues/7980#issuecomment-1378047080
const stylelint = require("stylelint");
const parseSelector = require("postcss-selector-parser");
const t = parseSelector;
const ruleName = "alloc/required-nesting-selector";
const messages = stylelint.utils.ruleMessages(ruleName, {
expected: selector => `Expected "& ${selector}"`,
});
@aleclarson
aleclarson / .socket+vscode.md
Last active October 6, 2023 20:58
Socket SDK + VSCode
@aleclarson
aleclarson / +seoul256.md
Last active December 16, 2022 18:59
Seoul256 dark theme – Visual Studio Code
const MagicString = require('magic-string');
const assert = require('assert');
const kleur = require('kleur');
function test() {
const s1 = new MagicString('abcde');
const s2 = s1.clone();
const desiredResult = 'abxcde';
import { route } from 'saus'
// Default route
route(() => import('./routes/UnknownPage'))
// Catch route
route('error', () => import('./routes/ErrorPage'))
//
// Matched routes
const reservedChars = /[\r\n,"]/
module.exports = function toCSV(header, rows) {
rows = rows.map(row => row.map(valueToString).join(','))
return [header.join(','), ...rows].join('\r\n') + '\r\n'
}
function valueToString(value) {
return value === undefined
? ''
// Adapted from: https://digitalbunker.dev/2020/09/13/understanding-gaussian-blurs/
function gaussianBlurMatrix(blurRadius: number) {
if (blurRadius !== Math.round(blurRadius) || blurRadius <= 0) {
throw Error('Blur radius must be a positive integer')
}
const kernel: number[] = []
const kernelWidth = 1 + 2 * blurRadius
const kernelSize = kernelWidth * kernelWidth
// Adapted from https://github.com/lukeed/escalade/blob/2477005/src/sync.js
import { dirname, join } from 'path'
import { readdirSync } from 'fs'
/**
* Search each parent directory until a string or false is returned.
*/
export function findFile(
dir: string,
callback: (names: string[], dir: string) => string | false | undefined
@aleclarson
aleclarson / .indo.json
Last active April 13, 2021 16:29
Gist for indo test suite
{
"repos": {
"mixpa": {
"url": "https://github.com/aleclarson/mixpa"
}
}
}