Skip to content

Instantly share code, notes, and snippets.

@dfee
dfee / node.test.ts
Created July 27, 2022 01:22
building and traversing a tree using fp-ts
import {
Lineage,
Node,
getSubtreeByLineage,
treeFromLineageArray,
walkTreeDepthFirst,
} from "../node";
describe("Node", () => {
const LINEAGE_ARRAY_FIXTURE: ReadonlyArray<Lineage> = [
import startServer from "verdaccio";
const PORT = 4873
const STORAGE = "./storage";
const CONFIG = {
storage: STORAGE,
uplinks: {
"npmjs": {
"url": "https://registry.npmjs.org/"
}
import startServer from "verdaccio";
const PORT = 4873
const STORAGE = "./storage";
const CONFIG = {
storage: STORAGE,
uplinks: {
"npmjs": {
"url": "https://registry.npmjs.org/"
}
@dfee
dfee / machine.js
Last active August 12, 2021 18:44
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dfee
dfee / main.js
Created March 18, 2021 01:51
Storybook config for TailwindCss 2.0
// <root>/.storybook/main.js
const cssRe = /\.css$/;
const removeCssRule = (config) =>
(config.module.rules = config.module.rules.filter(
(rule) => String(rule.test) !== String(cssRe),
));
module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
type IsolationOptions = {
entityManager?: EntityManager<IDatabaseDriver<Connection>>;
flush?: boolean;
};
@Injectable()
export class UsersService {
constructor(
private readonly _entityManager: EntityManager<IDatabaseDriver<Connection>>,
) {}
@dfee
dfee / integration.test.ts
Last active August 8, 2020 08:07
Example of auto-rollback transactions with Mikro-Orm for testing
import {
Connection,
EntityManager,
IDatabaseDriver,
MikroORM,
} from "@mikro-orm/core";
import { PostgreSqlDriver } from "@mikro-orm/postgresql";
import { getConfig } from "../config";
import { UserEntity } from "../entities";
import { AnyEntity, Property, PropertyOptions } from "@mikro-orm/core";
import { TimestampType } from "./types";
export type DecoratorType = (
target: AnyEntity<unknown>,
propertyName: string,
) => void;
export type ConcretePropertyOptions<T> = Omit<PropertyOptions<T>, "columnType">;
import {
CommandLineChoiceParameter,
CommandLineFlagParameter,
CommandLineStringParameter,
} from "@rushstack/ts-command-line";
import { DeployManager } from "../../logic/deploy/DeployManager";
import { RushCommandLineParser } from "../RushCommandLineParser";
import { BaseRushAction } from "./BaseRushAction";