Skip to content

Instantly share code, notes, and snippets.

View mykolaharmash's full-sized avatar

Mykola Harmash mykolaharmash

View GitHub Profile
Check which process on which port
lsof -i -n -P
fucntion fn () {
setImmediate(function () {
console.log('setImmediate');
});
process.nextTick(function () {
console.log('nextTick');
});
}
reindent region C-M-\
cut region C-w
copy region M-w
yank C-y
kill window C-x 0
kill window and buffer C-x 4 0
goto line M-g
join current line to upper one M-^
Seach next C-s
alias served="ruby -r webrick -e \"s = WEBrick::HTTPServer.new(:Port => 9090, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start\""
cd $HOME
rm .bash_it 2>/dev/null
rm .bashrc 2>/dev/null
rm .bash_profile 2>/dev/null
rm .vimrc 2>/dev/null
rm .tmux.conf 2>/dev/null
rm .viminfo 2>/dev/null
rm -rf .vim 2>/dev/null
rm -rf .dotfiles 2>/dev/null
rm -rf .tmux 2>/dev/null
@mykolaharmash
mykolaharmash / bootstrap.sh
Last active January 28, 2017 13:20
bootstrap script for nik-garmash/.dotfiles
cd $HOME
git clone git@github.com:nik-garmash/.dotfiles.git
cd $HOME/.dotfiles
git submodule init && git submodule update
cd $HOME
if [ -f .bashrc ]
then
mv .bashrc .bashrc.b
fi
function clientRender () {
let root = document.body
function createElement (name, attrs, children) {
let element = document.createElement(name)
Object.keys(attrs).forEach((attrName) => {
element.setAttribute(attrName, attrs[attrName])
})
show_exit_code() {
local ex=$?
if [ $ex -ne 0 ]
then
echo -e "\033[0;31m$ex\033[0m"
fi
}
PROMPT_COMMAND="show_exit_code;$PROMPT_COMMAND"
/*
Реализация i-statefull-block
https://github.yandex-team.ru/Metrika/metrika-contrib/tree/master/blocks/common/i-statefull-block
*/
BEM.DOM.decl({block: 'stateful-parent', baseBlock: 'i-statefull-block'}, {
onSetMod: {
js: function () {
this._model = BEM.blocks['m-parent'].create();
this.setStateModel(this._model);
@mykolaharmash
mykolaharmash / bench.js
Last active November 11, 2019 14:20
Collect all the links within HTML string and report performance (cheerio, jsdom, hyntax)
const fs = require('fs')
const { PerformanceObserver, performance } = require('perf_hooks');
const cheerio = require('cheerio')
const { JSDOM } = require("jsdom")
const { tokenize, constructTree } = require('hyntax')
const html = fs.readFileSync('./github.html').toString()
const obs = new PerformanceObserver((items) => {
console.log(items.getEntries())