- Runs at build time only, meaning if there’s no
getInitialProps
, the page will be served as a static file (no SSR). - Can pass data to the page component as props.
- In development runs on every request
This file contains 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
/** | |
* Convert a time string to a decimal value | |
* | |
* @param {string} argv e.g. 142h13m, 142 h 13 min | |
*/ | |
function run(argv) { | |
const query = argv[0]; | |
const [, hours, minutes] = query.match(/\s*(?:(\d+)\s*h)?\s*(?:(\d+)\s*m)?/) | |
let decimal = 0; |
This file contains 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
#!/usr/bin/env bash | |
# References: | |
# https://docs.travis-ci.com/user/environment-variables | |
# | |
# Inspired by: | |
# https://gist.github.com/willprice/e07efd73fb7f13f917ea | |
# But using SSH keys instead of Personal Access Token: | |
# https://gist.github.com/alexilyaev/2672fe6d99756377fbffaabad6db1f45 |
https://prettier.io/docs/en/options.html#trailing-commas
When set to none
...
- Often forgetting to add a comma when adding entries to an Object.
- Commenting a property in an object currently removes the comma from the property above it.
- Moving the last property of an object up requires an extra step to add a comma at the end.
- Messes up Git diff and sometimes creates conflicts.
- Use
rem
units forfont-size
andline-height
.- The user preferences are respected.
- We can change the apparent
px
value ofrem
to whatever we'd like.
- Use
px
,%
orvw
for layout purposes.- For example, when using
margin
,padding
,width
,height
, etc. - Easier to implement design requirements.
- Why not
rem
here as well?
- For example, when using
- Layout can break when changing the base browser font-size.
A really nice tool to manage the different Node.js/npm/yarn versions between projects:
- Making sure everyone who works on the project uses the same Node.js/npm/yarn version for consistent dependencies tree and Node.js execution.
- Switching the Node.js version when jumping between projects.
eslint-plugin-unicorn
v19.0.0 added unicorn/no-null by default.
The reasoning behind it:
Intent to stop using null
in my JS code
Some good Pros/Cons summary from that thread:
sindresorhus/meta#7 (comment)
The rule only restricts using null
as explicit values for variables or function arguments.
StackBlitz - Introducing WebContainers: Run Node.js natively in your browser
- Really easy to start up a new project and play around with it locally (like in CodeSandbox, but supports Node.js as well).
- Turns out CodeSandbox have an experimental support for Node.js projects as well 😳 I don't know if they run it locally or remotely, and you can't
clone
and existing Node repo and run it.
- Turns out CodeSandbox have an experimental support for Node.js projects as well 😳 I don't know if they run it locally or remotely, and you can't
- Can connect to any repo on GitHub and play around with the code (if the Node.js version matches):
- If it's my repo, I can directly
commit
to it. That's actually nice, cause it could be a very fast workflow for quick changes.
- If it's my repo, I can directly
- Can run on a Tablet or Chromebook.