View types.d.ts
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
type Response = { | |
hostname: string; | |
requestUrl: string; | |
title: string; | |
description: string; | |
image?: { | |
url: string; | |
alt?: string; | |
}; | |
details: Details; |
View code-snippets.json
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
{ | |
"Create a useState block": { | |
"prefix": ["useState", "us"], | |
"body": [ | |
"const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = React.useState(${2:initialState})" | |
], | |
"description": "Create a regular useState hook" | |
}, | |
"Create a useEffect block": { | |
"prefix": ["useEffect", "ue"], |
View Main.elm
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
module Main exposing (..) | |
import Browser | |
import Html exposing (..) | |
import Html.Attributes as A | |
import Html.Events as Events | |
import Http | |
main = |
View image-optimizer.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
import Pica from 'pica'; | |
const getImageFromFile = file => | |
new Promise(resolve => { | |
const reader = new FileReader(); | |
const image = new Image(); | |
reader.onload = async fileReaderEvent => { | |
image.onload = () => resolve(image); | |
image.src = await fileReaderEvent.target.result; | |
}; |
View webpack.config.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
const path = require('path'); | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
const isProduction = process.env.NODE_ENV === 'production'; | |
const config = { | |
// First, let's define an entry point for webpack to start its crawling. | |
entry: './src/index.js', | |
// Second, we define where the files webpack produce, are placed | |
output: { |
View webpack.config.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
const path = require('path'); | |
const config = { | |
// First, let's define an entry point for webpack to start its crawling. | |
entry: './src/index.js', | |
// Second, we define where the files webpack produce, are placed | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js', | |
}, |
View my-styles.less
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
@color: palevioletred; | |
.with-styles { | |
background-color: @color; | |
} |
View index.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
import './my-styles.less'; | |
document.querySelector('body').classList.add('with-styles'); | |
View webpack.config.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
const path = require('path'); | |
const config = { | |
// First, let's define an entry point for webpack to start its crawling. | |
entry: './src/index.js', | |
// Second, we define where the files webpack produce, are placed | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js', | |
}, |
View withApiState.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
const withApiState = TargetComponent => | |
class extends React.Component { | |
state = { | |
current: "idle" | |
}; | |
apiState = { | |
pending: () => this.setState({ current: "pending" }), | |
success: () => this.setState({ current: "success" }), | |
error: () => this.setState({ current: "error" }), |
NewerOlder