Skip to content

Instantly share code, notes, and snippets.

@codejets
codejets / flyweight.js
Last active March 21, 2016 08:22
flyweight pattern
// Flyweight Pattern
/*
Here we are sharing a part of our data into a separate object.
*/
(function() {
'use strict';
@codejets
codejets / facade.js
Last active March 20, 2016 08:53
facade pattern
// 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';
@codejets
codejets / decorators.js
Last active April 8, 2016 07:29
Decorators Pattern using Books eStore
// 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.
*/
@codejets
codejets / singleton.js
Last active March 28, 2016 04:11
Singleton Pattern
// Singleton Pattern
/*
In really simple terms, Singleton pattern is a initiation and caching service of your Object.
*/
var Todo = (function() {
'use strict';
var todo;
@codejets
codejets / module.js
Created March 19, 2016 20:21
module pattern
// 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() {
@codejets
codejets / constructor.js
Last active March 28, 2016 04:11
Constructor Pattern Implementation
/* 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';
@codejets
codejets / constructor.es6.js
Created March 19, 2016 19:51
ES6 implementation of Constructor Pattern
/* 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.
@codejets
codejets / Preferences.sublime-settings
Created March 16, 2016 19:39
current sublime preferences
{
"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,
[
{ "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"} },
]
@codejets
codejets / sublime-settings
Created March 13, 2016 05:49
Sublime Settings
{
"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,