Skip to content

Instantly share code, notes, and snippets.

View FredKSchott's full-sized avatar

Fred K. Schott FredKSchott

View GitHub Profile
@FredKSchott
FredKSchott / als.mjs
Created February 22, 2023 22:03 — forked from cyco130/als.mjs
AsyncLocalStorage-based Node server framework
import { createServer } from "node:http";
import { AsyncLocalStorage } from "node:async_hooks";
const asyncLocalStorage = new AsyncLocalStorage();
createServer((req, res) => {
asyncLocalStorage.run({ req, res }, () => {
asyncHandler().catch((err) => {
console.error(err);
if (!res.writableEnded) {
@FredKSchott
FredKSchott / shiki-ssr-issue.astro
Last active November 10, 2022 00:24
shiki ssr issue
---
import { Code } from "astro/components";
---
<!-- This breaks when deployed to Vercel! -->
<Code lang="ts" code={`// Test`} />
@FredKSchott
FredKSchott / 1-draft-proposal.js
Last active March 3, 2022 18:54
integrations api draft
export default function createPlugin(options) {
return {
// Hook into different events:
name: 'my-plugin-name',
hooks: {
'config:setup': ({ config, command, injectScript, injectHtml }) => {},
'config:done': ({ config, command, injectScript, injectHtml }) => {},
'serve:setup': ({ server }) => {},
'serve:start': ({ port }) => {},
'serve:done': ({}) => {},
@FredKSchott
FredKSchott / GoogleFont.astro
Created January 28, 2022 02:16
A font component for Astro
---
import {writeFile} from 'node:fs/promises';
export interface Props {
font: string;
weight?: string[];
}
const {font, weight} = Astro.props as Props;
let familyValue = font;
if (weight) {
@FredKSchott
FredKSchott / 20210612.md
Last active June 17, 2021 18:46
Astro User Research

Astro User Research - 06/12/2021

I joined Salma (@whitep4nth3r) on their livestream and helped them use Astro for the first time. Below are my notes on the experience.

Video

https://www.twitch.tv/videos/1054128448

Notes

  1. process.env works inside of astro files. We should probably turn that into a warning somehow to use import.meta.env instead.

Before Running Tests:

  • For faster testing, modify test-workspace.ts to only run tests on one browser, like -l chrome

Before Running Push/Publish:

  • Change all 3.0.0-pre.X versions in dependency-map.json to the new version so that its picked up in all package.json files

Running Push/Publish:

First Command - Base Elements

@FredKSchott
FredKSchott / shelljs-build-task.js
Created August 21, 2014 19:14
Creating a Build Task - ShellJS Recipes - http://shelljs-recipes.tumblr.com/
require('shelljs/make');
target.lint = function() {
// see: http://shelljs-recipes.tumblr.com/post/94832587846/javascript-validation-with-eslint
// linting used her for example, can really be anything
echo('Validating JavaScript');
exec('node ./node_modules/eslint/bin/eslint ' + JS_FILES);
}
// To run: node make lint
@FredKSchott
FredKSchott / shelljs-mocha-nyan.js
Last active August 29, 2015 14:05
Running Javascript Tests (with Nyan Cat) - ShellJS Recipes - http://shelljs-recipes.tumblr.com/
// Dependencies: mocha (http://visionmedia.github.io/mocha/)
echo('Running Tests');
exec('node ./node_modules/mocha/bin/_mocha -R nyan --recursive ' + TEST_DIR);
// 380 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_,------,
// 0 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_| /\_/\
// 0 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-^|__( ^ .^)
// _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- "" ""
//
// 380 passing (2s)
@FredKSchott
FredKSchott / shelljs-mocha.js
Last active August 29, 2015 14:05
Running Tests with Mocha - ShellJS Recipes - http://shelljs-recipes.tumblr.com/
// Dependencies: mocha (http://visionmedia.github.io/mocha/)
echo('Running Tests');
exec('node ./node_modules/mocha/bin/_mocha --recursive' + TEST_DIR);
@FredKSchott
FredKSchott / shelljs-files-recently-changed.js
Created August 21, 2014 15:33
Getting Recently Changed Files - ShellJS Recipes - http://shelljs-recipes.tumblr.com/
// dependencies: a git repo
var CHANGED_FILES = exec('git diff --name-only master..HEAD').output.replace(/\n/g,' ');