Data is plural(from the latinwhat is given)
A given piece of data is called a datum
Nominal | No natural ordering $= \neq$ Ex: gender, ethnicity, nationality |
---|---|
Ordinal | Logical ordering but difference not meaningful $= \neq < >$ Ex: levels of happiness, levels of difficulty |
Ratio | Ordered, differences & doubling meaningful, 0 fixed $= \neq < > - \%$ Ex: temperature in Kelvin ($40^{o}K = 2 \times 20^{o}K$), length, height |
---|---|
Interval | Ordered, differences meaningful, doubling not meaningful, 0 arbitrary $= \neq < > -$ Ex: temperature in Celsius ($40^{o}C \neq 2 \times 20^{o}C$), dates, locations |
Strongly Disagree | Disagree | Neither Agree nor Disagree | Agree | Strongly Agree |
Conceptual | Semantic description of data entities and their relations |
---|---|
Logical | Implementation independent data design representation |
Physical | Implementation dependent details by which data is actually stored |
Conceptual model | |
---|---|
Logical model | |
Physical model |
Client | Server |
---|---|
Browsers render:
|
Servers (e.g., node, nginx, Apache) serve:
|
Hyper-Text Markup Language
<tag attribute="value"></tag>
classof elements, multiple classes per element
<tag class="definition blue"></tag>
<tag id="tag0"></tag>
Element | Description |
---|---|
<!DOCTYPE html> | Standard document type declaration (first line of document). |
html | Surrounds all HTML content in a document. |
head | Tag containing all document metadata (e.g., title). |
title | Title shown on top of browser window. |
body | Visible content in the page. |
h1, h2, h3, h4, h5, h6 | Headers of different levels. |
p | Paragraph (block-level element). |
span | Portion of text (inline element). |
div | Division within the document (block-level element). |
em | Emphasize text, rendered in italic. |
strong, b | Emphasize text, rendered in boldface. |
a | Hyperlink, rendered in underlined, blue text. |
svg | SVG element for rendering vector graphics. |
<!DOCTYPE html>
<html>
<head>
<title>Page title</title>
</head>
<body>
<!-- This is an HTML comment -->
<!-- Visible HTML elements are placed in the body -->
</body>
</html>
Scalable Vector Graphics
<svg width="800" height="260" style="background-color: honeydew">
<circle cx="300" cy="200" r="50" fill="steelblue"/>
<text x="300" y="200">Apples</text>
<circle cx="100" cy="100" r="50" fill="orange"/>
<text x="100" y="100">Pears</text>
<rect x="500" y="50" width="200" height="100" fill="orange"/>
<text x="450" y="100">Oranges</text>
</svg>
Cascading Style Sheets
Inline overrides Embedded overrides External
<p style="color: blue">Inline style</p>
<style>
p { color: blue; }
</style>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<!-- p { color: blue; } placed in style.css -->
</head>
div | div elements |
.foo | elements with class foo |
#foo | elements with id foo |
div.foo | div elements with class foo |
div#foo | div elements with id foo |
div .foo | elements with class foo inside a div |
div #foo | elements with id foo inside a div |
div , .foo | div elements and elements with class foo |
div p .foo | elements with class foo in a p in a div |
h1 {
color: red; } /* all h1 */
h1, h2 {
font-weight: bold; } /* all h1 and h2 */
h1 h2 {
font-weight: bold; } /* all h2 inside h1 */
p strong { /* all strong inside p */
color: orange;
font-weight: bold; }
#chapter1 {
color: blue } /* element with id chapter1 */
.pastoral {
color: green } /* all with class pastoral */
div,a.important {
color: 'red'
}
<script type="text/javascript">
//JavaScript code here
</script>
<script src="script.js"></script>
//denotes a comment
obj = {first: 'Joseph', last: 'Priestley'}; //object literal
obj.first //'Joseph'
obj = {first: 'Joseph', last: 'Priestley'};
obj.first = 'Joe' //now first is 'Joe'
//primitive types
var foo = true; //Boolean
var foo = null; //Null
var foo = undefined; //Undefined
var foo = 2.3; //Number
var foo = 'bar' //String
var b = 5; //global scope, i.e., at the top of the script
function f(a) {
var b = 3; //local scope, i.e., within the scope of the function
return a + b;
}
b; //5
//functions treated similar to any other variable
var pi = function() { return Math.PI; } //assign functions to a variable
function add(a, f) { return a + f(); }
add(1, pi); //pass functions as argument
function addPi() {
return function(a) { //return functions
return a + Math.PI;
}
}
Hoisting refers to the moving of variable declarations at the top of their scope when the script is parsedDeclarations are moved, initializations are not moved
var a; //declare
a = 2; //initialize
var b; //declare
b = 5; //initialize
//function expression: declare & initialize
var add = function (a, b) {
return a + b;
}; //; at the end!
//function declaration
function func(a) {
var b = 3; //declare & initialize
var c = a + b; //declare & initialize
return c;
}
var a; //hoisted
var b; //hoisted
var add; //hoisted
function func(a) { //hoisted
var b; //hoisted
var c; //hoisted
b = 3;
c = a + b;
return c;
}
a = 2;
b = 5;
add = function (a, b) {
return a + b;
};
A closure is the combination of a function and the lexical
environment within which that function was declared.
function exampleClosure(arg1, arg2) { //closure example
var localVar = 2;
function exampleReturned(innerArg) { //inner function (declaration)
return ((arg1 + arg2) / (localVar + innerArg));
}
return exampleReturned; //reference to inner function
}
var globalVar = exampleClosure(2, 4);
console.log(globalVar); //[Function: exampleReturned]
globalVar(4); //1 = ((2 + 4) / (2 + 4))
//...
const { NEIGHBORHOOD_MAP } = require('../lib/utils/xtown-api');
let neighborhoodIds = [];
printNewsCmd.neighborhoods.forEach(d => {
let ids = NEIGHBORHOOD_MAP.get(d).id;
if (!ids) {
console.log(danger('ERROR'));
console.log(danger('No such neighborhood id "' + info + '"'));
exit(0);
}
ids = Array.isArray(ids) ? ids : [ids];
neighborhoodIds = neighborhoodIds.concat(ids);
});
neighborhoodIds = [...new Set(neighborhoodIds)]; //remove duplicates
const { printNews } = require('../lib/utils/printer');
printNews({
print_settings: {
neighborhoods: neighborhoodIds,
image: {
dir: FOUNDRY_CONFIG.print_defaults.news.image.dir,
format: printNewsCmd.imageFormat,
width: +printNewsCmd.imageWidth,
height: +printNewsCmd.imageHeight
},
user: user,
},
news: fs.readJSONSync(newsFile)
}).then(result => {
console.log(info('PRINT:'));
console.log(info(' id:'), important(result.print.id));
console.log(info(' path:'), important(result.print_settings.path));
console.log(info(' file:'), important(result.print.file));
console.log(info('PRINTS:'));
result.print_settings.neighborhoods.forEach(d => {
console.log(info(' ' + d + ':'));
console.log(info(' file:'), important(result.print_settings.path + d + '/index.html'));
console.log(info(' url:'), important(FOUNDRY_CONFIG.prints_url + result.print.id + '/' + d + '/index.html'));
});
if (printNewsCmd.verbose) {
console.log(info('\ntrace'));
console.dir(result, CONSOLE_DIR_OPTIONS);
}
}).catch(err => {
console.log(danger('ERROR'));
console.dir(err, CONSOLE_DIR_OPTIONS);
});
//...
/**
* print news
* @param {Object} context print context
* @returns {Object} printed object
*/
const printNews = context => {
return new Promise((resolve, reject) => {
const { FOUNDRY_CONFIG } = require('../config');
const { v4: uuidv4 } = require('uuid');
context.print = {
id: uuidv4(),
news_id: context.news.id,
created: {
user: context.print_settings.user,
timestamp: Date.now(),
},
errors: []
};
context.print_settings = context.print_settings ? context.print_settings : FOUNDRY_CONFIG.print_defaults.news;
context.print_settings.path = context.print_settings.path ? context.print_settings.path : FOUNDRY_CONFIG.prints_path;
context.print_settings.path += context.print.id + '/'; //prints folder
const { NEIGHBORHOOD_MAP } = require('./xtown-api');
let neighborhoods = [];
context.print_settings.neighborhoods.forEach(d => {
let ids = NEIGHBORHOOD_MAP.get(d).id;
if (!ids) {
reject(err);
return;
}
ids = Array.isArray(ids) ? ids : [ids];
neighborhoods = neighborhoods.concat(ids);
});
context.print_settings.neighborhoods = [...new Set(neighborhoods)]; //remove duplicates
fs.ensureDirSync(context.print_settings.path);
const newsFile = context.print_settings.path + context.print.id + FOUNDRY_CONFIG.json_ext;
fs.writeJSONSync(newsFile, {...context.print, neighborhoods: context.print_settings.neighborhoods});
context.print.file = newsFile;
printNewsFiles(context).then(results => {
resolve(context);
}).catch(e => reject(e));
});
}