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
// 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';
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;
@jasonmit
jasonmit / initializer---router-map-patch.js
Last active July 25, 2016 00:32
Router.map runtime patch
// Also, parts of this are entirely wrong.. I don't have access to what
// I originally wrote at the moment but it at least shows roughly the idea..
import Ember from 'Ember';
const { get, Logger } = Ember;
export default {
name: 'router-map-patch',
initialize() {
Ember.Router.reopen({
Router.map({
needs: ['i18n']
}, function({ i18n }) {
this.route('index', { path: '/' });
this.route('about', { path: i18n.t('urls.about') });
this.route('contact_us', { path: i18n.t('urls.contact_us') });
});
export default Service.extend({
i18n: service(),
init() {
this._super(...arguments);
this._subscribers = A();
this.subscribe((e) => logger.error(e), this);
}
@jasonmit
jasonmit / post-merge
Last active December 15, 2016 06:35 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@jasonmit
jasonmit / computed.js
Last active December 21, 2016 10:50
New Twiddle
let format = new Intl.DateFormat('en-US', {
hour: 'numeric', minute: 'numeric', second: 'numeric',
timeZoneName: 'short'
});
const { computed, run } = Ember;
const COUNTERS = '__COUNTERS__';
let idx = 0;
export default function({ interval }) {
@jasonmit
jasonmit / components.x-foo.js
Last active December 31, 2016 00:02
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default class extends Ember.Controller {
get appName() { return 'Ember Twiddle'; }
};
@jasonmit
jasonmit / components.x-select.js
Last active January 19, 2017 02:01
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
hasFocus: false,
options: [
{
name: 'Foo',
value: 'http://foo.com'
},
{