Skip to content

Instantly share code, notes, and snippets.

View pixelhandler's full-sized avatar

Billy Heaton pixelhandler

View GitHub Profile
@pixelhandler
pixelhandler / no-firefox-allowed.html
Last active August 29, 2015 13:58
HTML snippet to redirect website visitors using a Firefox browser.
<script type="text/javascript">
if (navigator.userAgent.match(/Gecko/) !== null && navigator.userAgent.match(/Firefox/) !== null) {
window.location = 'http://browsehappy.com'; // put a link here;
}
</script>
html, body { margin: 20px; }
h1 { font-size: 1.6em; padding-bottom: 10px; }
h2 { font-size: 1.4em; }
dl { padding: 15px; font-size: 1.4em; color: blue; }
/* Put your CSS here */
html, body { margin: 20px; }
h1 { font-size: 1.6em; padding-bottom: 10px; }
h2 { font-size: 1.4em; }
dl { padding: 15px; font-size: 1.4em; color: blue; }
@pixelhandler
pixelhandler / application_adapter.js
Last active September 15, 2015 02:37
Handle 404 with Ember Data, pseudo code: see route.js, application_adapter.js, router.js (given a response.status = 404) the router would redirect to a 404 route.
App.ApplicationAdapter = DS.RESTAdapter.extend({
ajaxError: function(jqXHR) {
var error = this._super(jqXHR),
errors = {};
if (jqXHR && jqXHR.status === 422) {
var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)["errors"];
forEach(Ember.keys(jsonErrors), function (key) {
errors[Ember.String.camelize(key)] = jsonErrors[key];
@pixelhandler
pixelhandler / app.js
Created February 5, 2014 19:43
Routing with a rootUrl, attempting to reproduce bug in double rootUrl. To use place the files in a folder named 'blog' then start a server in the parent (of blog) directory. `python -m SimpleHTTPServer` [ see http://pixelhandler.github.io/ember-data-extensions/blog/ ]
App = Ember.Application.create();
App.Router.reopen({
location: 'history',
rootURL: '/blog/'
});
App.Router.map(function() {
this.resource('posts', function () {
this.route('archive');
@pixelhandler
pixelhandler / jsbin.iCIXuzI.css
Created October 19, 2013 16:47 — forked from anonymous/jsbin.iCIXuzI.css
Ember Data (Canary) record w/ hasMany and belongsTo - jsbin link: http://emberjs.jsbin.com/iCIXuzI/1/
/* Put your CSS here */
html, body { margin: 20px; }
h1 { font-size: 1.6em; padding-bottom: 10px; }
h2 { font-size: 1.4em; }
dl { padding: 15px; font-size: 1.4em; color: blue; }
@pixelhandler
pixelhandler / resolveComponent.js.coffee
Created October 8, 2013 19:24
resolveComponent method for Ember.js added via DefaultResolver. We use a `Core` namespace as default, so keep common components on `Core.`
Ember.DefaultResolver.reopen
resolveComponent: (parsedName) ->
get = Ember.get
classify = Ember.String.classify
className = classify(parsedName.name) + classify(parsedName.type)
factory = get(parsedName.root, className) || get(Core, className)
return factory || @resolveOther parsedName
@pixelhandler
pixelhandler / entry.handlebars
Created September 25, 2013 06:17
entry.handlebars template
<h2>{{name}}</h2>
@pixelhandler
pixelhandler / entries.handlebars
Created September 25, 2013 06:16
entries.handlebars template
<h1>Entries...</h1>
{{#each entry in controller}}
{{render "entry" entry}}
{{/each}}
@pixelhandler
pixelhandler / application.html
Created September 25, 2013 06:11
application handlebars template, w/ outlet
<script type="text/x-handlebars">{{ outlet }}</script>