Skip to content

Instantly share code, notes, and snippets.

View drwpow's full-sized avatar
🤘

Drew Powers drwpow

🤘
View GitHub Profile
@drwpow
drwpow / .stylelintrc
Created March 8, 2018 13:38
Stylelint + Styled Components
{
"plugins": [
"stylelint-order"
],
"processors": ["stylelint-processor-styled-components"],
"extends": [
"stylelint-config-recommended",
"stylelint-config-styled-components"
],
"rules": {
@drwpow
drwpow / manifold-co-next-js.md
Last active May 2, 2018 23:35
manifold.co 👉 Next.js performance numbers
Connection CPU Before After Improvement
Fast (200MB) Fast 1.5s 0.2s 750%
Average (3G) Fast 5.6s 🐢 1.1s 500%
Average (3G) Average 7.5s 😞 1.3s 570%
Slow (Slow 3G) Average 22s 😱 4s 550%
/* Old (React Router) */
<Link to="/my/page">
A link
</Link>
/* New (Next.js router) */
<Link href="/my/page" passHref>
<a>
module.exports = {
webpack: (config, options) =>
Object.assign(config, {
plugins: config.plugins.concat([
new webpack.ProvidePlugin(
config.isServer
? {}
: { fetch: 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch' }
),
]),
module.exports = {
webpack: (config, options) =>
Object.assign(config, {
node: config.isServer ? undefined : { fs: 'empty' },
}),
};
class HomePage extends React.Component {
static getInitialProps() {
// This only fires on the first SSR pass
}
componentDidMount() {
// This only fires in the client, when mounted (not on SSR)
}
}
if (typeof window !== 'undefined') {
// Pls let me access `window` without everything blowing up
}
@drwpow
drwpow / manifold-config.md
Created June 27, 2018 21:00
Manifold Config
Option Default Description
team (none) Set the team label for this app
project (none) Set the project label for this app
const IronWorker = require('iron_worker');
const Logger = require('logdna');
const logger = Logger.setupDefaultLogger(process.env.KEY, {});
// Task
logger.log('Starting job…');
logger.log(`--BEGIN IRONWORKER PAYLOAD--`);
logger.log(IronWorker.params());
logger.log(`--END IRONWORKER PAYLOAD--`);
{
"scripts": {
"deploy": "docker build -t $TAG . && docker push $TAG && manifold run -- iron register -e \"MANIFOLD_API_TOKEN=$MANIFOLD_TOKEN\" $TAG"
}
}