Skip to content

Instantly share code, notes, and snippets.

View hasparus's full-sized avatar

Piotr Monwid-Olechnowicz hasparus

View GitHub Profile
@hasparus
hasparus / README.md
Last active August 19, 2024 18:34
A color scheme for Windows Terminal

👨‍🎤 Cyberpunk SCARLET for Windows Terminal

screenshot of terminal presenting colors and borg cowsay saying "Hello!"

profile settings in screenshot

  "colorScheme": "Cyberpunk SCARLET",
  "cursorHeight": 25,
 "cursorShape": "vintage",
@hasparus
hasparus / windows-auto-darkmode.ps1
Last active April 20, 2024 17:39
A PowerShell script setting light mode during the day and dark mode after 18:30.
# Set your triggers to 06:00, log in, and 18:30.
# Set this to false if you like light Windows UI.
# Personally, I'm conflicted so I change it back and forth every few months.
$SYSTEM_ALWAYS_DARK = $TRUE
$lightTheme = @{ AppsUseLightTheme = 1; SystemUsesLightTheme = 1 }
$darkTheme = @{ AppsUseLightTheme = 0; SystemUsesLightTheme = 0 }
# We set light mode between 06:00 and 18:30.
@hasparus
hasparus / @changesets__assemble-release-plan@5.2.3.patch
Last active August 31, 2023 13:06
a bit wasteful CI/CD setup with PR snapshot release and automerged Changesets on main
diff --git a/dist/assemble-release-plan.cjs.dev.js b/dist/assemble-release-plan.cjs.dev.js
index 3a37c62c975518f975c22e1b4b3974d9b325a5da..cc7b4669526b9ccddcf184f52f8cb5225cc8284e 100644
--- a/dist/assemble-release-plan.cjs.dev.js
+++ b/dist/assemble-release-plan.cjs.dev.js
@@ -132,16 +132,38 @@ function determineDependents({
} of dependencyVersionRanges) {
if (nextRelease.type === "none") {
continue;
- } else if (shouldBumpMajor({
- dependent,
import { ReactRenderer, StoryObj } from '@storybook/react'
import { ComponentAnnotations } from '@storybook/types'
import { describeStories } from './tiniest-storybook-test-suites'
import * as stories from './MyComponent.stories'
describeStories(stories)
// @ts-ignore
import GatsbyParser from "gatsby/dist/query/file-parser";
import path from "path";
import glob from "glob";
/**
* Collect all graphql fragments from a directory
* @see https://github.com/gatsbyjs/gatsby/issues/12155#issuecomment-618424527
*/
export const collectGraphQLFragments = async (
// TypeScript Playground: https://tsplay.dev/mq8eYN
/// <reference types="@types/jest" />
import type { MatcherState } from 'expect';
const matchers = {
toHaveWordsCount(this: MatcherState, sentence: string, wordsCount: number) {
// implementation redacted
},
@hasparus
hasparus / match.ts
Last active August 15, 2022 01:30
lightweight sum type matching in typescript
interface A { type: 'A', a: 10 };
interface B { type: 'B', b: [11] };
type AB = A | B;
type TypeOf<T extends { type: any }> = T extends { type: infer Type } ? Type : never;
type Cases<T extends { type: any }, R> = {
[P in TypeOf<T>]: (val: Extract<T, { type: P }>) => R
}
@hasparus
hasparus / Microsoft.Powershell_profile.ps1
Last active May 26, 2022 17:13
A guide on setting up on new laptops for future me, and a manifest of all the tools I installed.
# Git Completions
Import-Module posh-git
# Prompt
Invoke-Expression (&starship init powershell)
# Aliases
Set-Alias g git
# Utils
@hasparus
hasparus / generator.ts
Last active April 27, 2022 08:12
freebooter-generator/lib
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// generator.js
// written and released to the public domain by drow <drow@bin.sh>
// http://creativecommons.org/publicdomain/zero/1.0/
// Adapted and rewritten to TypeScript by hasparus <hasparus@gmail.com>
// - used PRNG instead of Math.random
// - added context and `ctx -> text` functions
import { random } from "./random";
@hasparus
hasparus / #All Stories Actually Render the Component.md
Last active April 22, 2022 10:26
ensure all stories render the component they describe

It's easy to overlook that your component stories stopped working after changes to the component source. If we're not reusing our stories in unit tests and thus ensure they still work on CI in every Pull Request, we need to remember to check them during code review.

When you're hotfixing a production bug you have more serious concerns than not breaking the docs. That's understandable. Every app I worked on that used Storybook eventually had some broken stories. Fixing them lands at the bottom of the backlog; they're just some component examples and those components work on production now! You're going to do it only if you actually need those stories.