Skip to content

Instantly share code, notes, and snippets.

View eoikonomou's full-sized avatar

Efstathios Oikonomou eoikonomou

View GitHub Profile
@eoikonomou
eoikonomou / removeAccents.js
Last active September 6, 2024 12:39
Remove accents
function removeAccents(str) {
if (!str) {
return ''
}
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
}
@eoikonomou
eoikonomou / nvm-auto-use.md
Last active March 8, 2024 09:17
NVM auto use instructions

NVM automatic version change

Linux Users

Make sure that the correct curl is used in your machine.

  1. Uninstall curl if it is installed using snap by running sudo snap remove curl.
  2. Install curl using apt-get by running sudo apt-get install curl. This is done due to permissions issues with snap curl.

Install nvm if you haven't done so already by running curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash.

@eoikonomou
eoikonomou / promise_all.js
Last active June 13, 2023 18:48
Promise all function replacement
function promiseAll(promises, results = []) {
return new Promise((resolve, reject) => {
const results = [];
if (!promises.length) {
return resolve(results);
}
let pendingPromises = promises.length;
@eoikonomou
eoikonomou / consoleColors.js
Created February 22, 2022 08:33 — forked from abritinthebay/consoleColors.js
The various escape codes you can use to color output to StdOut from Node JS
// Colors reference
// You can use the following as so:
// console.log(colorCode, data);
// console.log(`${colorCode}some colorful text string${resetCode} rest of string in normal color`);
//
// ... and so on.
export const reset = "\x1b[0m"
export const bright = "\x1b[1m"
export const dim = "\x1b[2m"
@eoikonomou
eoikonomou / delete_merged_branches.sh
Created April 20, 2020 07:35
Delete merged branches
git branch -d $(git branch --merged |tail -n +2)
@eoikonomou
eoikonomou / mockCanvas.js
Created February 7, 2020 14:29
Mocking canvas for tests
//
// Mock Canvas / Context2D calls
//
function mockCanvas (window) {
window.HTMLCanvasElement.prototype.getContext = function () {
return {
fillRect: function() {},
clearRect: function(){},
getImageData: function(x, y, w, h) {
return {
@eoikonomou
eoikonomou / disableContextMenuPopup.js
Created February 3, 2020 14:52
Disable context menu popup on long touch in android devices
// disable context menu popup on touch devices
window.oncontextmenu = () => false;
@eoikonomou
eoikonomou / marquee.html
Created January 21, 2020 10:12
Maquee effect (Scrolling text)
<!DOCTYPE html>
<html>
<title>Marque effect</title>
<head>
<style>
div {
background-color: #1c87c9;
color: #fff;
padding: 5px;
width: 400px;
@eoikonomou
eoikonomou / sleep.js
Created January 9, 2020 12:31
Sleep function for javascript
/**
* Sleep for ms milliseconds
* @param ms
*/
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
};
@eoikonomou
eoikonomou / hideDeveloperTools.js
Created October 23, 2019 13:24
Disable developer tools
document.onkeydown = function (event) {
if (event.keyCode == 123) { // Prevent F12
return false;
} else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) { // Prevent Ctrl+Shift+I
return false;
}
};
// Hides context menu on right click of the mouse to prevent right click - inspect
document.oncontextmenu = function (e) {
e.preventDefault();