Skip to content

Instantly share code, notes, and snippets.

View joostdevries's full-sized avatar

Joost de Vries joostdevries

  • Amsterdam, Netherlands
View GitHub Profile
@joostdevries
joostdevries / gist:6060936
Created July 23, 2013 08:53
Using the werkzeug debugger if you're testing AJAX calls to your API.
$(window).ajaxError(function(evt, evtData) {
if(evtData && ('responseText' in evtData)) {
var debuggerWindow = window.open('about:blank', 'debuggerWindow');
debuggerWindow.document.open();
debuggerWindow.document.write(evtData.responseText);
debuggerWindow.document.close();
}
});
@joostdevries
joostdevries / gist:acd9f47583111542982b
Last active August 29, 2015 14:04
IE9 parentNode error in Emberjs

I get reports from users experiencing the error below in IE9 causing our (EmberJS) application to crash. I haven't found what's causing it yet because I'm unable to reproduce it through Browserstack or locally and I've got users in IE9 without problems (only a couple of users are affected).

Error

Unable to get value of the property 'parentNode': object is null or undefined

User agent

@joostdevries
joostdevries / gist:f2ce4f24dc16ae8c2d10
Created September 30, 2014 12:01
github-related-issues.user.js
// Adds a 'References' section to the github issue/PR sidebar
//
// Installation:
// - Save this file as github-related-issues.user.js somewhere
// - Go to chrome://extensions
// - Drag the file to the open extensions tab
(function(w) {
var $ = function(selector, one) {
return one?document.querySelector(selector):document.querySelectorAll(selector);
@joostdevries
joostdevries / gist:68744dd139c24db55e90
Created January 7, 2015 13:08
Issue references above description
window.location.hostname==='github.com' && $('.discussion-item-ref').each(function() {var el=$(this).clone();$('.js-discussion').prepend(el);});
import Ember from 'ember';
export default Em.Controller.extend({
userName: null,
prettyUserName: function() {
return this.get('userName') ? this.get('userName') : 'everyone';
}.property('userName')
});
@joostdevries
joostdevries / gist-to-ember-cli-app.md
Last active August 29, 2015 14:16
How to create an Ember CLI app using Github Gist

Gist > Ember CLI app

Basically, it's really simple: Create a Gist where the files follow the same naming convention as you would use in an Ember CLI app.

Because Gists can't have folders, just use . instead of /. Eg:

  • controllers.application.js
  • templates.application.hbs

Once your Gist is ready to test, just put the ID in the playground URL, eg. http://ember-playground.joostdvrs.com/f2c90713bdfdf54a262b. All the magic then happens client-side:

  • Your templates are transpiled using ember-template-compiler
@joostdevries
joostdevries / application.hbs
Last active August 29, 2015 14:17
Ember Twiddle sample
<h1>Ember Twiddle Gist demo</h1>
{{outlet}}
export default Em.Controller.extend({foo: 'foo'});
@joostdevries
joostdevries / pagination-patch-recordarray.js
Created April 25, 2015 09:31
extend record array for pagination/infinite scroll
DS.AdapterPopulatedRecordArray.reopen({
queryPageParam: 'page_number',
metaPageParam: 'currentPage',
metaTotalPagesParam: 'totalNumPages',
isPaginating: false,
nextPage: function (append) {
var meta = this.get('meta');
if(meta[this.get('metaPageParam')]<meta[this.get('metaTotalPagesParam')]-1)
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});