This file contains hidden or 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
// Code from: http://patshaughnessy.net/2020/1/20/downloading-100000-files-using-async-rust | |
// | |
// Cargo.toml: | |
// [dependencies] | |
// tokio = { version = "0.2", features = ["full"] } | |
// reqwest = { version = "0.10", features = ["json"] } | |
// futures = "0.3" | |
use std::io::prelude::*; | |
use std::fs::File; |
This file contains hidden or 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
/* eslint-env node */ | |
/** | |
* This can be run as an npm script a part of your CI testing | |
* | |
* This is a "smoke test" to make sure that the application, when run | |
* within FastBoot, isn't calling APIs that aren't supported by the | |
* Node.js environment. (e.g. window.alert) | |
*/ |
This file contains hidden or 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
// test helper | |
import { getContext } from '@ember/test-helpers'; | |
export default function createComponent(lookupPath, named = {}) { | |
let { owner } = getContext(); | |
let componentManager = owner.lookup('component-manager:glimmer'); | |
let { class: componentClass } = owner.factoryFor(lookupPath); | |
return componentManager.createComponent(componentClass, { named }); | |
} |
This file contains hidden or 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
## Architecture | |
A possible future design of ember-cli-fastboot which achieves the goal of "production ready." | |
### General Design | |
ember-cli-fastboot combines a couple of critical components for a user's experience in development and production. | |
1. **Production** - fastboot service, utils to add to and clear the shoebox, and managing the HTML on handoff to the client. | |
2. **Development** - an express server that instantiates a FastBoot instance, plugs the FastBoot middleware into the pipeline, reload capabilities and build time utilities. |
This file contains hidden or 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
## General Design | |
- Cluster management. | |
- Being aware of distribution changes and downloading of new assets. | |
- Delegation of responsibilities between three separate primary objects: | |
- Cluster Master | |
- Cluster Workers | |
- Express HTTP Server | |
## Constituent Components |
This file contains hidden or 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
let counter = 0; | |
class MyPromise extends Promise { | |
constructor(cb) { | |
const stack = (() => { try { throw new Error(); } catch (e) { return e; } })().stack; | |
const id = `promise ${counter++}`; | |
console.time(id); | |
super(function(resolve, reject) { |
This file contains hidden or 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 createDataTree = dataset => { | |
let hashTable = Object.create(null); | |
dataset.forEach(aData => { | |
return (hashTable[aData.id] = { ...aData, childNodes: [] }); | |
}); | |
let dataTree = []; | |
dataset.forEach(aData => { | |
if (aData.parentId) { | |
hashTable[aData.parentId].childNodes.push(hashTable[aData.id]); | |
} else { |
This file contains hidden or 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 createScheduler({ | |
callback, | |
time, | |
callbackTimeout, | |
backoffMultiplier = 1.5, | |
backoffMaxTime = 20000 | |
}) { | |
let run; | |
let timeoutId; | |
let ticker; |
This file contains hidden or 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 Component from '@glimmer/component'; | |
import { action } from '@ember/object'; | |
export default class extends Component { | |
get handleStyles() { | |
const fraction = (this.args.currentValue / this.args.max) * 100; | |
return `left: ${fraction}%`; | |
} | |
@action |
This file contains hidden or 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 getBooleanTable = number => Array(Math.pow(2, number)) | |
.fill() | |
.map((_, idx) => idx) | |
.map(num => num.toString(2).padStart(number, '0')) | |
.map(stringOfBits => | |
stringOfBits.split('').map(bit => Boolean(parseInt(bit))) | |
) | |
console.log(getBooleanTable(3)) |