This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import produce from 'immer'; | |
import { Action, useRegisterActions } from 'kbar'; | |
import { FC, useMemo, useState } from "react"; | |
interface IDemoProps { } | |
const Demo: FC<IDemoProps> = () => { | |
const [counter, setCounter] = useState( 0 ) | |
const [recentActions, setRecentActions] = useState<Record<string, number>>( {} ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createStore from 'zustand' | |
type HistoryStore<T> = { | |
present: T | |
past: T[] | |
future: T[] | |
undo: () => void | |
redo: () => void | |
reset: (present: T | ((data: T) => T)) => void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { match, Pattern } from 'ts-pattern' | |
/** | |
* Returns an element of the array matching given pattern or `null` | |
*/ | |
export const find = <T>(data: T[], query: Pattern<T>): T | undefined => | |
data | |
.find(item => | |
match(item) | |
.with(query, () => true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
const useHistory = <T>( initialValue: T[] = [] ) => { | |
const [isDirty, setIsDirty] = useState( false ); | |
const [step, setStep] = useState( 0 ); | |
const [history, setHistory] = useState<T[]>( initialValue ); | |
useEffect( () => { | |
console.log( { | |
isDirty, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const genericButton = document.querySelector('[type="submit"]') | |
const password_input = document.querySelector('[type="password"]') | |
const button = document.createElement('button') | |
button.setAttribute('type', 'button') | |
button.innerText = 'Show Password' | |
button.style = "margin-top: 5px;" | |
if ( genericButton ) { | |
button.setAttribute('class', genericButton.getAttribute('class')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn parse_markdown_link(_str_with_link: String) -> String { | |
let chars = _str_with_link.chars(); | |
let mut is_text = false; | |
let mut is_url = false; | |
let mut text : String = String::new(); | |
let mut url : String = String::new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
TEXT_DIM="\e[2m" | |
TEXT_BOLD="\e[1m" | |
TEXT_UNDERLINE="\e[4m" | |
TEXT_RED="\e[91m" | |
TEXT_BLACK="\e[30m" | |
TEXT_DEFAULT="\e[39m" | |
TEXT_RESET="\e[0m" | |
TEXT_YELLOW="\e[33m" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker CI | |
on: | |
push: | |
branches: | |
- 'master' | |
- 'develop' | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
inputs: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Super simple Switch case as React Functional Component | |
import React, { FC, Children, ReactElement } from "react"; | |
const Case: FC<{ value: SwitchValue } | { default: true }> = ( { children } ) => | |
<>{children}</>; | |
const checkCondition = ( condition, value ) => { | |
if ( condition instanceof Function && condition( value ) ) return true; | |
return condition === value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> | |
- <System> | |
<Provider Name="Dwminit" /> | |
<EventID Qualifiers="32770">0</EventID> | |
<Version>0</Version> | |
<Level>3</Level> | |
<Task>0</Task> | |
<Opcode>0</Opcode> | |
<Keywords>0x80000000000000</Keywords> | |
<TimeCreated SystemTime="2021-03-24T22:25:17.9398436Z" /> |