Skip to content

Instantly share code, notes, and snippets.

Avatar

Scott Newcomer snewcomer

View GitHub Profile
@snewcomer
snewcomer / cli-fastboot-proposal
Created Oct 2, 2020
ember-cli-fastboot proposal
View cli-fastboot-proposal
## 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.
@snewcomer
snewcomer / ember-fastboot-architecture
Created Sep 25, 2020
Proposal: Ember FastBoot App Server architecture
View ember-fastboot-architecture
## 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
View controllers.application.js
import Ember from 'ember';
import Changeset from 'ember-changeset';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
save(){
const changeset = new Changeset(this.model.post);
@snewcomer
snewcomer / controllers.application.js
Created Apr 26, 2020 — forked from jelhan/controllers.application.js
ember-changeset-validations-validateConfirmation-undefined
View controllers.application.js
import Changeset from 'ember-changeset';
import Ember from 'ember';
import PasswordValidations from '../validations/password';
import lookupValidator from 'ember-changeset-validations';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
@snewcomer
snewcomer / controllers.application.js
Created Apr 26, 2020 — forked from jelhan/controllers.application.js
ember-changeset-validations-validateConfirmation-undefined
View controllers.application.js
import Changeset from 'ember-changeset';
import Ember from 'ember';
import PasswordValidations from '../validations/password';
import lookupValidator from 'ember-changeset-validations';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
View promise-timer.js
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) {
View array-to-tree.js
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 {
@snewcomer
snewcomer / exponential.js
Created Apr 16, 2020
exponential-backoff
View exponential.js
function createScheduler({
callback,
time,
callbackTimeout,
backoffMultiplier = 1.5,
backoffMaxTime = 20000
}) {
let run;
let timeoutId;
let ticker;
View components.range-slider\.js
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
View getBooleanTable.js
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))
You can’t perform that action at this time.