A library of my TIL
-AWS
-CSS
-Mac
-Saas
-Vim
Acronym
AWS Notes
Azure Notes
Clear History
-rm $HISTFILE
Notes for HomeLab
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
Line Break
-
Mongo Commands
Click Below for Notes
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\"",Start / Stop server
-brew services start postgresql
-brew services stop postgresql
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"]
}
Show Timeline
-\
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>Passing Props
-${props => props.NAME ? NAME : NAME}
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$.reducerACL - Access Control List
Alias File
-/Users/UserName/.zshrc
•Primary Mac?
Alter postgres to superuser
alter user postgres with superuser
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>Input Toggle Switching
def
VARIABLE_NAME;
switch (mode) {
case VARIABLE_NAME:
something = define
logic;
case VARIABLE_NAME:
something = define
logic;
}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
Steps to Enable
-⌘+R turn on your Mac
-csrutil enable --without kext
-csrutil disable
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
Windows Server net user Administrator /passwordreq:yes *
Arrow
ar
= () => { $End$ }
➕❌💥✨❓❕🚫✖️➖