Skip to content

ConnorSmiley/Today-I-Learned

Repository files navigation

Today I Learned

A library of my TIL


-A-plus

-Algos

-AWS

-Cookies

-Chrome

-CSS

-Dev-Tools

-Fastify

-JavaScript

-GitHub

-Iterm

-Linux-Commands

-Linux-Features

-LocalStorage

-Homelab

-Mac

-MongoDB

-Markdown

-Cidr-Block-Notation

-Nextjs

-Network-plus

-Postgressql

-Prisma

-Premiere

-React

-React-StyleComponents

-Redux

-ReduxToolKid

-Saas

-Security

-Sublime-Text

-TailWindCSS

-ThinkScript

-Icons

-Vim

-Volta

-WindowsCommands

-WindowsServer

-ShortCutUpdates

-Supabase


A-plus

Acronym

Algos

Algos

A+ Notes

AWS

AWS Notes

AWS

Azure

Azure Notes

Azure

CSS

CSS

JavaScript

JavaScript

GitHub

Github

Fastify

Fastify

Iterm

Clear History
-rm $HISTFILE

Linux-Commands

Link to Linux Commands

Linux-Features

Link to Linux Features

LocalStorage

LocalStorage

Notes for HomeLab

HomeLab

Mac

SMC
-shift + ctrl + option + power

PRAM
-cmd + option + r + p

Disable Mac Chime
-sudo nvram StartupMute=%01

Quit Finder
-defaults write com.apple.finder
-QuitMenuItem -bool true;
-killall Finder

Markdown

Line Break
- 

MongoDB

MongoDB

Mongo Commands

Network-plus

Click Below for Notes

Network+ Notes

Cidr Block Notation

Cidr-Block-Notation

Nextjs

Install TW
-npm install -D tailwindcss postcss autoprefixer
-npx tailwindcss init -p

Fetch API

const [fetched, setFetched] = useState()


useEffect(() => {
    const fetchItems = async () => {
        try {
            const response = await fetch(API_URL);
            if (!response.ok) throw Error('Did not receive expected data');
            const fetchAPI = await response.json();
            setFetched(fetchAPI);
            setFetchError(null);
        } catch (err) {
            setFetchError(err.message);
        } finally {
            setIsLoading(false);
        }
    }

    setTimeout(() => fetchItems(), 2000)

}, [])

Nodemon server

