Skip to content

Instantly share code, notes, and snippets.

View kossnocorp's full-sized avatar
Shipping

Sasha Koss kossnocorp

Shipping
View GitHub Profile
"C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto
@kossnocorp
kossnocorp / buildFunctions.ts
Created October 28, 2020 11:46
My Firebase Functions esbuild setup
import { build } from 'estrella'
import fs from 'fs'
import { promisify } from 'util'
import packageJSON from '../package.json'
import listFunctions from './_lib/listFunctions'
const writeFile = promisify(fs.writeFile)
const external = Object.keys(packageJSON.dependencies)
const appEnv = process.env.APP_ENV
const rootPath = process.cwd()
@kossnocorp
kossnocorp / usePromise.ts
Last active April 28, 2022 04:28
Promise hooks
import { useEffect, useMemo, useRef } from 'preact/hooks'
/**
* The {@link usePromise} resolve function.
*/
export type UsePromiseResolve<Type> = (value: Type) => void
/**
* The {@link usePromise} reject function.
*/
@kossnocorp
kossnocorp / useEvent.ts
Created March 24, 2022 12:07
Preact event/dispatch hook
import { useEffect } from 'preact/hooks'
/**
* Generates an event hook / dispatch function pair for the given payload.
*
* @returns the hook and dispatch functions
*/
export function createEventHooks<Payload>() {
const { useEvent, dispatchEvent } = createEventsHooks()
const event = Date.now().toString()
@kossnocorp
kossnocorp / cypress.ts
Last active October 19, 2021 09:47
Solve Jest/Cypress conflict when using with Testing Library by using these custom wrappers:
/**
* The code is based on Gleb Bahmutov's [local-cypress](https://github.com/bahmutov/local-cypress).
*/
/// <reference types="cypress" />
/// <reference types="@testing-library/cypress" />
const win = window as unknown as Window & {
assert: Chai.AssertStatic
expect: Chai.ExpectStatic
@kossnocorp
kossnocorp / module.ts
Last active November 5, 2020 07:09
Source code with an example of hoisting usage
import {
defaultNumberingPosition,
defaultNumberingStyle,
NumberingFormatOptions,
NumberingPosition,
NumberingStyle,
} from '#app/core/split/parse'
export function stripNumbering(
text: string,
@kossnocorp
kossnocorp / v2-pre-releases.md
Last active October 19, 2020 11:33
date-fns v2 pre-releases change log
"————————————————————————————————————————————————————————————————————————————————————————————————————————————————————"
" Full colors reset
"————————————————————————————————————————————————————————————————————————————————————————————————————————————————————"
" Base colors
hi ColorColumn guifg=#000000 guibg=#ffffff gui=none ctermfg=16 ctermbg=231 cterm=none
hi Conceal guifg=#000000 guibg=#ffffff gui=none ctermfg=16 ctermbg=231 cterm=none
hi Cursor guifg=#000000 guibg=#ffffff gui=none ctermfg=16 ctermbg=231 cterm=none
hi CursorIM guifg=#000000 guibg=#ffffff gui=none ctermfg=16 ctermbg=231 cterm=none
var errorsStash = []
var errorListener = function(e) {
errorsStash.push(e.error)
}
var unhandledRejectionListener = function(e) {
errorsStash.push(e.reason)
}
window.addEventListener('error', errorListener)
window.addEventListener('unhandledrejection', unhandledRejectionListener)
window.__passOnToSentry__ = function() {
@kossnocorp
kossnocorp / Makefile
Last active October 13, 2019 05:44
Demo of the problem for a Stack Overflow questions
SHELL := /bin/bash
PATH := $(shell yarn bin):$(PATH)
test:
which ts-node
${shell yarn bin}/ts-node --version
ts-node --version