Skip to content

Instantly share code, notes, and snippets.

View radislaw's full-sized avatar

Radik Yalilov radislaw

View GitHub Profile
@radislaw
radislaw / machine.js
Last active April 14, 2021 06:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@radislaw
radislaw / machine.js
Created December 24, 2020 11:01
Generated by XState Viz: https://xstate.js.org/viz
const toggleStates = {
key: 'toggle',
initial: 'inactive',
states: {
inactive: {
on: {
TOGGLE: 'active',
}
},
active: {
@radislaw
radislaw / shunt.js
Created October 9, 2019 00:18
A JavaScript Implementation of Edsger Wybe Dijkstra's Shunting Yard Algorithm.
function Parser(table) {
this.table = table;
}
Parser.prototype.parse = function (input) {
var length = input.length,
table = this.table,
output = [],
stack = [],
index = 0;
@radislaw
radislaw / branchCreatedDate.txt
Created July 20, 2018 06:52
show date when branch created
git reflog show --date=local --all | sed 's!^.*refs/!refs/!' | grep '/branch-name' | tail -1
@radislaw
radislaw / slider.js
Created July 3, 2018 09:03
hide buttons in first and last slide in swiper
let productShowcase = this.initSwiper('.product-showcase', {
slidesPerView: 3,
onInit(e) {
if(e.isBeginning) {
e.prevButton[0].style.display = 'none'
}
},
})
productShowcase.forEach((item) => {
@radislaw
radislaw / isLeapYear.js
Created June 28, 2018 06:12
isLeapYear
const isLeapYear = (year) => {
return !(year % 4) && (!!(year % 100) || !(year % 400))
},
@radislaw
radislaw / logPageLoadedTime.js
Created March 30, 2018 04:32
log to console page loaded time
function getCurrentTime() {
const date = new Date();
let h = date.getHours();
let m = date.getMinutes();
let s = date.getSeconds();
h = h < 10 ? `0${h}` : h;
m = m < 10 ? `0${m}` : m;
s = s < 10 ? `0${s}` : s;
@radislaw
radislaw / icrease_heap.txt
Created August 23, 2017 00:07
Increasing memory in elasicsearch < 5
Edit the following files to modify memory and file number limits. These instructions assume Ubuntu 10.04, may work on later versions and other distributions/OSes. (Edit: This works for Ubuntu 14.04 as well.)
/etc/security/limits.conf:
elasticsearch - nofile 65535
elasticsearch - memlock unlimited
--------------------------------------------------------------------------
/etc/default/elasticsearch (on CentOS/RH: /etc/sysconfig/elasticsearch ):
@radislaw
radislaw / formatedPhone.js
Last active August 15, 2017 05:44
regexp for add space to phone number
const phone = "+79009999999"
const formatedPhone = phone.replace(/(\d{1})(\d{3})(\d{3})(\d{2})(\d{2})/, '$1 ($2) $3-$4-$5');
// -> "+7 (900) 999-99-99"
computed: {
someComputedProp() {
// You must return function with argument
return (argument) => doStuffWith(argument)
}
}