<body>
<div>
<header>
<h1 id="title"><em><a href="/">Hello world!</a></em></h1>
</header>
<section>
<ul>
<li class="item"><a href="#">Navigation Item</a></li>
<a href="#">Navigation Item</a>
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
loop[0][2][20] = function(i) { | |
console.log(i); | |
}; | |
// Output: | |
// 0 | |
// 2 | |
// 4 | |
// 6 | |
// 8 |
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
/* Extremely simple definition of a 2D array in Javascript. Javascript doesn't allow for a match-all getter so a length has to be defined. This defines the height or rows of the array but not the width; the width or columns is as big as you want it to be, sugar. For some odd reason, the __defineGetter__ doesn't send the name of the current "get" to the callback (which is silly in my opinion for situations exactly like these) so I had to convert the functions to strings. */ | |
var Array2D = function(l) { | |
if(!l) throw new Error("Please specify a length for your Array2D"); | |
this.arr = []; | |
this.definedLength = l; | |
for(var i = 0; i < l; i++) { | |
this.__defineGetter__(i, Function("var i = " + i + ";if(!this.arr[i]) this.arr[i] = [];return this.arr[i];")); | |
} |
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 sudoku = [], iterationCount = 0; | |
function check(type, pos, num) { | |
var bool = false; | |
for(var i = 0; i < 9; i++) { | |
var tile = (type === 1) ? (pos * 9) + i : //row | |
(type === 2) ? (i * 9) + pos : null; //Column | |
(((((pos - (pos % 3))/3) * 3)) * 9) + ((((pos % 3) * 3)) + (i % 3)); //Quadrant |
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
{ | |
"section_a": { | |
"1": { | |
"i": { | |
"content": " Explain using examples why many hard RTS use a cyclic executive approach to scheduling whereas many soft RTS utilise a real-time operating system. [10] " | |
}, | |
"ii": { | |
"content": " Using Antilock Braking Systems (ABS) as an example, distinguish between the sample rate and response time of a RTS. [10] " | |
}, | |
"iii": { |
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 multiline = function(string) { | |
// Replace the "function() {/*\n" and "\n*/}" with nothing and bam, multiline strings | |
return string.toString().replace(/(^[^\n]*\n)|(\n\*\/\})/g, ""); | |
}; | |
console.log(multiline(function() {/* | |
Hello world! | |
I'm a multiline string! | |
Tada! |
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
src/data/auth.coffee-112- id: installationId) | |
src/data/auth.coffee-113- return new Promise (resolve, reject) -> | |
src/data/auth.coffee-114- projectsDLM.get cacheKey, (err, res) -> | |
src/data/auth.coffee-115- return reject(err) if err? | |
src/data/auth.coffee-116- return resolve res if res? | |
src/data/auth.coffee:117: currentTimestamp = Date.now().toString() | |
src/data/auth.coffee-118- projectsDLM.set cacheKey, currentTimestamp, (err, res) -> | |
src/data/auth.coffee-119- return reject(err) if err? | |
src/data/auth.coffee-120- resolve currentTimestamp | |
src/data/auth.coffee-121- |
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 update_ = Runner.instance_.update; | |
Runner.instance_.update = function() { | |
if(this.horizon.obstacles.length) { | |
const nearestObstacle = this.horizon.obstacles[0]; | |
if(nearestObstacle.xPos < 115 && !this.tRex.jumping) { | |
if(nearestObstacle.yPos <= 50) { | |
this.tRex.setDuck(true); | |
setTimeout(this.tRex.setDuck.bind(this.tRex, false), 500); | |
} else { | |
this.tRex.startJump(this.currentSpeed); |
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
import React, { Component } from 'react'; | |
import Provider from "./Provider"; | |
import Incrementer from "./Incrementer"; | |
class App extends Provider { | |
state = { value: 0 }; | |
render() { | |
const increment = this.dispatch.bind(this, { type: "INCREMENT" }); | |
const decrement = this.dispatch.bind(this, { type: "DECREMENT" }); |
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
process.on("unhandledRejection", function(reason, p) { | |
console.log(reason, p); | |
console.log("Rejection handled") | |
new Promise(function(resolve, reject) { | |
console.log("Second rejection") | |
reject(new Error("Foo")); | |
}); | |
}); |
OlderNewer