Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
null !== undefined but null == undefined ¯\_(ツ)_/¯

Leo Lanese leolanese

💻
null !== undefined but null == undefined ¯\_(ツ)_/¯
View GitHub Profile
@leolanese
leolanese / GIT_squashing
Created Dec 11, 2018
GIT SQUASHING (another branch):
View GIT_squashing
GIT SQUASHING (another branch):
ok, do work on branches branches … lalala
git add -A
git commit -m 'TEAM-XXX'
Switch to the master branch and make sure you are up to date:
git checkout master && git fetch && git pull
@leolanese
leolanese / gist:b531169c374ab61cc9c5ed9dcff6e5b0
Created Feb 28, 2019
The function creates a new function that adds a delay in milliseconds to the execution of another function that is passed as an argument.
View gist:b531169c374ab61cc9c5ed9dcff6e5b0
function addDelay(func: () => void, ms: number) {
return () => {
setTimeout(() => {
func();
}, ms);
};
}
function sayHello() {
console.log('Hello world!');
@leolanese
leolanese / JavaScript Palindrome checker
Created Apr 19, 2019
JavaScript Palindrome checker
View JavaScript Palindrome checker
/*
JavaScript Palindrome checker
*/
// Example
const string1 = 'level',
const string2 = 'Le, vel.';
// Function can take up to two strings
const isPalindrome = (str1, str2) => {
View gist:06acd13f5ac1d78615065044c71a2a7e
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'
View !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
View 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"
}
View css-editor-bookmark
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
View 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>'; } })();
View 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);
};
View 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);
};