git checkout .
git update-index --assume-unchanged config/database.yml
| const pdf = require("html-pdf"); | |
| const convertToPdf = (html, cb) => { | |
| pdf.create(html).toBuffer(function (err, buffer) { | |
| if (err) { | |
| console.error("Cannot write PDF", err); | |
| throw Error("Internal Server Error"); | |
| } | |
| console.log("Stream created..."); | |
| cb(buffer); |
git checkout .
git update-index --assume-unchanged config/database.yml
##Override build commands to ignore warnings such as unused variables
CI='' npm run build
| /* since apollo cache depends on unique identifiers, if it occurs that the fields are without id field we need to merge existing with incoming cache, or just accept the incoming one */ | |
| const cache = new InMemoryCache({ | |
| typePolicies: { | |
| /* query */ | |
| getSinglePosition: { | |
| fields: { | |
| /* related field */ | |
| Files: { | |
| merge(existing, incoming) { |
| import React, { useState, useContext, useCallback } from "react"; | |
| import styled from "styled-components"; | |
| import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; | |
| import { SidebarItem } from "../SidebarNavigation/SidebarNavigation.component"; | |
| import { FaPlus } from "react-icons/fa"; | |
| import { HiOutlineDotsVertical } from "react-icons/hi"; | |
| import { ModalContext } from "../../structure/Modal/modalContext"; | |
| import AddPositionForm from "./AddPositionForm"; | |
| const Wrapper = styled.div` |
| /* Change position of the item in array */ | |
| const list = [1, 2, 3, 4, 5, 6]; | |
| const changePosition = (arr, destinationIndex, sourceIndex) => { | |
| // destructable, copy array before using splice | |
| arr.splice(destinationIndex, 0, list.splice(sourceIndex, 1)[0]); | |
| return arr; | |
| }; |
| Position.aggregate([ | |
| { | |
| $project: { | |
| _id: 1, | |
| positions: { | |
| $filter: { | |
| input: "$newPositionsArray", | |
| as: "position", | |
| cond: { | |
| /* multiple conditions */ |
| /* compose function for combining HOC in react */ | |
| export const compose = (...rest) => (x) => rest.reduceRight((y, f) => f(y), x); | |
| /* | |
| It's called functional composition and it has mathematical background (that causes y and x variables naming and reversed execution of functions). It decreases complexity of the way how you call written functions by eliminating variables extra definition and deep level of function wrapage. | |
| */ |
Computed property names and methods
ECMAScript 2015 adds a nice feature: computed property names in object literals and classes.
The computed properties use a slight different syntax [methodName]() {...}, so the method definition looks this way:
const addMethod = 'add',
getMethod = 'get';
const collection = {
items: [],
[addMethod](...items) {