Skip to content

Instantly share code, notes, and snippets.

View scvnc's full-sized avatar

Vincent Schramer scvnc

View GitHub Profile
@scvnc
scvnc / useNavigationGuard.ts
Created March 20, 2026 20:29
A pattern to DRY up your 'You have unsaved changes, are you sure you'd like to navigate away' checks.
// This is a gist to describe the concept and not a full working example.
// Use this hook to signal to the app that you would like to block navigation when your form is dirty
useNavigationGuard(form.isDirty, {
message: "Your work hasn't been saved. Are you sure you want to continue?",
cancel: 'Go Back',
proceed: 'Continue without saving'
})
@scvnc
scvnc / mfe.ts
Created March 20, 2026 20:18
General pattern for exposing a microfrontend with vue3 (and vite/vueuse) + shadowDOM
import { createApp } from "vue";
import { createEventHook, useEventBus } from "@vueuse/core";
import { CSS_KEY } from "./const";
import {MfeWidget} from "./mfe-widget";
export const mount = (element: Element) => {
var app = createApp(MfeWidget);
if (!element) {
@scvnc
scvnc / INVENTIONS.md
Created March 20, 2026 16:22
Inventions

{Placeholder}

@scvnc
scvnc / StubFieldComponent.ts
Created October 23, 2023 17:07
A way of stubbing out VeeValidate form field
/**
* Stub out the component with this
*/
export const StubFieldComponent = {
props: ["name"],
setup: (props: { name: string }): unknown => {
if (props.name === undefined) {
throw new Error("did not recv props!");
}
const field = useField<unknown>(props.name);
@scvnc
scvnc / normalize-markdown-headers.js
Created October 9, 2023 17:48
Hacktacular script that quashes markdown headers to their highest size, with header-2 being the largest
const fs = require('fs');
// Check if a Markdown file is provided as a command-line argument
const filePath = process.argv[2];
if (!filePath) {
console.error('Please provide a Markdown file as a command-line argument.');
process.exit(1);
}
@scvnc
scvnc / async-itr-vue.ts
Created May 26, 2023 14:55
Fiddle with async iterable or other @bufbuild/connect-web vue binding
import { ConnectError } from '@bufbuild/connect-web';
import { Ref, ref } from 'vue';
const useStreamingCall = <T>(controllerFn: StreamingCallController<T>) => {
const currentData = ref<T | undefined>(); // todo: optionally not make undefined
const cancel = controllerFn(
(data: T) => {
currentData.value = data;
// do something with data
@scvnc
scvnc / REVIEW.MD
Last active April 21, 2023 00:13
Video notes on "Vue NYC - Component Tests with Vue.js - Matt O'Connell"
@scvnc
scvnc / YourApp.ce.vue
Created April 17, 2023 21:44
How to register plugins on a vue CE. You likely will have have to modify accordingly to make compatible for other plugins.
<script setup lang="ts">
import { useCeVueApp } from './useCeVueApp';
import PrimeVue from 'primevue/config'
useCeVueApp(app => {
app.use(PrimeVue);
});
</script>
title Communication Policy
description
published 1
date 2020-03-30 13:35:21 UTC
tags

Communication Policy

@scvnc
scvnc / search_for_faker.js
Created March 27, 2023 15:32
Have chatGPT make a util that detects whether a javascript module eventually imports @faker-js/faker
import fs from 'fs';
import path from 'path';
import * as acorn from 'acorn';
import * as walk from 'acorn-walk';
const getRelativeModuleFilePath = (
moduleFilePath: string,
adjacentModulePath: string
): string | false => {
const adjacentModuleFilePath = path.join(path.dirname(moduleFilePath), adjacentModulePath);