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'); | |
var graphqlHTTP = require('express-graphql'); | |
var { buildSchema } = require('graphql'); | |
var schema = buildSchema(` | |
type Query { | |
hello: String | |
} | |
`); |
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 { graphql, buildSchema } = require('graphql'); | |
// Construct a schema, using GraphQL schema language | |
var schema = buildSchema(` | |
type Query { | |
hello: String | |
} | |
`); | |
// The root provides a resolver function for each API endpoint |
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 http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
res.end('Hello World!'); | |
}).listen(8080); |
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
const express = require('express') //use the express module | |
const app = express() //create the express application object | |
app.get('/', function (req, res) { //create the callback function for handling GET request con ' | |
res.send('Hello World!') //send the response | |
}) | |
//start listening on port 3000 | |
app.listen(3000, 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
class ConditionalComponent extends React.Component { | |
render() { | |
const isLoggedIn = true; | |
let button = null; | |
if (isLoggedIn) { | |
button = <LogoutButton />; | |
} else { | |
button = <LoginButton />; |
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
/** | |
* Filter object array (e.g. filter those with id>100): | |
*/ | |
//In ES6: | |
objectList.filter(obj => obj.id > 100); | |
//In ES5: | |
objectList.filter(function (obj) { | |
return obj.id > 18; | |
}); |
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
li:before { | |
content: ""; | |
display: inline-block; | |
height: 1rem; // or px or em or whatever | |
width: .5rem; // or whatever space you want | |
} |
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 someAsyncFunction = function(callback) { | |
setTimeout(function() { | |
var template = '<h1>{{message}}</h1>'; | |
callback(template); | |
}, 1000); | |
}; | |
$(document).ready(function() { | |
someAsyncFunction(function(template) { | |
var compiledTemplate = Handlebars.compile(template); |
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
.wrap { | |
white-space: pre-wrap; /* CSS3 */ | |
white-space: -moz-pre-wrap; /* Firefox */ | |
white-space: -pre-wrap; /* Opera <7 */ | |
white-space: -o-pre-wrap; /* Opera 7 */ | |
word-wrap: break-word; /* IE */ | |
} |
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
router.get('/:id', function(req, res) { | |
var eventID = req.params.id; | |
}); | |
//http://myurl.com/search?param1=value1¶m2=value2 | |
router.get('/search', function(req, res) { | |
var param1,param2; | |
if (req.query.param1) { | |
param1 = req.query.param1; |