This file contains hidden or 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
var arr = [1, 2, 3]; | |
var greeting = "hello world"; | |
var m = new Map(); | |
m.set("foo", 42); | |
m.set({cool: true}, "hello world"); | |
var it = arr[Symbol.iterator](); | |
it.next(); | |
it.next(); | |
it.next(); |
This file contains hidden or 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
function foo() { | |
function nextState(v) { | |
switch (state) { | |
case 0: | |
state++; | |
return 42; // yield | |
case 1: | |
state++; | |
x = v; // yield ended | |
console.log(x); |
This file contains hidden or 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
{ | |
"files.autoSave": "onFocusChange", | |
"explorer.confirmDelete": false, | |
"editor.fontFamily": "Victor Mono", | |
"editor.fontWeight": "600", | |
"editor.fontSize": 15, | |
"editor.fontLigatures": true, | |
"editor.lineHeight": 16, | |
"editor.tokenColorCustomizations": { | |
"textMateRules": [ |
This file contains hidden or 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 { useState } from "react"; | |
// использование | |
function App() { | |
// аналогично useState, но первым аргументом является ключ значения, хранящегося в локальном хранилище | |
const [name, setName] = useLocalStorage("name", "Igor"); | |
return ( | |
<div> | |
<input |
This file contains hidden or 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 { useState, useRef, useEffect, useCallback } from "react"; | |
// использование | |
function App() { | |
// состояние для хранения координат курсора | |
const [coords, setCoords] = useState({ x: 0, y: 0 }); | |
// обработчик событий обернут в useCallback, | |
// поэтому ссылка никогда не изменится | |
const handler = useCallback( |
This file contains hidden or 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
[alias] | |
co = checkout | |
br = branch | |
ci = commit | |
di = diff | |
st = status --short --branch | |
pullhead = "!git pull origin $(git rev-parse --abbrev-ref HEAD)" |
This file contains hidden or 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
/** | |
* @docs https://dev.to/ruheni/fetch-is-all-you-need-e8f | |
*/ | |
const controller = new AbortController(); | |
const signal = controller.signal; | |
let url = 'https://jsonplaceholder.typicode.com/todos/1' | |
setTimeout(() => controller.abort(), 100); |
This file contains hidden or 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 default (block, element, modifier) => { | |
let prefix, ret; | |
if (!element) { | |
prefix = block; | |
} else { | |
prefix = block + '__' + element; | |
} | |
if (modifier) { | |
if (modifier instanceof Array) { |
This file contains hidden or 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
# Adds node_modules/.bin to the PATH | |
# vi -c ":set nobomb" -c ":wq" ~/.zshrc macOs utf-8 char problem | |
npm_chpwd_hook() { | |
if [ -n "${PRENPMPATH+x}" ]; then | |
PATH=$PRENPMPATH | |
unset PRENPMPATH | |
fi | |
if [ -f package.json ]; then | |
PRENPMPATH=$PATH | |
PATH=$(npm bin):$PATH |
This file contains hidden or 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
# | |
# Sets completion options. | |
# | |
# Authors: | |
# Robby Russell <[email protected]> | |
# Sorin Ionescu <[email protected]> | |
# | |
# Return if requirements are not found. | |
if [[ "$TERM" == 'dumb' ]]; then |