var
var happyDays = function(day){
if(day === 'sunny') {
var a = 'apples'; //a is function-scoped
}
console.log(a); // apples
}
var
var happyDays = function(day){
if(day === 'sunny') {
var a = 'apples'; //a is function-scoped
}
console.log(a); // apples
}
# /etc/nginx/sites-enabled/some.domain | |
# Change the server name {some.domain} | |
# Change the {host.of.notebook} and {port} in the following locations | |
server { | |
listen 80; | |
# Change the server name {some.domain} | |
server_name some.domain; | |
location / { | |
# Change the {host.of.notebook} and {port} | |
proxy_pass http://host.of.notebook:port; |
import HighlightJS from 'highlight.js' | |
createHighlightedCodeBlock (content, language) { | |
let lineNumber = 0 | |
const highlightedContent = HighlightJS.highlightAuto(content, [language]).value | |
/* Highlight.js wraps comment blocks inside <span class="hljs-comment"></span>. | |
However, when the multi-line comment block is broken down into diffirent | |
table rows, only the first row, which is appended by the <span> tag, is | |
highlighted. The following code fixes it by appending <span> to each line |
{ | |
"parser": "babel-eslint", | |
"plugins": [ | |
"react", | |
"react-native" | |
], | |
"parserOptions": { | |
"ecmaFeatures": { | |
"jsx": true, | |
"modules": true |
function resolvePromise(promise, iterator) { | |
promise.then( | |
(response) => { | |
let result = iterator.next(response); | |
if (!result.done) { | |
sync(result.value, iterator); | |
} | |
}, | |
error => { | |
let result = iterator.next(error); |
'use strict' | |
const timeout = ms => new Promise(res => setTimeout(res, ms)) | |
function convinceMe (convince) { | |
let unixTime = Math.round(+new Date() / 1000) | |
console.log(`Delay ${convince} at ${unixTime}`) | |
} | |
async function delay () { |
let master = () => { | |
return new Promise( (resolve, reject) => { | |
setTimeout(() => { resolve('ok'); }, 3000); | |
}); | |
} | |
let slaves = [ | |
{ | |
start: () => { | |
console.log("loading") |
A well-thought structure is helpful for the maintainability of the code.
It also helps to avoid some common anti-patterns.
A redux application is not necessary a big thing, it can also be a component that is complex enough to require redux.
There are the only 2 rules to comply with, so it is not painful to always have them in mind while developing.
List() | |
var list = Immutable.List([1,2,3]) | |
// [1, 2, 3] | |
List.isList() | |
Immutable.List.isList(list) | |
// true | |
List.of() | |
var list = Immutable.List.of(1,2,3); |