Skip to content

Instantly share code, notes, and snippets.

View treyhuffine's full-sized avatar

Trey Huffine treyhuffine

View GitHub Profile
@treyhuffine
treyhuffine / rich-text-html-editors.md
Created April 14, 2022 12:44 — forked from manigandham/rich-text-html-editors.md
Rich text / HTML editors and frameworks

Strictly Frameworks

Abstracted Editors

These use separate document structures instead of HTML, some are more modular libraries than full editors

const outerFunction = () => {
let storedValue = 0;
// returning a function from a function is the key
return () => {
storedValue = storedValue + 1;
console.log('storedValue = ', storedValue);
};
};
import './styles.css';
const ClassStylesComponent = () => {
const [isActive, setIsActive] = useState(false);
const className = isActive ? 'button--active' : 'button';
return (
<div>
<button onClick={() => setIsActive(!isActive)} className={className}>
click me
.button {
background-color: gray;
}
.button--active {
background-color: green;
}
import styled from 'styled-components';
const Button = styled.button`
background-color: ${({ isActive }) => (isActive ? 'green' : 'gray')};
`;
const CssInJsComponent = () => {
const [isActive, setIsActive] = useState(false);
return (
const getMaxProfit = (prices) => {
let minPrice = prices[0];
let maxProft = 0;
for (const price of prices) {
const currentProfit = price - minPrice;
minPrice = Math.min(minPrice, price);
maxProft = Math.max(maxProft, price - minPrice);
}
const getMaxProfit = (prices) => {
let maxProfit = 0;
for (let buyDay = 0; buyDay < prices.length; buyDay++) {
const buyPrice = prices[buyDay];
for (let sellDay = buyDay + 1; sellDay < prices.length; sellDay++) {
const sellPrice = prices[sellDay];
const currentProfit = sellPrice - buyPrice;
const apiRequest = () => {
return new Promise((resove) => {
// do some async things for an unknown amount of time...
return resolve({ answer: 42 });
})
}
const run = () => {
apiRequest.then((response) => {
console.log(response);
const apiRequest = async () => {
// do some async things for an unknown amount of time...
return { answer: 42 } ;
}
const run = async () => {
const response = await apiRequest();
console.log(response);
}
FROM postgres:latest
ARG FILE
ARG DBNAME
ENV FILE ${FILE}
ENV DBNAME ${DBNAME}
VOLUME /tmp
COPY ${FILE} /tmp/${FILE}
COPY restore_database.sh /docker-entrypoint-initdb.d/restore_database.sh