Skip to content

Instantly share code, notes, and snippets.

View its-monotype's full-sized avatar
😃

its-monotype

😃
  • Earth
View GitHub Profile
@bitterteasweetorange
bitterteasweetorange / keybindings.json
Last active September 9, 2024 13:49
setup vscode like neovim
[
{
"command": "projectManager.listGitProjects#sideBarGit",
"key": "cmd+o"
},
{
"command": "expand_region",
"key": "ctrl+=",
"when": "editorTextFocus"
},
@palashmon
palashmon / Prettify.ts
Created May 13, 2023 16:11
A super useful type helper in TypeScript by Matt Pocock from Twitter
/**
* A TypeScript type alias called `Prettify`.
* It takes a type as its argument and returns a new type that has the same properties as the original type,
* but the properties are not intersected. This means that the new type is easier to read and understand.
*/
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
@levvsha
levvsha / useOnClickOutside.ts
Created May 9, 2023 12:44
useOnClickOutside react hook with TypeScript
function useOnClickOutside(
ref: React.RefObject<HTMLDivElement>,
handler: (event: TouchEvent | MouseEvent) => void,
) {
useEffect(() => {
const listener = (event: TouchEvent | MouseEvent) => {
if (!ref.current || ref.current.contains(event.target as HTMLElement)) {
return;
}
handler(event);
@martinratinaud
martinratinaud / .gitconfig
Last active August 24, 2023 07:06
Awesome Git Configuration
[alias]
# shortcuts
c = commit
co = checkout
cp = cherry-pick
f = fetch
# enhancements
d = diff -- ':!package-lock.json' ':!yarn.lock' # Do not show lock files when diffing
ds = diff --staged -- ':!package-lock.json' ':!yarn.lock' # Do not show lock files when diffing staged files
@bennettdams
bennettdams / zod-empty-string-undefined-optional.ts
Last active July 24, 2024 09:15
Zod empty string transformed to `undefined` including handling optional
import { z } from 'zod'
const emptyStringToUndefined = z.literal('').transform(() => undefined)
/**
* Provide a schema and get a schema that is optional and empty strings are transformed to `undefined`.
* When someone removes his input of this field, the then empty string is transformed to `undefined`.
*
* Example:
*
@HughParsons
HughParsons / forwardRefHOC.tsx
Created September 9, 2022 00:04
React HOC (higher order component) with forwardRef
import * as React from 'react'
export function HOC<T, P extends {}>(
Component: React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>
): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>> {
return React.forwardRef<T, P>(
function ComponentFromHOC(props, ref) {
return (
<Component {...props as React.PropsWithoutRef<P>} ref={ref} />
);
@Zekfad
Zekfad / conventional-commits.md
Last active September 17, 2024 12:37
Conventional Commits Cheatsheet

Quick examples

  • feat: new feature
  • fix(scope): bug in scope
  • feat!: breaking change / feat(scope)!: rework API
  • chore(deps): update dependencies

Commit types

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Changes which doesn't change source code or tests e.g. changes to the build process, auxiliary tools, libraries
@vtenq
vtenq / git-workflow.md
Last active September 2, 2024 16:54
Git workflow with conventional commits and semantic auto release

Git workflow with conventional commits and semantic auto release

This is an adoptation of Git flow by Vincent Driessen with conventional commits and semantic release.

The main concepts

At the core, the development model is greatly inspired by existing models out there. The central repo holds two main branches with an infinite lifetime:

@dusekdan
dusekdan / window_helper.py
Created March 15, 2019 16:59
Snippet of python code to help working with Windows under win32gui.
import win32gui
import re
class WindowMgr:
"""Encapsulates some calls to the winapi for window management"""
def __init__ (self):
"""Constructor"""
self._handle = None
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active September 20, 2024 15:32
Conventional Commits Cheatsheet

Conventional Commit Messages

See how a minor change to your commit message style can make a difference.

Tip

Have a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default