Skip to content

Instantly share code, notes, and snippets.

View teimurjan's full-sized avatar
🎯
Focusing

Teimur Gasanov teimurjan

🎯
Focusing
View GitHub Profile
@teimurjan
teimurjan / sametrica-code-review-28-09-2017.md
Last active September 28, 2017 05:01
FeatureContext.php file, Igor Lee

FeatureContext.php

Feature name to seed name map

Extract as Trait or Factory in a separate file.

Translations map

In order to minify errors after changing texts on frontend we should get translations directly from the frontend's en.json, fr.json files. It can be achieved by reading these files from a FeatureContext.php file method like getTranslationWithCode(locale).

Simplify FeatureContext.php

Make FeatureContext.php contains just features methods like "Before", "BeforeStep" etc. So the steps methods like "I click", "I see" should be added as traits. These traits can be separated to groups: Base("I click", "I see"), Group("I publish", "I assign"), Specific("I see something in specific modal")

Do some "Given" steps programmaticaly
@teimurjan
teimurjan / sametrica-code-review-03-10-2017.md
Last active October 3, 2017 04:57
Form Edit, Teimur Gasanov

Form Edit

  • Exract EditTab to a container in order to not sending props from the parent.
  • Make components stateless
  • Refactor tabs
  • Extract spinner to a wrapper
  • Make files/variables names more clear
  • Extract language to the FornEdit global state

Edit tab

  • Remove unnecessary handlers
  • Extract switch to a factory
@teimurjan
teimurjan / sametrica-code-review-19-10-2017.md
Last active October 19, 2017 04:58
Test Seeders Builders, Zhyldyz Alikeeva
  • All builders should be independent and reusable.
  • No titles should be used for creating foreign key/m-2-m relations, only objects.
  • Create common functions for creating complex structures(form with page and section, question with option etc.)

Если нет props, то объявлять propTypes не нужно

static propTypes = {};

Вынести в методы класса, иначе будут создаваться новые функции при каждом вызове render

searchField: props => <SearchField {...props} placeholder={this.props.intl('search')}/>
function priceFormatter(cell, row){
  return '<i class="glyphicon glyphicon-usd"></i> ' + cell;
}
@teimurjan
teimurjan / App.js
Last active May 21, 2018 06:11
blog-digits-recognizer-python-flask-react-3
import React, { Component } from "react";
import logo from "./assets/logo.svg";
import "./assets/App.css";
import { SketchField, Tools } from "react-sketch";
import { makePrediction } from "./api";
const pixels = count => `${count}px`;
const percents = count => `${count}px`;
const MAIN_CONTAINER_WIDTH_PX = 200;
@teimurjan
teimurjan / api.js
Last active May 21, 2018 06:10
blog-digits-recognizer-python-flask-react-3
const validateStatusCode = response =>
new Promise((resolve, reject) => {
const status = response.status;
const next = status < 400 ? resolve : reject;
response.text().then(next);
});
export const makePrediction = image =>
fetch("/api/predict", {
method: "POST",
@teimurjan
teimurjan / extract-text-plugin.js
Last active May 21, 2018 06:17
blog-react-applications-optimization
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
module: {
rules: [
{
oneOf: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
@teimurjan
teimurjan / minimize-css.js
Created May 21, 2018 06:18
blog-react-applications-optimization
loader: ExtractTextPlugin.extract({
use: [
{
loader: require.resolve("css-loader"),
options: {
minimize: true
}
}
]
});
@teimurjan
teimurjan / node-env.js
Created May 21, 2018 06:20
blog-react-applications-optimization
const webpack = require("webpack");
module.exports = {
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
})
]
@teimurjan
teimurjan / uglify-js.js
Created May 21, 2018 06:24
blog-react-applications-optimization
const webpack = require("webpack");
module.exports = {
plugins: [
new webpack.optimize.UglifyJsPlugin({
/* settings */
})
]
};