Skip to content

Instantly share code, notes, and snippets.

View bohdanzahurskyi1's full-sized avatar

Bohdan Zahurskyi bohdanzahurskyi1

  • Ukraine, Khmelnitsky
View GitHub Profile
@bohdanzahurskyi1
bohdanzahurskyi1 / react-select.js
Created November 10, 2019 19:58
React Select customized
import React from 'react'
import styled from 'styled-components'
import ReactSelect from 'react-select'
export const App = () => {
return (
<Container>
<Select />
</Container>
)

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

import { appConfig } from '@app/config'
export const paginateOptionsProvider = maxLimit => (page = 1, limit = maxLimit) => {
const newLimit = Math.min(maxLimit, limit)
const newPage = Math.max(page, 1)
const offset = Math.max((newPage - 1) * newLimit, 0)
return {
limit: newLimit,
page: newPage,
offset,
@bohdanzahurskyi1
bohdanzahurskyi1 / express-resource.js
Created November 28, 2018 21:27
express-resource.js
const noop = () => {}
export default (express, bind) => {
const id = 'id'
const resources = [
{ path: '/', name: 'create', method: 'post' },
{ path: '/', name: 'index', method: 'get' },
{ path: `/:${id}`, name: 'show', method: 'get' },
{ path: `/:${id}`, name: 'update', method: 'put' },
{ path: `/:${id}`, name: 'delete', method: 'delete' },
@bohdanzahurskyi1
bohdanzahurskyi1 / deepClone.js
Created November 13, 2018 20:11
Deep clone
const deepClone = (initalObj, finalObj = {}) => {
const obj = finalObj
for (let i in initalObj) {
var prop = initalObj[i]
if (prop === obj) {
continue
}
if (typeof prop === 'object') {
@bohdanzahurskyi1
bohdanzahurskyi1 / json-schema-nested-schemas.js
Last active November 11, 2018 14:13
Json Schema - nested schemas
const { Validator, ValidationError } = require('jsonschema')
const validator = new Validator()
// override standard error messages
// ValidationError.prototype.toString = function toString() {
// const [instance, ...rest] = this.property.split('.')
// return rest.join('.') + ' ' + this.message
// }