Today, we're going to make choose your own adventure a web app.
This is easier than it sounds
— What exactly is a web server?
function Tweet(params) { | |
params = params || {}; | |
this.user = params.user; | |
this.content = params.content; | |
} | |
Tweet.recent = function(limit) { | |
var limit = limit || 50; | |
return $.get('/tweets/recent', { | |
dataType: 'json', |
<!doctype html> | |
<html> | |
<head> | |
<title>Github User search</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src=github-user.js></script> | |
</head> | |
<body> | |
<form class=search-form> | |
<input name=query type=search> |
"use strict"; | |
var inquirer = require('inquirer'); | |
var game = require('./game.source'); | |
// play(node: Node) -> Promise<Node> | |
function play(node) { | |
if (!node.connections.length) { | |
console.log(node.text); |
var inquirer = require('inquirer') | |
inquirer.prompt([ | |
{ name: 'choice', | |
message: 'Pick a color', | |
type: 'list', | |
choices: [ | |
{name: 'Red', value: '#ff0000'}, | |
{name: 'Green', value: '#00ff00'}, | |
{name: 'Fuchsia', value: '#ff00ff'}, |
var childProcess = require('child_process') | |
var sortProc = childProcess.spawn('sort') | |
process.stdin.pipe(sortProc.stdin) | |
sortProc.stdout.pipe(process.stdout) |
// Second timer goes off before the first | |
var startedAt = new Date() | |
setTimeout(function() { | |
var now = new Date | |
console.log(`Timer went off at ${now}, ${now - startedAt}ms later.`) | |
}, 1200) | |
var now = new Date | |
while(now - startedAt < 1000) { now = new Date } |
INSERT INTO Users (name, pictureUrl) VALUES ('Donald Trump', 'http://i.imgur.com/CTil4ns.jpg'); | |
INSERT INTO Users (name, pictureUrl) VALUES ('Ted Cruz', 'http://i.imgur.com/Ru6KUIm.jpg'); | |
INSERT INTO Users (name, pictureUrl) VALUES ('Bernie Sanders', 'http://i.imgur.com/KhisgEO.jpg'); | |
INSERT INTO Users (name, pictureUrl) VALUES ('Hillary Clinton', 'http://i.imgur.com/XbsjDcr.jpg'); | |
INSERT INTO Users (name, pictureUrl) VALUES ('Marco Rubio', 'http://i.imgur.com/cYxVyyg.jpg'); | |
INSERT INTO Users (name, pictureUrl) VALUES ('John Kasich', 'http://i.imgur.com/I8WtzSw.jpg'); | |
INSERT INTO Users (name, pictureUrl) VALUES ('Kanye West', 'http://i.imgur.com/MItGWVS.jpg'); | |
INSERT INTO Users (name, pictureUrl) VALUES ('Taylor Swift', 'http://i.imgur.com/JKInSVz.jpg'); | |
INSERT INTO Tweets (userId, content) VALUES ((SELECT id from Users where name='Donald Trump'), 'Make Fullstack great again!'); |
<!doctype html> | |
<html> | |
<head> | |
<link rel=stylesheet href=style.css> | |
</head> | |
<body> | |
<h1 id=header>trip planner</h1> | |
<ul class=todo-list> | |
<li class=todo-list-new-item> |
"use strict" | |
// Create an HTTP server that always serves a couple | |
// of script tags. | |
var http = require('http') | |
var httpServer = http.createServer(function(req, rsp) { | |
rsp.end(` | |
<script src="/socket.io/socket.io.js"></script> | |
<script> | |
// This JS is running on the client. Whee! |