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
var a = (...n) => { | |
console.log(n[1]) | |
}; | |
a([1,2,3],[3,4,5],[6,7,8]) // -> [3,4,5] |
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
//when function scope sucks, and you have to cache 'this' | |
let a = function() { | |
let that = this; | |
this.val = 1; | |
setTimeout(function() { | |
that.val++; | |
console.log(that.val) | |
}, 1) | |
}; |
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
// pure function | |
// evaluates the same result given the same args | |
// doesn't depend on and doesn't modify the states of variables outside it's scope | |
// no side effects (mutations, async reqs) | |
var foods = ['beans', 'rice', 'pizza', 'pineapple'] | |
// slice (shallow modified copy of array) vs splice (modifies original array) | |
foods.slice(0,3) //returns ['beans', 'rice', 'pizza'] |
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
<Helmet | |
meta={ [ | |
{ | |
name: "generator", content: `${ | |
process.env.PHENOMIC_NAME } ${ process.env.PHENOMIC_VERSION }`, | |
}, | |
{ property: "og:site_name", content: pkg.name }, | |
{ name: "twitter:site", content: `@${ pkg.twitter }` }, | |
] } | |
script={ [ |
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
const createStore = (reducer) => { | |
let state; | |
let listeners = []; | |
const getState = () => state; | |
const dispatch = (action) => { | |
state = reducer(state, action); | |
listeners.forEach(listener => listener()); | |
}; |
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
class Animal { | |
constructor(race) { | |
this.race = race; | |
} | |
} | |
class Cat extends Animal { | |
constructor(race) { | |
super(race); | |
} |
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, | |
"args": | |
{ | |
"name": "Packages/Babel Snippets/react_wrap.sublime-snippet" | |
}, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/User/SublimeLinter/Material-Theme-OceanicNext (SL).tmTheme", | |
"command": "insert_snippet", | |
"detect_indentation": 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
:first-child i === 0 | |
:last-child i === arr.length - 1 | |
:only-child arr.length === 1 | |
:nth-child(even) i % 2 | |
:nth-child(odd) !(i % 2) | |
:nth-child(n) i === n - 1 | |
:nth-last-child(n) i === arr.length - n |
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
--multiple CTEs per statement | |
WITH | |
ProductQty AS ( | |
SELECT | |
ProductId, | |
LocationId, | |
Shelf, | |
Bin, | |
Quantity |
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
WITH | |
ProductQty (PID, LID, Shelf, Bin, Qty) AS | |
(SELECT | |
ProductId, LocationId, Shelf, Bin, Quantity | |
FROM | |
Production.ProductInventory) | |
SELECT | |
p1.PID, | |
SUM(p1.Qty) AS ShelfQty_A, |