Skip to content

Instantly share code, notes, and snippets.

View dev99problems's full-sized avatar
🤷
Little By Little

Gene Chulkov dev99problems

🤷
Little By Little
View GitHub Profile
# origin: https://github.com/JSMonk/my-vimrc/blob/master/.vimrc
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'bling/vim-airline'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'pangloss/vim-javascript'
Plug 'isRuslan/vim-es6'
Plug 'mattn/emmet-vim'
set t_RV=
set t_vb=
call plug#begin('~/.vim/plugged')
" Initialize plugin system
Plug 'easymotion/vim-easymotion'
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
[alias]
# tips from Harry Roberts
# https://csswizardry.com/2017/05/little-things-i-like-to-do-with-git/
stats = !git shortlog -sn --all --no-merges
recent = !git for-each-ref --count=5 --sort=-committerdate refs/heads/ --format='%(refname:short)'
# tips from Rob Miller
# https://gist.github.com/robmiller/6018582
br-name = "!git rev-parse --abbrev-ref HEAD"
diffmaster = "!git log --oneline origin/master..$(git br-name)"
@dev99problems
dev99problems / package.json
Created October 4, 2019 16:31
husky, lint-staged and prettier (minimal example)
{
"name": "example",
"version": "0.0.1",
"description": "examplio",
"main": "index.js",
"author": "Eugene Chulkov",
"license": "MIT",
"dependencies": {},
"devDependencies": {
"husky": "^3.0.8",
@dev99problems
dev99problems / react-file-upload.js
Created March 2, 2020 15:57 — forked from AshikNesin/react-file-upload.js
Simple React File Upload
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}

CRA 2.x + TS setup:

This will give you complete intellisense and type safety within your app and CSS modules

typesafe-css-modules

🚨 NOTE

  • refactoring className from ts file wont update your css/scss className, to change class names you have to change it within your .module.scss file
@dev99problems
dev99problems / getRecordsToSave.js
Last active September 25, 2020 12:14
Mocking `new Date()` in tests with a specific date
const _isEmpty = require('lodash/isEmpty')
module.exports = (news, prevResults) => {
const recordsToSave = []
if (_isEmpty(news) || _isEmpty(prevResults)) {
return recordsToSave
}
// some loop over values
@dev99problems
dev99problems / persistData.ts
Last active February 3, 2021 12:02
Really simple util class to use localStorage
class PersistData {
storageName: string
constructor(storageName: string) {
this.storageName = storageName
}
get() {
try {
const value = window.localStorage.getItem(this.storageName) || ''
@dev99problems
dev99problems / test.ts
Created February 8, 2021 10:45
jest + process.env
// How to test something with Jest and process.env
// Details link to original author's response on SO
// https://stackoverflow.com/questions/48033841/test-process-env-with-jest
describe('environmental variables', () => {
const OLD_ENV = process.env;
beforeEach(() => {
// MOST IMPORTANT THING IS 👇
jest.resetModules() // Most important - it clears the cache
@dev99problems
dev99problems / language_data.mock.js
Created June 11, 2021 13:25
Simple example of mocking dependencies with node-tap@15.0.9
module.exports = {
'ar-AR': {
'nativeName': 'العربية',
'englishName': 'Arabic'
},
'cs': {
'nativeName': 'Čeština',
'englishName': 'Czech'
},
'uk': {