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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>App</title> | |
<meta charset="utf-8"/> | |
</head> | |
<body> | |
<h1>Mini React app ❤</h1> | |
<div id="app"></div> | |
<script src="app.tsx"></script> |
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
{ // TypeScript configuration file: provides options to the TypeScript | |
// compiler (tsc) and makes VSCode recognize this folder as a TS project, | |
// enabling the VSCode build tasks "tsc: build" and "tsc: watch". | |
"compilerOptions": { | |
"target": "es5", // Compatible with older browsers | |
"module": "umd", // Compatible with both Node.js and browser | |
"moduleResolution": "node", // Tell tsc to look in node_modules for modules | |
"sourceMap": true, // Creates *.js.map files | |
"jsx": "react", // Causes inline XML (JSX code) to be expanded | |
"strict": true, // Strict types, eg. prohibits `var x=0; x=null` |
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 server | |
var fs = require("fs"); // file system access | |
var url = require("url"); // url parser | |
var path = require("path"); // file path parser | |
// You can choose the port via command line, e.g. node server.js 3000 | |
const port = process.argv[2] || '1234'; | |
const folderToServe = 'app'; | |
const mimeTypes = { | |
'.ico': 'image/x-icon', | |
'.html': 'text/html', |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>App</title> | |
<meta charset="utf-8"/> | |
<script src="node_modules/react/umd/react.development.js"></script> | |
<script src="node_modules/react-dom/umd/react-dom.development.js"></script> | |
<script src="node_modules/preact/dist/preact.dev.js"></script> | |
<script> | |
module = {exports:{}}; exports = {}; |
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
"scripts": { | |
"test": "echo \"Error: no tests installed\" && exit 1", | |
"build": "webpack app/app.tsx --module-bind tsx=awesome-typescript-loader -o app/app.bundle.js --mode=production", | |
"build:dev": "webpack app/app.tsx --module-bind tsx=awesome-typescript-loader -o app/app.bundle.js --mode=development", | |
"watch": "webpack app/app.tsx --module-bind tsx=awesome-typescript-loader -o app/app.bundle.js --mode=development --watch", | |
"start": "node server.js" | |
}, |
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
"scripts": { | |
"test": "echo \"Error: no tests installed\" && exit 1", | |
"build": "webpack --config webpack.config.js --mode=production", | |
"build:dev": "webpack --config webpack.config.js --mode=development", | |
"watch": "webpack --config webpack.config.js --mode=development --watch", | |
"start": "node server.js" | |
}, |
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
// Define a macro recognized by LeMP ( http://ecsharp.net/lemp ) | |
define #using($type $varname = $expression, $block) { | |
{ | |
$type $varname = $expression; | |
try $block | |
finally { | |
if ($varname != null) | |
((IDisposable)$varname).Dispose(); | |
} | |
} |
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 y; | |
// Math.random() is a random number between 0 and 1 | |
if (Math.random() < 0.5) | |
y = "Why?"; | |
else | |
y = 25; | |
y = [y, y]; | |
console.log(y); // print [25,25] or ["Why?","Why?"] in browser's 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
class Box { | |
constructor(width, height) { // initializer | |
this.width = width; | |
this.height = height; | |
} | |
get area() { return this.width*this.height; } // getter function | |
setSquare(side) { // normal function | |
// set the Box's width and height to side, representing a square | |
this.width = this.height = side; | |
} |
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 Box { | |
width: number; | |
height: number; | |
constructor(width: number, height: number) { | |
this.width = width; | |
this.height = height; | |
} | |
get area() { return this.width*this.height; } | |
setSquare(side: number) { | |
this.width = this.height = side; |