Skip to content

Instantly share code, notes, and snippets.

View jasonmit's full-sized avatar
🌴
On a hiatus from open source

Jason Mitchell jasonmit

🌴
On a hiatus from open source
View GitHub Profile
import Fastboot from 'fastboot';
export default middleware(req, res, next) {
const fb = new FastBoot({ distPath: distPath});
res.render('foo-bar', function(err, layoutHtml) {
const $layout = cheerio.load(layoutHtml);
fb.visit(req.url).then((result) => {
const app = result.instance;
// WARNING: DO NOT USE.
// When isDisabled is truthy, count will freeze in the DOM
// {{#hide-rerendering isDisabled}}
// {{count}}
// {{/hide-rerendering}}
import Ember from 'ember';
import hbs from 'htmlbars-inline-precompile';
@jasonmit
jasonmit / output.html
Last active November 19, 2015 22:17
output.css
<style type="text/css">
@media screen and (max-width: 767px) {
#a23d39cc article {
font-size: 25px;
}
}
#a23d39cc article {
font-size: 15px;
}
@jasonmit
jasonmit / no-$-in-controllers-routes-models.js
Last active September 9, 2015 06:38
Warn on jquery in controllers, routes, models
var Filter = require('broccoli-filter');
var controller = new RegExp(/(^controllers\/)|(^models\/)|(^routes\/)/);
var jquery = new RegExp(/\W(\$\.)|(\.\$\.)|(\$\()/);
NoJquery.prototype = Object.create(Filter.prototype);
NoJquery.prototype.constructor = NoJquery;
function NoJquery(inputNode) {
if (!(this instanceof NoJquery)) {
@jasonmit
jasonmit / gist:7e02fd5468bd58d610d6
Last active August 29, 2015 14:20
get({ foo: { bar: 'bar' }}, 'foo.bar');
//
// https://jsfiddle.net/jmvf41f4/1/
//
function get(object, path) {
var paths = path.split('.');
var len = paths.length;
var out = object;
var i = 0;
# deb cdrom:[Ubuntu 14.10 _Utopic Unicorn_ - Release amd64 (20141022.1)]/ utopic main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ utopic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ utopic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ utopic-updates main restricted
@jasonmit
jasonmit / gist:2dd4aacb217a0b6b6098
Last active August 29, 2015 14:14
ember jsbin bases
@jasonmit
jasonmit / didCreateRecord.js
Last active August 29, 2015 14:12
Ember-data custom didCreateRecord event
/*
* The `didCreate` event on a DS.Model does not behave like one would expect.
* It actually only ever fires when you createRecord AND then save the record.
*
* This custom eventing below is how you achieve a the expected event.
* This is useful in the case where you have relational objects that you want
* to auto-create when a record is created. Or, some custom logic to implement
* once the record is created. Likely very useful where you want to setup
* observers for things like validation. Placing them in `init` wouldn't
* be ideal since they will trigger the first time the model is initialized
@jasonmit
jasonmit / observerOnce.js
Last active August 29, 2015 14:10
Ember.observerOnce - combines Ember.observer + Ember.run.once
//
// Example: http://jsbin.com/welusizema/1/edit
//
// Since observers are not async, it's usually a good
// practice, when observing numerous properties, to
// wrap the observer function with an Ember.run.once.
// ```
// fooBarChanged: Ember.observer('foo', 'bar', function () {
// Ember.run.once(this, this.scheduledChange);
// }),