Skip to content

Instantly share code, notes, and snippets.

Avatar
⚛️
useEffect(() => { setWorking(true) }, [])

Konstantin Dichev kdichev

⚛️
useEffect(() => { setWorking(true) }, [])
View GitHub Profile
View contetnful-plugin
dfds-kd:bench-app kdichev$ yarn run build
yarn run v1.17.3
$ gatsby build
success open and validate gatsby-configs - 0.038s
success load plugins - 0.682s
Loaded gatsby-source-contentful
Loaded gatsby-starter-plugin
success onPreInit - 0.022s
success delete html and css files from previous builds - 0.733s
success initialize cache - 0.019s
@kdichev
kdichev / master
Created Mar 17, 2020
this is our latest master build under our infrastructure.
View master
2020-03-17T08:26:02.8640112Z yarn run v1.19.1
2020-03-17T08:26:02.9055760Z $ yarn validate:schema
2020-03-17T08:26:03.1232878Z $ node ./scripts/validate-local-schema.js
2020-03-17T08:26:03.3995455Z $ gatsby build
2020-03-17T08:26:04.7039219Z success open and validate gatsby-configs - 0.076s
2020-03-17T08:26:05.4198376Z success load plugins - 0.702s
2020-03-17T08:26:05.4353014Z success onPreInit - 0.004s
2020-03-17T08:26:05.4545610Z success delete html and css files from previous builds - 0.009s
2020-03-17T08:26:05.4693152Z success initialize cache - 0.005s
2020-03-17T08:26:05.5002112Z success copy gatsby files - 0.022s
View test.js
// bad
<div
className={`miniBook__tab miniBook__tabOneWay${oneWay ? ' miniBook__tab--active' : ''}`}
onClick={() => this.tabOnClick(oneWay)}
>
{children}
</div>
// better
<div
View data.js
// that needs to become something readable for a pathfinding algorithm like
// [
// [0, 0, 0, 1, 0],
// [1, 0, 0, 0, 1],
// [0, 0, 1, 0, 0],
// ]
const apiData = [
[
"west",
View grid.js
// data contains width * height walkable path entries
// each entry has at most two walls "west" | "north"
// to find all walkable directions from X use the array entries X, X+1 and X+width to construct walls
// grid is 15x15 blocks
const data = [["west","north"],["north"],["west","north"],["north"],["north"],["west","north"],["north"],["north"],["west","north"],["north"],["north"],["north"],["west","north"],["north"],["north"],["west","north"],["west"],["west"],["north"],["west"],["west"],["west"],["west"],["north"],["north"],[],["west"],["north"],["north"],[],["west"],[],["west"],["west"],["north"],[],["west"],["north"],["north"],["west","north"],["north"],[],["west","north"],["north"],["west"],["west"],["north"],["north"],["west"],["north"],["north"],["north"],["north"],["west"],["north"],["north"],["north"],["west"],["west"],["west"],["west","north"],["north"],["west"],["west"],["west","north"],["north"],["north"],["west"],["west","north"],["north"],["west"],["west"],[],["west"],["north"],["west"],["west
View gist:07529da3743d1646bedb2c3562633635
const data = [
[
'west',
'north'
],
[
'north'
],
[
'north'
View endpoints.graphql
mutation {
createCar(
name: "car"
carBrand: "Mercedes-Benz"
carMode: "C63 AMG"
carYear: "2018-06-19T19:51:13.701Z"
) {
id
carBrand
}
View gist:3d57c8c3f21751d23f10f83b86361beb
const asyncAction = (dataMaybe) => async (dispatch, getState) => {
// u can dispatch all kinds of actions here according to outcome
dispatch({type: "FETCHING_START"}
// if u need to use store data but can be passed as arg from react component when invoking
const store = getState().theReducer
const response = await myFetchFunction()
if (response) {
dispatch({type: "FETCHING_SUCCESS", payload: {response}}
View gist:0d1fade1f2e5cce048b1142d2cedde92
import { connect } from "react-redux";
const mapStateToProps = ({
theReducer: { city, humidity, temperature, wind }
}) => ({
city,
humidity,
temperature,
wind
});
@kdichev
kdichev / js
Created Apr 8, 2018
reducers.js
View js
import { combineReducers } from "redux";
const initialState = {
hi: "hi"
};
export const theReducer = (state = initialState, action) => {
switch (action.type) {
case "SOMETHING_HAPPENING":
return { ...state, hi: "bye" };