Skip to content

Instantly share code, notes, and snippets.

View blazsmaster's full-sized avatar
📚
Currently digitizing all school materials from the past year.

Blazs blazsmaster

📚
Currently digitizing all school materials from the past year.
View GitHub Profile
@blazsmaster
blazsmaster / date_and_time.js
Last active November 7, 2022 15:41
Regex expressions in javascript
// YYYY-MM-dd
// using separator -
// https://www.regexpal.com/?fam=104039
function isDate(value) {
return /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/.test(value)
}
// dd-MM-YYYY
// using separators - or . or /
// https://regexr.com/?346hf
@blazsmaster
blazsmaster / shuffleArray.js
Created August 23, 2022 10:07
Simple way to shuffle an array
/**
* @param {Array} array
* @returns {Array}
*/
function shuffleArray(array) {
let currentIndex: number = array.length;
let randomIndex: number;
while (currentIndex !== 0) {
randomIndex = Math.floor(Math.random() * currentIndex);
@blazsmaster
blazsmaster / scrollUp.html
Created August 30, 2021 11:33
Simple scroll up script for html websites.
<button type="button" id="topButton" onclick="topFunction()">Top</button>
<style>
#topButton {
display: none;
position: fixed;
bottom: 25px;
right: 30px;
z-index: 99;
}
</style>