Skip to content

Instantly share code, notes, and snippets.

@kisildev
kisildev / index.js
Created January 30, 2020 23:35
Divide name with symbol
export default (fullName: string) => (
fullName.split(' ').map((item, index) => {
return index === 1 ? `@${item}` : item;
})
)
@kisildev
kisildev / init.txt
Created November 26, 2019 12:14
Jest + Enzyme + Typescript (based on parcel)
1) npm i jest --save-dev
2) npm i @types/jest ts-jest —save-dev
3) create jest.config.js
---------------------------
module.exports = {
"roots": [
"<rootDir>/src"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
@kisildev
kisildev / test.js
Created November 18, 2019 09:40
Jest test mock class method
it('should redirect to another page', () => {
const user = {
id: 1,
token: 'J9gj9fj90.Tgf84h8Ufds.jfiosdjfi',
};
// static method
const spy = jest.spyOn(Login, 'redirectUser');
mount(<Login user={user} />, global.contextData);
expect(spy).toBeCalled();
@kisildev
kisildev / index.txt
Created October 25, 2019 08:48
Create webpack || parcel bundler
create own config - https://createapp.dev/parcel
@kisildev
kisildev / google-map-react.js
Created October 18, 2019 10:28
React google map examples
//Link to repository - https://github.com/google-map-react/google-map-react
import React, { Component } from 'react';
import GoogleMapReact from 'google-map-react';
import Marker from './marker';
import mapStyle from './map-style';
export default class MapContainer extends Component {
renderMarkers() {
const { markersCoords } = this.props;
@kisildev
kisildev / index.js
Created August 20, 2019 14:08
Render with array map
getUsers() {
const { users } = this.props;
if (Array.isArray(users)) {
return users.map((user) => {
return (<Participant key={user.id} userData={user} />);
});
}
};
@kisildev
kisildev / How to delete a commit on Github.txt
Created August 15, 2019 08:25
How to delete a commit on Github (Git)
How to delete a commit on Github
1. We get the hash code of the commit that we want to return to.
2. Go to the repository folder and write to the console:
$ git reset --hard a3775a5485af0af20375cedf46112db5f813322a
$ git push --force
@kisildev
kisildev / index.js
Created August 12, 2019 08:52
Text overflow
var a,w=document.createTreeWalker(document,NodeFilter.SHOW_TEXT);while(a=w.nextNode()){if(a.textContent.trim().length)a.textContent='Одиннадцатиклассница пошла посмотреть на достопримечательность, она шла долго, несколько строчек, пока не пришла'}
@kisildev
kisildev / index.js
Created July 31, 2019 14:22
React wrapper
import React, { Component } from 'react';
import ApiService from '../../services/api-service';
import Nav from '../../components/nav';
import Metabox from '../../components/metabox';
import Dialog from '../../components/dialog';
import Page404 from '../../components/page-404';
import Spinner from '../../components/spinner';
import './single-sample.scss';
import placeholder from './placeholder-image.png';
import { AppStatusContext } from '../../context/app-status-context';
@kisildev
kisildev / doc.txt
Created June 27, 2019 13:44
Slides Presentations
https://slides.com/wladeveloper/flex-content#/