Skip to content

Instantly share code, notes, and snippets.

View pixelhandler's full-sized avatar
🍊
Working remotely

Bill Heaton pixelhandler

🍊
Working remotely
View GitHub Profile
@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');
/* 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; }
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 / 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>
@pixelhandler
pixelhandler / index.html
Created April 10, 2014 04:24 — forked from anonymous/index.html
Mocking AJAX with ember-testing-httpRespond; attempt to create a simple jsbin using ember-testing-httpRespond; however not working and breaks jsbin. See: http://emberjs.jsbin.com/cexiy/1/edit Comment in PR here: https://github.com/emberjs/website/pull/1401/#issuecomment-39868759
<!DOCTYPE html>
<html>
<head>
<title>Posts - Mocking AJAX with ember-testing-httpRespond</title>
<meta name="description" content="Using All Helpers" />
<meta charset="utf-8">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.14.0.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
@pixelhandler
pixelhandler / autosavemodel.coffee
Created May 23, 2014 00:11
Auto save an Ember.js model (DS.Model)
get = Ember.get
App.BaseModel = DS.Model.extend
autoSave: (->
if get(@, 'isDraft') and !(get @, 'isNew') and isReallyDirty @
Ember.run.debounce @, '_doAutoSave', 12000
).observes 'isDirty'
_doAutoSave: ->
@pixelhandler
pixelhandler / is-really-dirty.coffee
Created August 21, 2014 17:19
function to check if a model is really dirty (Ember Data record, DS.Model)
# Strange that model can be dirty with no changed attrs
isReallyDirty = (model) ->
hasChangingAttr = false
attrs = []
model.eachAttribute (name)-> attrs.push name
for own key, value of model.changedAttributes()
if attrs.contains key
hasChangingAttr = true
break
hasChangingAttr
@pixelhandler
pixelhandler / test-lobotomized-owl-selector-speed.html
Last active August 29, 2015 14:08
Testing a CSS selector: lobotomized owl selector
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS Universal Selector - Test performance of Lobotomized Owl Selector</title>
<!-- See http://alistapart.com/article/axiomatic-css-and-lobotomized-owls -->
<!-- Perf test based on https://github.com/benfrain/css-performance-tests/blob/master/CSS%20Selectors/15.html -->
<meta name="description" content="Rudimentary Test for Lobotomized Owl Selector Speed">
<meta name="viewport" content="width=device-width">
<style>
@pixelhandler
pixelhandler / .gitignore
Created December 3, 2014 06:05
ember-cli-es5-shim
/node_modules
npm-debug.log
@pixelhandler
pixelhandler / slides.js
Created January 14, 2015 17:59
Ember CLI http-mock backed by RethinkDB
/*
Add `nouns` as http mocks and use in a local db, available via API in develoment
* Install the adapter `npm install rethinkdb_adapter --save-dev`
* Install RethinkDB, see https://github.com/pixelhandler/ember-slide-deck/blob/master/bin/install_rethinkdb.sh
* Start db `rethinkdb`
* Setup Db and Table, see https://github.com/pixelhandler/ember-slide-deck/blob/master/bin/setup_db.js
* Generate a mock `ember g http-mock nouns` and edit your mock to use the db, see code below for 'slides'
* Set your application adapter to use `namespace: 'api'`
* In our routes use Ember Data in your model hook