This file contains 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
async function func () { | |
const url = 'https://maps.googleapis.com/maps/api/geocode/json?address=94043&sensor=false'; | |
const { results: [ result ] } = await fetch(url).then((response) => response.json()); | |
return JSON.stringify(result, null, 2); | |
} | |
func().then(console.log.bind(console)); | |
/* |
This file contains 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 promisify = require("promisify-node"); | |
function makeItAsync(callback) { | |
callback(null, true); | |
} | |
// Convert the function to return a Promise. | |
var wrap = promisify(makeItAsync); | |
// Invoke the newly wrapped function. |
This file contains 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
// promisify-node is necessary to turn node callback functions in Promises | |
let promisify = require("promisify-node"); | |
let fs = promisify('fs'); | |
let path = require('path'); | |
let dir = '/home/jaydson.gomes/public_html'; | |
async function statDir() { | |
// Asynchronous node fs.readdir return Promises | |
let list = await fs.readdir(dir); |
This file contains 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
(function($) { | |
function parseImagesFromCSS(doc) { | |
var i, j, | |
rule, | |
image, | |
pattern = /url\((.*)\)/, | |
properties = ['background-image', '-webkit-border-image'], | |
images = {}; | |
if (doc.styleSheets) { |
This file contains 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 express = require('express'), | |
requirejs = require('requirejs'), | |
app = module.exports = express.createServer(); | |
app.configure('development', function(){ | |
// Use development version of static files | |
app.use(express.static(__dirname + '/public')); | |
}); | |
app.configure('production', function(){ |
This file contains 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
ES2015 (a.k.a. ES6) | |
- Lots of new language features | |
- Classes | |
- Arrow Functions | |
- Destructuring | |
- Let + Const | |
- Iterators | |
- Generators | |
- Modules |
This file contains 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
import React from "react"; | |
import {ContextTypes, DefaultProps, PropTypes} from "./Decorators"; | |
// this will throw a warning. | |
@PropTypes({name: React.PropTypes.func}) | |
@DefaultProps({name: "robbie"}) | |
class BaseClass extends React.Component { | |
render() { | |
return ( | |
<div className="base-class-example"> |
This file contains 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
import React, { Component } from 'react'; | |
import storeDecorator from './store-decorator'; | |
import someStore, { SOME_STORE_SYMBOL } from './some-reflux-store'; | |
@storeDecorator(someStore) | |
class SomeComponent extends Component { | |
render() { | |
return ( | |
<div> | |
{this.state[SOME_STORE_SYMBOL].someProperty} |
This file contains 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
import React from 'react'; | |
import SomeStore from '../stores/SomeStore'; | |
import AppActions from '../actions/AppActions'; | |
function gatherSomeStoreState(props, state) { | |
return { | |
myRandomNumber: SomeStore.getRandomNumber() | |
}; | |
} |
OlderNewer