- Create or open file:
vi <filename>
- Normal mode:
ESC
| Insert mode:i
| Command mode::
In normal mode, we can execute Vim commands to search, and transform text. In Insert mode, we can edit the file content. - Write and quit:
:wq
- Select lines: Press
v
to startvisual selection
. Select lines with arrow keys. - Copy with
y
| Paste withp
- Delete or cut line:
d
- Repeat last action:
.
Press dot as many times as you want to repeat the command (e.g. indent) - Search:
/
E.g./nodePort
Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.
You use Next.js router like normally, but don't define getStaticProps
and such. Instead you do client-only fetching with swr
, react-query
, or similar methods.
You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)
Don't like Next? Here's how to do the same in Gatsby.
/* Using a JavaScript proxy for a super low code REST client */ | |
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg | |
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3 | |
// also see https://github.com/fastify/manifetch | |
// also see https://github.com/flash-oss/allserver | |
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
const createApi = (url) => { | |
return new Proxy({}, { | |
get(target, key) { |
Tiny wrapper component for React-Datepicker to stylistically fit with Chakra-UI 1.x.
<DatePicker selectedDate={myDate} onChange={(d) => console.log(d)} />
Clearable version:
<DatePicker selectedDate={myDate} onChange={(d) => console.log(d)} isClearable={true} />
//Dev.to article: https://dev.to/nerycordova/unzip-large-files-in-aws-using-lambda-and-node-js-cpp | |
const AWS = require("aws-sdk"); | |
const s3 = new AWS.S3({ apiVersion: "2006-03-01" }); | |
const unzipper = require("unzipper"); | |
exports.handler = async (event) => { | |
//...initialize bucket, filename and target_filename here | |
try { |
'use strict' | |
// examples from https://github.com/vriad/zod | |
// trying to use zod in JS w/ jsdoc type comments in vsCode | |
const z = require('zod') | |
const dogSchema = z.object({ | |
name: z.string(), |
Welcome to step by step hands-on guide to setup webpack in your upcoming typescript project. Please follow the steps and you should be able to create your own webpack project. Please download the source code from github.
You will learn below things:
- ✅Create a Typescript node.js project.
- ✅Install Dependencies with webpack & typescripts.
- ✅Use Webpack CLI to crate
webpack.config.js
file and modify webpack.config.js based on our need.
const createMySocketMiddleware = (url) => { | |
return storeAPI => { | |
let socket = createMyWebsocket(url); | |
socket.on("message", (message) => { | |
storeAPI.dispatch({ | |
type : "SOCKET_MESSAGE_RECEIVED", | |
payload : message | |
}); | |
}); |