npm install better-sqlite3
npm install prisma --save-dev
npx prisma init --datasource-provider sqlite
# update database on .env DATABASE_URL="file:./dev.db"
# create schema
This file contains hidden or 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
| // use for fake data | |
| const images = [1, 2, 3, 4] | |
| const articles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
| const paired = articles.map((article, i) => ({ | |
| article, | |
| image: images[i % images.length], | |
| })) | |
| // --- |
This file contains hidden or 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
| // make pagination array smaller, better for responsive design | |
| function elipsisPagination(currentPage, totalPages, visibleCount = 5) { | |
| const pages = [] | |
| const showEllipsis = (arr, position) => { | |
| if (position === 'start' && arr[0] !== 1) { | |
| arr.unshift('...') | |
| arr.unshift(1) | |
| } | |
| if (position === 'end' && arr[arr.length - 1] !== totalPages) { |
This file contains hidden or 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
| // C:\Program Files\Git\etc\profile.d\aliases.sh | |
| # Some good standards, which are not used if the user | |
| # creates his/her own .bashrc/.bash_profile | |
| # --show-control-chars: help showing Korean or accented characters | |
| alias ls='ls -F --color=auto --show-control-chars' | |
| alias ll='ls -l' | |
| # Aliases |
This file contains hidden or 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
| diksutil list | |
| # change number wit your usb | |
| diskutil eraseDisk MS-DOS "{usbName}" MBR disk{number} | |
| # open iso files | |
| ls /Volumes | |
| # try to use -Rp instead | |
| cp -Rp /Volumes/{OsIsoName}/* /Volumes/{usbName}/ |
This file contains hidden or 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 * as React from "react"; | |
| import { Route, RouteProps } from "react-router"; | |
| interface Props { | |
| component: React.ComponentType<RouteProps>; | |
| } | |
| export const HomepageLayout = ({ component: Component, ...rest }: Props) => { | |
| return ( | |
| <Route {...rest} render={routeProps => <Component {...routeProps} />} /> | |
| ); |
This file contains hidden or 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 from 'react' | |
| const Name = (props) => { | |
| return( | |
| <div> | |
| dumb Component | |
| <div> | |
| name: {props.name} | |
| </div> | |
| <input name="name" value={props.name} onChange={props.handleChange}/> |
This file contains hidden or 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 from 'react' | |
| class Statefull extends React.Component { | |
| constructor(props){ | |
| super(props) | |
| this.state={ | |
| name: '' | |
| } | |
| } | |
| handleChange = (e) => { |
This file contains hidden or 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
| ╔════════════════╦═══════════════════╗ | |
| ║ smart componen ║ dumb component ║ | |
| ╠════════════════╬═══════════════════╣ | |
| ║ statefull ║ Stateless ║ | |
| ╠════════════════╬═══════════════════╣ | |
| ║ container ║ functional ║ | |
| ╚════════════════╩═══════════════════╝ |
Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demoNewerOlder