Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / random-hex-color
Created November 22, 2016 12:38
random hex color codes
Easily generate a random hex color in JS:
"#" + Math.floor(Math.random() * 16777215).toString(16).toUpperCase();
@codejets
codejets / Agile-Works.md
Created September 18, 2017 18:04
Agile works

Agile Works!

Building and delivering Small modules in sprints over the whole application at once.

Agile Manifesto:

  1. Individuals and interactions over processes and tools
  2. Working Software over Comprehensive Document
  3. Customer Collaboration over Contract Negotiation
  4. Responding to change over initial plan
  5. Change of plan anytime during development
@codejets
codejets / pie_test.csv
Last active September 20, 2017 11:05
pie_test.csv
age population color
<5 2704659 #30343F
5-13 4499890 #FAFAFF
14-17 2159981 #E4D9FF
18-24 3853788 #273469
25-44 14106543 #87B37A
45-64 8819342 #E2D58B
≥65 612463 #F9D4BB
@codejets
codejets / mock-data.tsv
Last active September 20, 2017 11:25
mock-data.tsv
date New York San Francisco Austin
20111001 63.4 62.7 72.2
20111002 58.0 59.9 67.7
20111003 53.3 59.1 69.4
20111004 55.7 58.8 68.0
20111005 64.2 58.7 72.4
20111006 58.8 57.0 77.0
20111007 57.9 56.7 82.3
20111008 61.8 56.8 78.9
20111009 69.3 56.7 68.8
@codejets
codejets / simpleDragnDrop.js
Last active December 9, 2017 06:37
Simple drag and drop
import React from "react";
const styles = {
width: "200px",
border: '1px solid #222',
height: "200px",
display: "inline-block",
verticalAlign: "top",
background: "#fff"
};