Skip to content

Instantly share code, notes, and snippets.

View SeLub's full-sized avatar
🎯
Focusing

Sergey Lubimov SeLub

🎯
Focusing
View GitHub Profile
@SeLub
SeLub / gist:f3d61ae628d500e022f28822ad611127
Last active February 8, 2024 06:23
Remove or recover last commit pushed to git

Delete last commit from git

First way

git reset --hard HEAD~1
git push --force

Another way

Task

console.log '1' after 1 second,
'2' after 2 seconds and
'3' after 3 seconds after start of the program.

setTimeout

The delay parameter only guarantees that your callback will not execute before that time has elapsed. Other queued tasks or operations could delay it further than the specified time.

const startTime = process.hrtime();

Binary Search Task

Task: We have an array sorted in ascending order:

a = [ 3, 4, 6, 9, 10, 12, 14, 15, 17, 19, 21 ]; Define a function f(a, x) that would return x, the nearest smallest number, or -1 on error.

Example: