Skip to content

Instantly share code, notes, and snippets.

View MrRedu's full-sized avatar
:electron:
help, I don't understand

Eduardo MrRedu

:electron:
help, I don't understand
View GitHub Profile
@theKAKAN
theKAKAN / getDirection.js
Created February 14, 2021 17:09
Convert degrees or angles to cardinal direction
function getDirection( angle ){
// We divide it into 16 sections
let directions = ["N","NNE","NE","ENE","E",
"ESE", "SE", "SSE","S",
"SSW","SW","WSW","W",
"WNW","NW","NNW" ];
// This means, every 360 / 16 degree, there's a section change
// So, in our case, every 22.5 degree, there's a section change
// In order to get the correct section, we just need to divide
let section = parseInt( angle/22.5 + 0.5 );
@ch1nux
ch1nux / Utils.js
Last active January 27, 2025 15:57
Javascript Utilities for several things
/**
* Detect words in a paragraph.
* @type {RegExp} ['word', 'word', ...]
*/
export const WORDS = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g
/**
* Detect a valid Venezuelan phone number (area code included)
* @type {RegExp}
*/