Skip to content

Instantly share code, notes, and snippets.

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]);
}
class Promise {
triggered?: string;
resultOrReason: any;
rejectHandlers: Function[];
resolveHandlers: Function[];
constructor(callback: (resolve, reject?) => void) {
this.triggered = null;
this.rejectHandlers = [];
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})
// mapAsync
function mapAsync(arr, process, callback) {
var output = [];
arr.forEach((element) => {
process(element, (err, data) => {
if (err) {
throw err;
}
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,
});
set position(vec) {
const diff = vec.clone().subtract(this._lowerLeft);
this._lowerLeft = vec;
this._upperRight.add(diff);
}
get position() {
return this._lowerLeft;
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)
@jacobgardner
jacobgardner / .htacess
Created July 22, 2015 18:46 — forked from ryanfitton/.htacess
This snippet is great to use if you have recently switched your Wordpress website over to HTTPS only. Paste this snippet into your .htaccess and overwrite the standard Wordpress code at the top of the file.
# 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]
function setup() {
function test() {
}
}
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],
]