"proxy": "http://localhost:3001",
"scripts": {
"dev": "concurrently \"open http://localhost:3000 && next dev\" \"npm run server\"",

Postgressql

Postgressql

Start / Stop server
-brew services start postgresql
-brew services stop postgresql

Prisma

Prisma

Commands

-yarn prisma db push

-yarn prisma migrate dev --name init

-yarn prisma introspect --force

-yarn prisma studio

-yarn prisma generate


generator client {

provider = "prisma-client-js"

previewFeatures = ["multiSchema"] }


datasource db {

provider = "postgresql"

url = env("DATABASE_URL")

schemas = ["auth", "public"]

}

Premiere

Show Timeline
-\

React

React Options Chaining

console.log(maybeNo.Object ?)

Slice and Map

array = []

{
    array.slice(startIndex
:
    number, endIndex
:
    number
).
    map(x => {
        return <Component>{x}</Component>
    })
}

KeyStroke Text

    const [text, setText] = useState("")

function handleChange(e) {
    const {value} = e.target
    setText(value)
}

return (
    <div
        onChange={handleChange}
        value={text}
    />

Count Words

const [text, setText] = useState("")

function handleChange(e) {
    const {value} = e.target
    setText(value)
}

function calculateWordCount(text) {
    const wordsArr = text.trim().split(" ")
    const filteredWords = wordsArr.filter(word => word !== "")
    return filteredWords.length
}

return (
    <div>
        <TextBox
            onChange={handleChange}
            value={text}
        />
        <button onClick={() => calculateWordCount(text)}/>
    </div>
)

Timer == setTimeRemaining

const [timeRemaining, setTimeRemaining] = useState(5)


useEffect(() => {
    setTimeout(() => {
        if (timeRemaining === 0) return
        setTimeRemaining(time => time - 1)
    }, 1000)
}, [timeRemaining])

or

useEffect(() => {
    if (timeRemaining > 0) {
        setTimeout(() => {
            setTimeRemaining(time => time - 1)
        }, 1000)
    }
}, [timeRemaining])

UseEffect Return

    useEffect(() => {
    const intervalId = setInterval(() => {
        setCount(prevCount => prevCount + 1)
    }, 1000)
    setColor(randomcolor())
    return () => clearInterval(intervalId)
}, [count])

Button Disable

const [timeRunning, setTimeRunning] = useState(5)

return (
    <Button
        disable={timeRunning}/>)

Disable Input

<button disabled={!text}>CLICK</button>

React-StyleComponents

Passing Props
-${props => props.NAME ? NAME : NAME}

Redux

import {createSlice} from '@reduxjs/toolkit'

const initialState = [{}]

export const $VAR$ = createSlice({
    name: '',
    initialState,
    reducers: {},
})

export const ??
? = (state) => state. ?? ?
export const {} = $VAR$.actions
export default $VAR$.reducer

Saas

Saas Notes

Security

ACL - Access Control List

Sublime-Text

Alias File
-/Users/UserName/.zshrc
      •Primary Mac?

Supabase

Alter postgres to superuser

alter user postgres with superuser

TailWindCss

Center Absolute
-inset-x-0

Render Conditions

const handleTail = (small ? "bg-black" : med ? "bg-white" : large ? "bg-red-500" : "bg-green-500")

    < div
className = {handleTail} > Blah < /div>

ThinkScript

Input Toggle Switching

def
VARIABLE_NAME;
switch (mode) {
    case VARIABLE_NAME:
        something = define
        logic;

    case VARIABLE_NAME:
        something = define
        logic;
}

Vim

Save and Write
-:q close
-:w write/saves
-:wa[!] write/save all windows [force]
-:x save and quit, same as wq
-:q! force close's non-saved files with changes

Volta

Steps to Enable
-⌘+R turn on your Mac
-csrutil enable --without kext
-csrutil disable

WindowsCommands

Navigation

cd = change directory

dir = list current dir (similar to ls)

md = make dir

mkdir = make dir

chdir = change dir

rd = remove dir

rmdir = remove dir

cls = clear screen

Command Line Tools

[command name] /? = Show help command (similar to man) help = help

chkdsk = check for disk errors -/f = fixes logical file system errors on disk -/r = locates bad sectors and recovers readable information

format = format drive

xcopy = copies full directory and files -/s = & copies sub-directories

copy = copy file-name rename-copy-file -/v = verifies that new files are written correctly -/y = suppresses prompt to confirm over-write file message

robocopy = more robust copy method to xcopy

gpupdate = updates group policy -/force = everything is updated

gpresult = shows current group policy update -/r = shows all current active dir policy settings

shutdown = shutdown computer -/s /t nn = shutdown timer -/r /t nn = restart timer -/a = abort shutdown

sfc = checks and repairs windows system files -/scannow = checks disk

diskpart = makes disk partitions

winver = shows which version

Network Command Line Tools

ipconfig = displays TCP/IP, DHCP and DNS -/all = more details on ipconfig

ping = Verifies connection with ICMP request.

pathping = show path route and network information / tracert + ping

hostname = Displays host name

netstat = Displays TCP connections, ports, Ethernet, IP routing table, IPv4 and IPv6 stats -/a = show all active connection -/b = show all binaries -/n = do no resolve names

nslookup = Name server lookup

net = used to connect to, remove, and configure connections with shared resources

net user = shows user privileges

net use = shows network connections

tracert = Determine package route to destination

nslookup = look up DNS, names and IP

WindowsCommands

Windows Server net user Administrator /passwordreq:yes *

ShortCutUpdates

Arrow ar = () => { $End$ }


Icons

➕❌💥✨❓❕🚫✖️➖ 

About

TIL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors