Sticky Notes

Get random number withing a range in JS

//min - inclusive, max - exclusive
function getRandom(min, max) {
    return Math.random() * (max - min) + min;
}

//random integer
function getRandomInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

Handle changes made in wrong git branch

This happens very often when you forget to create a new branch and make some changes in the same branch.

This will create a new branch named “new-branch” and move all your changes to it.

git switch -c "new-branch"
"Be so good they can't ignore you." - Steve Martin