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
// Return "infinite" sequence of HSL colors | |
function* colorMaker({distance = 1, saturation, luminosity, shift = 0}) { | |
let colorIndex = 0 | |
while (true) { | |
const hue = (colorIndex * distance + shift) % 359 | |
yield `hsl(${hue}, ${saturation}%, ${luminosity}%)` | |
colorIndex++ | |
} | |
} |
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
async function retry(foo, count = 1, delay) { | |
let error; | |
while (count--) { | |
try { | |
return foo() | |
} catch (e) { | |
error = e | |
await timeout(delay) | |
} |
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
/* | |
101 - 100 | |
12 - 12 | |
12.3 - 12 | |
1.45 - 1.4 | |
*/ | |
N = 2 | |
parseFloat(a.toPrecision(N)) |
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=$(cat package.json | jq -r '.dependencies * .devDependencies | keys | join("\n")') | |
ARR=', ' read -r -a array <<< $FILES | |
echo Not found deps | |
echo | |
for dep in "${array[@]}" | |
do | |
grep -qr "$dep" src |
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
// item = {id: 'uniq id', field: 1, fielda: 'a'} | |
listOfItems.reduce((a, i) => ({...a, [i.id]:i}), {}) |
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
/* @flow */ | |
/* eslint-disable no-console */ | |
/* | |
* Логгер, создается в разных контекстах | |
* Имеет внутренний стейт, так как должнен быть создан и начать | |
* работать до запуска основных модулей | |
* | |
* Доступные уровни: ALL, WARN, ERROR, SILENT | |
* |
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
#!/bin/sh | |
# Input params | |
DOMAIN=$1 | |
UPSTREAM_PORT=$2 | |
# Check if config already exist (no overwrite) | |
if [ -f /etc/nginx/servers/$DOMAIN ]; then | |
echo "Config /etc/nginx/servers/$DOMAIN already exist. Remove it for continue" | |
exit 1; |
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! s:encodeURIComponent(str) | |
let s = '' | |
for i in range(strlen(a:str)) | |
let c = a:str[i] | |
if c =~# "[A-Za-z0-9-_.!~*'()]" | |
let s .= c | |
else | |
let s .= printf('%%%02X', char2nr(a:str[i])) | |
endif | |
endfor |
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
class LineStream extends Transform { | |
constructor(...args) { | |
super(...args); | |
this.buffer = ''; | |
} | |
_transform(chunk, encoding, callback) { | |
const lines = chunk.toString().split('\n'); | |
lines[0] = this.buffer + lines[0]; |
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
on run {input, parameters} | |
set myPath to POSIX path of input | |
set cmd to "vim " & quote & myPath & quote | |
tell application "iTerm" | |
activate | |
set newWindow to (create window with default profile) | |
tell current session of newWindow | |
write text cmd | |
end tell |