This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TypesOfObjectProperties<T> = { | |
[K in keyof T]: T[K] | |
}[keyof T]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Optional<T = unknown> = null | T; | |
export const hasValue = <T,>(value: Optional<T>): value is T => value !== null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const localTimeZoneName = Intl.DateTimeFormat().resolvedOptions().timeZone; | |
export const localTimeZoneOffsetInSeconds = -new Date().getTimezoneOffset() * 60; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type loggerLevel = 'info' | 'error' | 'warn' | 'debug'; | |
const log = (message: string, level: loggerLevel = 'info') => { | |
console.log(`${new Date().toLocaleString()} [${level}] ${message}`) | |
} | |
/** | |
* Create Logger with stopwatch | |
* @param label - stopwatch logger label | |
* @returns - logger wrapper with stopwatch feature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "$color_prompt" = yes ]; then | |
# get current branch in git repo | |
function parse_git_branch() { | |
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
if [ ! "${BRANCH}" == "" ] | |
then | |
STAT=`parse_git_dirty` | |
echo "${BRANCH}${STAT}" | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import ReactDOM from 'react-dom' | |
import ReactDOMServer from 'react-dom/server' | |
class Navigation extends Component { | |
render() { | |
return ( | |
<ul> | |
<li>Main</li> | |
<li>About</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Useful keybindings for micro | |
* version: 19.12.11 | |
* author: Alex Arus | |
* | |
* to install put it to ~/.config/micro/bindings.json | |
* +------------------------------------------------------------+ | |
* | Y | U | I | O | P | | |
* | add cursor above| home | up | end | page up | | |
* |-----------------|---------|---------|---------|------------| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createLogger, format, transports } from 'winston'; | |
import { loggerConfig } from '../config'; | |
import chalk from 'chalk'; | |
export const logger = createLogger(loggerConfig); | |
export const msToPrettyTime = (totalMilliseconds: number) => { | |
const msInSecond = 1000; | |
const secondInMinute = 60; | |
const minuteInHour = 60; |