Skip to content

Instantly share code, notes, and snippets.

View ecuyar's full-sized avatar

Enes Can UYAR ecuyar

  • Kayseri, TURKEY
View GitHub Profile
@ecuyar
ecuyar / gist:25a430942056c757dd9ce7a2cab722f6
Created October 30, 2024 19:47
Get elapsed time in C#
long startTime = Stopwatch.GetTimestamp();
TimeSpan delta = Stopwatch.GetElapsedTime(startTime);
/*
This method doesn't create a class or else, so no extra allocation for heap.
Extra efficient and precise.
*/
@ecuyar
ecuyar / gist:6e1c047d81b8e5356e93930f7aecd234
Created March 19, 2022 08:58
Disable form submitting with validating it
function handleSubmit (e) {
e.preventDefault();
var form = document.getElementById("formId");
form.checkValidity();
form.reportValidity();
//return value of .checkValidity() can bu used for more detailed validation
}
@ecuyar
ecuyar / recover-deleted-branch.sh
Created February 18, 2022 22:17 — forked from umayr/recover-deleted-branch.sh
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}