Skip to content

Instantly share code, notes, and snippets.

Avatar

Piotr Monwid-Olechnowicz hasparus

View GitHub Profile
@hasparus
hasparus / Microsoft.Powershell_profile.ps1
Last active Jun 23, 2021
A guide on setting up on new laptops for future me, and a manifest of all the tools I installed.
View Microsoft.Powershell_profile.ps1
# Git Completions
Import-Module posh-git
# Prompt
Invoke-Expression (&starship init powershell)
# Aliases
Set-Alias g git
Set-Alias y yarn
View going-too-far-with-matchers-type.ts
// 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
},
View examples-auth-db.tsx
// Imagine that @prisma/client is a normal library and it doesn't have different types in userspace and libraries
import {GetEvents, LogDefinition, LogLevel, PrismaClient, PrismaClientOptions} from "@prisma/client"
import {exec} from "child_process"
interface EnhancedPrismaClient<
// TypeScript doesn't have higher (i.e. * -> * -> *) order types, so
// we can't use anything like ConstructorParameters<typeof PrismaClient>,
// because ConstructorParameter will "strip" generics.
//
// The only way to preserve generic parameters is to copy them.
View collectGraphQLFragments.ts
// @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 (
@hasparus
hasparus / print-readme.yml
Created Jul 7, 2020
Print GitHub readme to PDF with Pandoc
View print-readme.yml
name: Print readme to PDF
on:
push:
paths: ['readme.md', '.github/workflows/print-readme.yml']
jobs:
make_pdf:
runs-on: ubuntu-18.04
@hasparus
hasparus / lazy-avatar-nextjs.ts
Created Mar 30, 2020
avatar = facebook || tinygraphs
View lazy-avatar-nextjs.ts
import { NextApiResponse, NextApiRequest } from "next";
import fetch from "isomorphic-unfetch";
export default async function avatar(
req: NextApiRequest,
res: NextApiResponse
) {
const {
query: { username_slug },
} = req;
View cloudSettings
{"lastUpload":"2020-02-13T08:01:14.026Z","extensionVersion":"v3.4.3"}
@hasparus
hasparus / README.md
Last active Jun 29, 2020
A color scheme for Windows Terminal
View README.md

👨‍🎤 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 / wrots-r3f.md
Last active Feb 11, 2020
talk idea for the February Wrocław TypeScript meetup
View wrots-r3f.md

Title: Case Study: Helping with TypeScript problems of react-three-fiber.

Dan Questions:

  • How will you deliver the idea to the audience?

    • R3F is pretty rad. Gonna show this on the first slide.
  • What is the one thing that you want people to take away from your talk?

    • Compiler API is powerful. We can use this power to hard solve problems.