Skip to content

Instantly share code, notes, and snippets.

@hendrikkao1
hendrikkao1 / is-prime.js
Created April 1, 2020 08:11
Check if number is Prime or not
function isPrime(num) {
const root = Math.sqrt(num);
if (root <= 1) {
return false;
}
for (let i = 2; i <= root; i++) {
if (num % i === 0) {
return false;
@hendrikkao1
hendrikkao1 / is-opening-hours.js
Created June 6, 2019 14:58
Function to check if current day and time fit the opening hours
/**
* Function to check if current day and time fit the opening hours.
* @param {number[]} openDays - Array of days represented as numbers, sunday - saturday : 0 - 6.
* @param {number} openingTime - Opening time in minutes, 9:00 : 9 * 60.
* @param {number} closingTime - Closing time in minutes 17:00 : 17 * 60.
* @return {boolean}
*/
function isOpeningHours(openDays = [1, 2, 3, 4, 5], openingTime = 9 * 60, closingTime = 17 * 60) {
const date = new Date();
@hendrikkao1
hendrikkao1 / check-encoding.sh
Created March 21, 2015 19:20
Check the encoding of .htm, .html and .xml files in the directory
#!/bin/sh
for f in `find . -name "*.htm" -o -name "*.html" -o -name "*.xml"` ;
do
echo `file -I "$f"` ;
done
@hendrikkao1
hendrikkao1 / flexbox-grid.css
Last active September 10, 2016 02:34
Equal height columns for Bootstrap grid
@supports (display: flex) {
.row--flex {
display: flex;
flex-wrap: wrap;
}
.row--flex:before,
.row--flex:after,
.row--flex > .clearfix:before,