Skip to content

Instantly share code, notes, and snippets.

View danielwei15's full-sized avatar

Daniel Wei danielwei15

  • Either SF or NYC
  • 01:54 (UTC -04:00)
View GitHub Profile

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
Run and detach a command instantly screen -dmS <session_name> <your> <command> <here>
List running sessions / screens screen -ls
Attach to a running session screen -x
@danielwei15
danielwei15 / editor-asset-grid-card-header-center-controller.tsx
Created November 29, 2024 06:02
i need pattern matching in typescript/react ASAP
import { ShmReact } from '@/src/lib/utils/react';
import { Card } from '@/src/packages/shmood-db/api/types/immutable-card';
import { useCache } from '@/src/contexts/root-cache/react';
import { EditorState } from '@/src/contexts/board-state/editor-state';
import { AssetCardHeader } from '@/src/components/shm/asset-card-header';
import { Shmavatar } from '@/src/components/shm/avatar';
import { AssetMoreMenu } from '@/src/components/shm/asset-more-menu';
import { AssetPopoverMenu } from '@/src/components/shm/asset-popover-menu';
import React, { useEffect } from 'react';
import { EditorAssetZoneCardMenuController } from '@/src/components/logical/editor/editor-asset-zone-card-menu';
import { useEffect, useRef, useState } from "react";
/**
* Custom hook that maintains the previous value of a changing React state variable.
*/
export function usePrevious<T>(value: T): T | undefined {
// The ref object is a generic container whose current property is mutable, and can hold any value, similar to an instance property on a class
const ref = useRef<T>();
// Store current value in ref
useEffect(() => {
@danielwei15
danielwei15 / ramp-fe-challenge
Created January 10, 2023 09:32
a really really extra list
https://codesandbox.io/s/ramp-fe-challenge-wiczb6
import React, { useEffect } from "react";
/**
* Utility function to assert the target is a node
* Lifted straight from https://stackoverflow.com/questions/71193818/react-onclick-argument-of-type-eventtarget-is-not-assignable-to-parameter-of-t
*/
function assertIsNode(e: EventTarget | null): asserts e is Node {
if (!e || !("nodeType" in e)) {
throw new Error(`Node expected`);
}
@danielwei15
danielwei15 / custom-hooks.tsx
Created January 5, 2023 21:44
Mutex-locked Fuzzy React Search Bar
import { useEffect, useRef } from "react";
/**
* Custom hook that maintains the previous value of a changing React state variable.
*/
export function usePrevious<T>(value: T): T {
// The ref object is a generic container whose current property is mutable, and can hold any value, similar to an instance property on a class
const ref: any = useRef<T>();
// Store current value in ref
useEffect(() => {
import { useState } from "react";
type FlatStateType<T> = T;
type FlatStateSetter<T> = <X>(props: SetterProps<T, X>) => void;
type FlatStateGetter<T> = <X>(props: GetterProps<T, X>) => T | GetterRes<T>;
type FlatUpdates = number;
type FlatStateHookObj<T> = [MutationBundle<T>, FlatUpdates];
@danielwei15
danielwei15 / custom-hooks.tsx
Last active December 23, 2022 03:47
super extra search bar
import { useEffect, useRef } from "react";
/**
* Custom hook that maintains the previous value of a changing React state variable.
*/
export function usePrevious<T>(value: T): T {
// The ref object is a generic container whose current property is mutable, and can hold any value, similar to an instance property on a class
const ref: any = useRef<T>();
// Store current value in ref
useEffect(() => {
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
}
body {
background-color: #1a1a1a;
font-family: sans-serif;
This file has been truncated, but you can view the full file.