Visit my blog or connect with me on Twitter
git init
or
| local function ex1( a, ... ) | |
| if a then | |
| print(a) | |
| return ex1( ... ) | |
| end | |
| end |
| local function ex1( a, ... ) | |
| if a then | |
| print(a) | |
| return ex1( ... ) | |
| end | |
| end |
| // Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/ | |
| // Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch | |
| // async function | |
| async function fetchAsync () { | |
| // await response of fetch call | |
| let response = await fetch('https://api.github.com'); | |
| // only proceed once promise is resolved | |
| let data = await response.json(); | |
| // only proceed once second promise is resolved |
Visit my blog or connect with me on Twitter
git init
or
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import { style, hover, active, media } from 'glamor'; | |
| const button = { | |
| backgroundColor: '#ff0000', | |
| width: 320, | |
| padding: 20, | |
| borderRadius: 5, | |
| border: 'none', |
| class Parent extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.doSomething = this.doSomething.bind(this); | |
| } | |
| doSomething(value) { | |
| // expecting value to be 'hello' | |
| // ... | |
| } |
| /* Let's pretend we have a tab delimited list of data as seen below | |
| data.txt | |
| name gender age | |
| --- | |
| derrik nasca male 31 | |
| kathleen nasca female 27 | |
| bernie nasca male 1 | |
| toes nasca female 5 | |
| --- |
| // 3 ways to reduce from an array | |
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce?v=a) | |
| var orders = [ | |
| { amount: 100 }, | |
| { amount: 200 }, | |
| { amount: 300 }, | |
| { amount: 400 }, | |
| ] |
| var foods = [ | |
| { name: 'brocolli', type: 'vegetable' }, | |
| { name: 'spinach', type: 'vegetable' }, | |
| { name: 'apple', type: 'fruit' }, | |
| { name: 'tomato', type: 'fruit' }, | |
| { name: 'bread', type: 'grain' }, | |
| { name: 'beef', type: 'meat' }, | |
| { name: 'chicken', type: 'meat' }, | |
| ] |
| a |