This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Easily generate a random hex color in JS: | |
"#" + Math.floor(Math.random() * 16777215).toString(16).toUpperCase(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Flyweight Pattern | |
/* | |
Here we are sharing a part of our data into a separate object. | |
*/ | |
(function() { | |
'use strict'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Facade Pattern | |
/* | |
Facade pattern are most commonly used in combination with other patterns like module pattern. | |
Here we will create facade from a module. | |
*/ | |
var module = (function() { | |
'use strict'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Decorators Pattern | |
/* | |
We will create a Book Object with constructor to initialize Name, | |
Author, Ratings and Cost. | |
Then we will add decorators to add feature to the Book object for | |
some Ebooks. | |
*/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Singleton Pattern | |
/* | |
In really simple terms, Singleton pattern is a initiation and caching service of your Object. | |
*/ | |
var Todo = (function() { | |
'use strict'; | |
var todo; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Module Pattern | |
/* | |
In Simple terms, Module pattern is a collection of functions in a object literal. | |
*/ | |
/* | |
We will make a simple service to store and retrive data from localStorage. | |
*/ | |
(function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* We will use an IIFE wrapping-function to keep the global scope clean and | |
to prevent things from being created in the global scope. We will use strict mode in a controlled enviroment, | |
also without triggering it in the global scope. */ | |
var Todo = (function() { | |
'use strict'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* We now a have clean class based design like other languages out there.*/ | |
class todo { | |
constructor(name) { | |
// Adds the name of the object | |
this.name = name; | |
// As Default completed is set to false. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"always_show_minimap_viewport": true, | |
"auto_complete": true, | |
"auto_indent": true, | |
"bold_folder_labels": false, | |
"caret_style": "phase", | |
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme", | |
"default_encoding": "UTF-8", | |
"detect_indentation": true, | |
"draw_indent_guides": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "keys": [":", "v", "s", "p"], "command": "create_pane", "args": {"direction": "right", "give_focus": true} }, | |
{ "keys": [":", "s", "p"], "command": "create_pane", "args": {"direction": "down", "give_focus": true} }, | |
{ "keys": [":", "b", "d"], "command": "destroy_pane", "args": {"direction": "self"} }, | |
] |