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
// index.js | |
const D3Chart = dynamic(() => import("../components/d3chart")) | |
// further down in the render method | |
<D3Chart/> |
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
// chart.js | |
import React from "react"; | |
import * as d3 from "d3"; // big dependency | |
const data = [30, 86, 168, 281, 303, 365]; | |
export default class D3Chart extends React.PureComponent{ | |
constructor(props) { | |
super(props); |
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
{ | |
"scripts": { | |
"dev": "node server.js", | |
"build": "next build", | |
"start": "NODE_ENV=production node server.js" | |
} | |
} |
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
// next.config.js | |
const webpack = require('webpack'); | |
const BrotliPlugin = require("brotli-webpack-plugin"); | |
const CompressionPlugin = require("compression-webpack-plugin"); | |
const isNodeDevelopment = process.env.NODE_ENV === "development" | |
module.exports = { | |
webpack: config => { |
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
// Server.js | |
const express = require('express'); | |
const next = require('next'); | |
const port = parseInt(process.env.PORT, 10) || 3000; | |
const dev = process.env.NODE_ENV !== 'production'; | |
const app = next({ dev }); | |
const handle = app.getRequestHandler(); |
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
// Image.js | |
import React from "react"; | |
import LazyLoad from "react-lazyload"; | |
export default class Image extends React.PureComponent { | |
state = { | |
loaded: false | |
}; |
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
/* CSS */ | |
.image{ | |
width: 250px; | |
height: 250px; | |
display: block; | |
} | |
.image-loading { | |
position: static; |
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
import React, { useState, useEffect } from "react"; | |
const useFetch = url => { | |
const [state, setState] = useState({ | |
loading: true, | |
error: false, | |
data: [], | |
}); | |
useEffect(() => { |
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
# current | |
ifconfig en0 |grep ether | |
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//' | |
sudo ifconfig en0 ether [randomNumber] |
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
------------ | |
stat file | |
ln -s | |
Control + A beginning of the line | |
Control + E end of the line | |
echo '{"a": {"b":123 } }' | jq '.a.b' | |
curl -s https://api.github.com/repos/facebook/react | jq '.stargazers_count' | |
curl -s https://api.github.com/search/repositories?q=service+worker | jq '.items[].name' | |
cat filename | |
grep pattern |
NewerOlder