##Ubuntu Server
sudo apt-get install g++ curl libssl-dev apache2-utils git-core make
cd /usr/local/src
wget http://nodejs.org/dist/v0.10.28/node-v0.10.28.tar.gz
tar -xvzf node-v0.10.28.tar.gz
cd node-v0.10.28| FROM ubuntu | |
| MAINTAINER David Weinstein <david@bitjudo.com> | |
| # install our dependencies and nodejs | |
| RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list | |
| RUN apt-get update | |
| RUN apt-get -y install python-software-properties git build-essential | |
| RUN add-apt-repository -y ppa:chris-lea/node.js | |
| RUN apt-get update | |
| RUN apt-get -y install nodejs |
| set fish_user_paths path_to_your_google_cloud_sdk/bin | |
| set -x MANPATH path_to_your_google_cloud_sdk/help/man /usr/local/share/man /usr/share/man /opt/x11/share/man |
| import { MongoClient } from 'mongodb'; | |
| import promisify from 'es6-promisify'; | |
| let _connection; | |
| const connect = () => { | |
| if (!process.env.MONGO_CONNECTION_STRING) { | |
| throw new Error(`Environment variable MONGO_CONNECTION_STRING must be set to use API.`); | |
| } |
Most of the modules I write are "agnostic" in that they should work in Node, browserify, webpack, Rollup, jspm... hell, even Unreal.js. It's just ES5, CommonJS and a few quirks like process.nextTick or require('path') (which browserify and webpack will shim).
Other modules are a bit trickier, and need to include a static asset like HTML, GLSL or another file.
In Node you might see this:
var fs = require('fs')Include Weather Icons in your app: https://github.com/erikflowers/weather-icons
Include the below JSON in your application, for example purposes, lets assume it's a global named weatherIcons.
Make a request to OpenWeatherMap:
req = $.getJSON('http://api.openweathermap.org/data/2.5/weather?q=London,uk&callback=?');| // 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works | |
| const axios = require('axios'); // promised based requests - like fetch() | |
| function getCoffee() { | |
| return new Promise(resolve => { | |
| setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee | |
| }); | |
| } |
| import React from 'react'; | |
| import { withState, pure, compose } from 'recompose'; | |
| import gql from 'graphql-tag'; | |
| import { graphql } from 'react-apollo'; | |
| import { Link } from 'react-router'; | |
| // The data prop, which is provided by the wrapper below, contains | |
| // a `loading` key while the query is in flight, and the bookSearch | |
| // results when they are ready | |
| const BookSearchResultsPure = ({ data: { loading, bookSearch } }) => { |
| enum PostStates { DRAFT, PUBLISHED, ARCHIVED } | |
| scalar Date | |
| scalar Html | |
| directive @buildIndex on field | |
| directive @defaultFirst on field | |
| #...etc | |
| type PostContent { | |
| brief: Html @editor(height: 150, wysiwyg: true) | |
| extended: Html @editor(height: 400, wysiwyg: true) |