Skip to content

Instantly share code, notes, and snippets.

View leolanese's full-sized avatar
💻
[] === []; // false ¯\_(ツ)_/¯

Leo Lanese leolanese

💻
[] === []; // false ¯\_(ツ)_/¯
View GitHub Profile
@leolanese
leolanese / Show both Critical and High Issues
Created October 28, 2019 16:26
Show both Critical and High Issues
npm audit | grep -E "(High | Critical)" -B3 -A10
@leolanese
leolanese / fp-varadocCurry
Created October 28, 2019 15:18
fp-varadocCurry
/**
*
* @param varadocCurry
*
* @usage
* const toSum = varadocCurry((x, y) => x + y, 0);
* const toMul = varadocCurry((x, y) => x * y, 1);
*
* toSum(1)(1, 2)(3, 4)(5, 6, 7)(); // 29
* toMul(1)(1, 2)(3, 4); // 24
@leolanese
leolanese / fp-curry
Created October 28, 2019 15:17
fp-curry
/**
* @param curry
*
* @usage
* const _sum3 = (x, y, z) => x + y + z;
* const _sum4 = (p, q, r, s) => p + q + r + s;
*
* const sum3 = curry(_sum3);
* sum3(1)(3)(2); // 6
* const sum4 = curry(_sum4);
@leolanese
leolanese / deepFreeze
Created October 28, 2019 15:17
deepFreeze
export const deepFreeze = (object: object) => {
const propNames = Object.getOwnPropertyNames(object);
for (const num of propNames) {
const value = object[num];
object[num] = value && typeof value === 'object' ? deepFreeze(value) : value;
}
return Object.freeze(object);
};
@leolanese
leolanese / deepFreeze
Created October 28, 2019 15:17
deepFreeze
export const deepFreeze = (object: object) => {
const propNames = Object.getOwnPropertyNames(object);
for (const num of propNames) {
const value = object[num];
object[num] = value && typeof value === 'object' ? deepFreeze(value) : value;
}
return Object.freeze(object);
};
@leolanese
leolanese / css-editor-bookmark-2
Created October 28, 2019 15:13
css-editor-bookmark-2
javascript: (function() { var elements = document.body.getElementsByTagName('*'); var items = []; for (var i = 0; i < elements.length; i++) { if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) { items.push(elements[i]); } } if (items.length > 0) { for (var i = 0; i < items.length; i++) { items[i].innerHTML = ''; } } else { document.body.innerHTML += '<style>* { border: 1px solid red;}</style>'; } })();
javascript: (function() { var elements = document.body.getElementsByTagName('*'); var items = []; for (var i = 0; i < elements.length; i++) { if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) { items.push(elements[i]); } } if (items.length > 0) { for (var i = 0; i < items.length; i++) { items[i].innerHTML = ''; } } else { document.body.innerHTML += '<style>* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }\ * * { background-color: rgba(0,255,0,.2) !important; }\ * * * { background-color: rgba(0,0,255,.2) !important; }\ * * * * { background-color: rgba(255,0,255,.2) !important; }\ * * * * * { background-color: rgba(0,255,255,.2) !important; }\ * * * * * * { background-color: rgba(255,255,0,.2) !important; }\ * * * * * * * { background-color: rgba(255,0,0,.2) !important; }\ * * * * * * * * { background-c
@leolanese
leolanese / sonar-jenkins
Created October 28, 2019 15:12
sonar-jenkins
node{
stage('SCM Checkout'){
git 'https://github.com/javahometech/my-app'
}
stage('Compile-Package'){
// Get maven home path
def mvnHome = tool name: 'maven-3', type: 'maven'
sh "${mvnHome}/bin/mvn package"
}
@leolanese
leolanese / !nocommit
Last active August 9, 2019 16:18
!nocommit
# include this into the file: .git\hooks\pre-commit
# pre-commit to avoid debugger
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
no_color='\033[0m'
if git commit -v --dry-run | grep 'debugger' >/dev/null 2>&1
then
function isPalindrome(str) {
str = str.replace(/\W/g, '').toLowerCase();
return (str == str.split('').reverse().join(''));
}
console.log(isPalindrome("level")); // logs 'true'
console.log(isPalindrome("levels")); // logs 'false'
console.log(isPalindrome("A car, a man, a maraca")); // logs 'true'