This file contains 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
export class ArrayHelpers { | |
/** | |
* Sorts an array of objects by a specified key in ascending or descending order. | |
* | |
* @template T - The type of objects in the array. | |
* @param {T[]} array - The array to be sorted. | |
* @param {keyof T} key - The key to sort the objects by. | |
* @param {'asc' | 'desc'} [order='asc'] - The order to sort the objects. Defaults to 'asc'. | |
* @returns {T[]} - The sorted array. | |
*/ |
This file contains 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 { PropsWithChildren, useState } from "react"; | |
import "./styles.css"; | |
interface PanelWithToggleProps { | |
open: boolean; | |
} | |
function PanelWithToggle({ | |
open, | |
children, | |
}: PropsWithChildren<PanelWithToggleProps>) { |
This file contains 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 myFnWithCallback = (cb) => { | |
const message = "hi" | |
cb(message) | |
} | |
const doSomething = () => { | |
myFnWithCallback((msg) => { | |
console.log(msg) // "hi" |
This file contains 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
function frg { | |
result=$(rg --ignore-case --color=always --line-number --no-heading "$@" | | |
fzf --ansi \ | |
--color 'hl:-1:underline,hl+:-1:underline:reverse' \ | |
--delimiter ':' \ | |
--preview "bat --color=always {1} --theme='OneHalfDark' --highlight-line {2}" \ | |
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3') | |
file=${result%%:*} | |
linenumber=$(echo "${result}" | cut -d: -f2) | |
if [[ -n "$file" ]]; then |
This file contains 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 { createProxyMiddleware } = require('http-proxy-middleware'); | |
module.exports = function(app) { | |
app.use( | |
'/stylist-api', | |
createProxyMiddleware({ | |
target: 'http://localhost:3000', | |
changeOrigin: true, | |
}) | |
); |
This file contains 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 segment from 'segment' | |
const segment = { | |
init: () => console.log("initialized!!"), | |
trackEvent: (eventName: string, data: any) => console.log(data), | |
}; | |
interface SegmentEvent { | |
name: string; | |
data: {}; |
This file contains 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
interface HttpClient<Response, Options extends {} = {}> { | |
get: (url: string, options: Options) => Promise<Response>; | |
put: (url: string, options: Options) => Promise<Response>; | |
post: (url: string, options: Options) => Promise<Response>; | |
} | |
interface CurrencyFormatter { |
This file contains 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
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
if [[ -n "${TRACE-}" ]]; then | |
set -o xtrace | |
fi | |
if [[ "$1" =~ ^-*h(elp)?$ ]]; then |
This file contains 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
# unbind Ctrl+B as the default meta and instead use Ctrl+A | |
unbind C-b | |
set -g prefix C-a | |
set -g pane-border-status top | |
# split panes using | and - | |
bind \\ split-window -h -c "#{pane_current_path}" | |
bind - split-window -v -c "#{pane_current_path}" | |
unbind '"' |
This file contains 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 React, { useRef } from 'react'; | |
interface WidgetProps { | |
url: string; | |
onWidgetReady: (api: any) => void; | |
} | |
type UnsubscribeCallback = Function; | |
type Subscribe = <T = string>( |
NewerOlder