View modern-js-patterns
//Factory and Decorator
https://medium.com/@tomchentw/redux-universal-576fb9475b5b
https://github.com/redux-saga/redux-saga
https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841
//Singleton
https://medium.com/@cymen/redux-and-the-store-dd9de854d5be
//Command
https://medium.com/front-end-developers/the-command-pattern-c51292e22ea7
View gist:a78e3a1d8f872f979ff7df92f4eb46c7
//Optional Default params
//es6
function myFunc({name = 'Default user', age = 'N/A'} = {}) {
}
//es5 via babeljs.io
'use strict';
function myFunc() {
View handlebarsHelpers.js
Handlebars.registerHelper('compare', function (lvalue, operator, rvalue, options) {
var operators, result;
if (arguments.length < 3) {
throw new Error("Handlerbars Helper 'compare' needs 2 parameters");
}
if (options === undefined) {
options = rvalue;
View keymap.cson
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'
'atom-text-editor[data-grammar="text html mustache"]:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'
'atom-text-editor[data-grammar="text html handlebars"]:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'
View udacityframeworks.js
var numLetters = function(letter) {
return new Function("num", "return ('" + letter + "').repeat(num)");
}
View curry.js
var curryIt = function(uncurried) {
var parameters = Array.prototype.slice.call(arguments, 1);
return function() {
return uncurried.apply(this, parameters.concat(
Array.prototype.slice.call(arguments, 0)
));
};
};
View regex.js
//Search for a function
let r = /\((.*)\).*\{([\s\S]*)\}/m
function sayHello(msg) {
console.log(msg);
}
r.exec(sayHello.toString());
View scssbestpractice.scss
%button {
// … button styles
+ %button {
margin-left: 1rem;
}
}
%modal {
// … modal styles
View ycombinator.js
// Credits: http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/
// Ymem takes a functional and an (optional)
// cache of answers.
// It returns the fixed point of the functional
// that caches intermediate results.
function Ymem(F, cache) {
if (!cache)
cache = {} ; // Create a new cache.
View gist:0e869e20279c256928d73181ca5d71a7
1. Write semantic and accessible HTML5
Goals:
+ Avoid div soup/code bloat
+ Accessibiity
+ Improve SEO
a/ Semantic aka has meaning
http://html5doctor.com/downloads/h5d-sectioning-flowchart.pdf
b/ Content models:
https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#kinds-of-content