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 / DeclareObjectsAsObjects.js
Created October 11, 2016 10:31
ES5 Declare Objects as Objects
// ES5 Declare Objects as Objects:
// not that good
var service = {};
service.winJsApp = null;
service.winJSActivation = 1;
service.actions = {
goToView: "goToView",
goToModal:"goToModal"
};
@leolanese
leolanese / settings.json
Created June 1, 2017 11:05
make Visual Code to hide .map and .js from the project folder panel view
{
"files.exclude" :{
"**/src/**/*.js.map": true,
"**/src/**/*.js": true
}
}
@leolanese
leolanese / Squash Git Commits.md
Last active September 20, 2017 15:24
squashing git commit

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

var isObject = (val) => val && typeof val === 'object';
function deepFreeze(obj) {
if(isObject(obj) && !Object.isFrozen(obj)) {
Object.keys(obj).forEach(name => deepFreeze(obj[name]));
Object.freeze(obj);
}
return obj;
}
@leolanese
leolanese / angular-cli-version
Created October 23, 2018 14:03
UPGRADE & DOWNGRAGE angular-cli
// UPGRADE
ng v
sudo npm uninstall -g angular-cli
sudo npm uninstall angular-cli
sudo npm cache verify
sudo npm install -g @angular/cli@latest
sudo npm install @angular/cli@latest
@leolanese
leolanese / Function-overloading
Created October 23, 2018 14:05
Function overloading OOP
Function overloading OOP
// overload declaration
function sum(a: number, b: number): number;
function sum(a: string, b: number): number;
function sum(a: number, b: string): number;
function sum(a: string, b: string): number;
// overload definiton
function sum(a,b){
@leolanese
leolanese / downgrade NODE using NVM
Created November 16, 2018 21:03
downgrade NODE using NVM (installing NVM)
NVM
node -v
npm install -g nvm
export PATH=./node_modules/.bin:$PATH
git clone git://github.com/creationix/nvm.git ~/.nvm
printf "\n\n# NVM\nif [ -s ~/.nvm/nvm.sh ]; then\n\tNVM_DIR=~/.nvm\n\tsource ~/.nvm/nvm.sh\nfi" >> ~/.bashrc
NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
npm config delete prefix
@leolanese
leolanese / GIT_Squashing
Created December 11, 2018 14:50
GIT Squashing (SAME BRANCH)
GIT Squashing (SAME BRANCH)
> let me rebase all commits for this branch (origin)
(Branch):
git add -A
git commit -m ‘ADCON-xxxx: lalalala'
git rebase -i master
DELETE LOCAL BRANCH
To delete the local branch use one of the following:
$ git branch -d branch_name
$ git branch -D branch_name
-=-=-=-=-=-
DELETE REMOTE BRANCH