Skip to content

Instantly share code, notes, and snippets.

Mike Pastore mwpastore

View GitHub Profile
@mwpastore
mwpastore / rg-refresh.sh
Last active Jun 4, 2018
Automated VLAN flop for AT&T RG workaround
View rg-refresh.sh
#!/bin/bash
###
# PURPOSE
#
# Execute a VLAN "flop" to allow the AT&T Residential Gateway (RG) to perform
# 802.1x authentication via the Optical Network Terminal (ONT) before falling
# back to the subscriber's "own" router/gateway hardware. The RG is toggled off
# and on as needed via a remote-controlled power outlet (see below).
#
# For more information about this procedure, please see brianlan's original
@mwpastore
mwpastore / -computed-promise.js
Last active Sep 28, 2017
Promise-aware compute macros
View -computed-promise.js
import computed from 'ember-macro-helpers/computed';
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
import { typeOf } from '@ember/utils';
import { all } from 'rsvp';
export default function(Proxy) {
const PromiseProxy = Proxy.extend(PromiseProxyMixin);
View components.my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
greeting: 'Hello',
actions: {
showAlert(message) {
const greeting = this.get('greeting');
alert(`${greeting}, ${message}!`);
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['endDate'],
startDate: '09/01/2017',
endDate: '09/30/2017'
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
store: Ember.inject.service(),
count: 0,
foo: null,
init() {
this._super(...arguments);
@mwpastore
mwpastore / cached-computed.js
Last active Aug 6, 2017
cached computed macro
View cached-computed.js
import { run } from '@ember/runloop';
import { computed } from '@ember/object';
const { stringify } = JSON;
export default function(...props) {
const { getState, update } = props.pop();
const strippedProps = props.map((prop) => {
@mwpastore
mwpastore / address-model.js
Last active Jul 28, 2017
ember-cp-validations preprocessor and helper for deferred validations
View address-model.js
import Model from 'ember-data/model';
import { validator } from 'ember-cp-validations';
import attr from 'ember-data/attr';
import buildValidations from '../utils/build-validations';
const ValidationsMixin = buildValidations({
street: {
deferred: true, // N.B.
validators: [
@mwpastore
mwpastore / .eslint.js
Created Jul 10, 2017
eslint rule for arrow function parens styling
View .eslint.js
module.exports = {
// ..
rules: {
'arrow-parens': [2, 'as-needed', { requireForBlockBody: true }],
// ..
}
// ..
}
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
You can’t perform that action at this time.