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 / DeclareObjectsAsObjects.js
Created Oct 11, 2016
ES5 Declare Objects as Objects
View DeclareObjectsAsObjects.js
// 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 Jun 1, 2017
make Visual Code to hide .map and .js from the project folder panel view
View settings.json
{
"files.exclude" :{
"**/src/**/*.js.map": true,
"**/src/**/*.js": true
}
}
@leolanese
leolanese / Squash Git Commits.md
Last active Sep 20, 2017
squashing git commit
View Squash Git Commits.md

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:

View isObject
var isObject = (val) => val && typeof val === 'object';
View deepFreeze
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 Oct 23, 2018
UPGRADE & DOWNGRAGE angular-cli
View angular-cli-version
// 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 Oct 23, 2018
Function overloading OOP
View Function-overloading
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 Nov 16, 2018
downgrade NODE using NVM (installing NVM)
View downgrade NODE using 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 Dec 11, 2018
GIT Squashing (SAME BRANCH)
View GIT_Squashing
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
View gist:3f1234fa5948b51c997361a2331b7bbe
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