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
function request(method, endpoint, {payload, headers: {}} = {}) { | |
return new Promise((resolve, reject) => { | |
const ajaxRequest = new XMLHTTPRequest(); | |
ajaxRequest.open(method, endpoint); | |
for (const key of Object.keys(headers)) { | |
ajaxRequest.setRequestHeader(key, headers[key]); | |
} |
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 Promise { | |
triggered?: string; | |
resultOrReason: any; | |
rejectHandlers: Function[]; | |
resolveHandlers: Function[]; | |
constructor(callback: (resolve, reject?) => void) { | |
this.triggered = null; | |
this.rejectHandlers = []; |
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 Promise = require('bluebird'); | |
const models = Promise.promisifyAll(require('./models')); | |
const {VehicleModel} = models; | |
function yourCode() { | |
Promise.all(vehicles.map((ownedVehicle) => { | |
return VehicleModel.findOneAsync({_id: ownedVehicle.vehicleId}) |
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
// mapAsync | |
function mapAsync(arr, process, callback) { | |
var output = []; | |
arr.forEach((element) => { | |
process(element, (err, data) => { | |
if (err) { | |
throw err; | |
} |
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
vehicles.forEach((ownedVehicle) => { | |
VehicleModel.findOne({_id: ownedVehicle.vehicleId}, (err, vehicle) => { | |
if (err) throw err; | |
console.log(vehicle); | |
returnArr.push({ | |
year: vehicle.year, | |
make: vehicle.make, | |
model: vehicle.model, | |
}); |
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
set position(vec) { | |
const diff = vec.clone().subtract(this._lowerLeft); | |
this._lowerLeft = vec; | |
this._upperRight.add(diff); | |
} | |
get position() { | |
return this._lowerLeft; |
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 TIMESTEP = 10; // 100 updates per second => 10ms = 0.01s => 1frame / 0.01s = 100fps | |
function renderLoop() { | |
// Do Renderer Things here | |
window.requestAnimationFrame(renderLoop); | |
} | |
window.requestAnimationFrame(renderLoop) |
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
# BEGIN WordPress | |
# Test | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{SERVER_PORT} !^443$ | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] | |
RewriteBase / | |
RewriteRule ^index\.php$ - [L] |
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
function setup() { | |
function test() { | |
} | |
} |
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
from collections import namedtuple | |
die = [ | |
[1, 1, 2, 3, 4, 5], | |
[1, 1, 2, 3, 4, 5], | |
[1, 1, 2, 3, 4, 5], | |
[1, 1, 2, 3, 4, 5], | |
[1, 1, 2, 3, 4, 5], | |
] |
NewerOlder