Skip to content

Instantly share code, notes, and snippets.

View pixelhandler's full-sized avatar

Billy Heaton pixelhandler

View GitHub Profile
@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
@pixelhandler
pixelhandler / .gitignore
Created December 3, 2014 06:05
ember-cli-es5-shim
/node_modules
npm-debug.log
@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 / A-Perusal-of-Animated Transitions-With-Liquid-Fire.md
Created September 30, 2014 22:10
Ember-SC 9/30/14 Presentation Notes

A Perusal of Animated Transitions With Liquid-Fire

  • Walk through of the [Liquid Fire] library, demos and source for creating animated transitions
  • Some limitations (when should you use the library vs CSS only transitions)
  • Examples of adding animated transitions to an existing application

Overview

In an app built with Ember changes from bindings and observer trigger redrawing view which can happen fast, adding some transitions can help guide user from screen to screen.

@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 / intro-to-ember-data.md
Last active November 27, 2017 14:48
Introduction to Ember Data, notes from a talk at Ember-SC in Jan. '14

Introduction to Ember Data

What is Ember Data?

Ember Data is a library that integrates tightly with Ember.js to make it easy to retrieve records from a server, cache them for performance, save updates back to the server, and create new records on the client.

Ember Data can load and save records and their relationships served via a RESTful JSON API, provided it follows certain conventions.

@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 / playing-with-orbit-js-and-ember-js.md
Last active February 22, 2018 21:55
Notes from Ember-SC April 2014 meetup - Playing with Orbit.js and Ember.js

Playing with Orbit.js and Ember.js

This presenation is an exploration of rolling your own data persistence for and Ember.js Application

During this discovery I attempt to roll my own data solution. I've selected to use alpha software, Orbit.js. So not also choosing other alpha software at the some time. Not covering es6, broccoli, ember-cli etc.

The exploratory app is based on converting my blog app (uses REST) to use Web sockets with a Node.js backend. I am using some build tools brunch.io also borrowing from tapas-with-ember. The modules in the source code are [CommonJS modules].

@pixelhandler
pixelhandler / transforms.js
Last active October 3, 2016 06:54
Raw object and array tranforms for Ember Data
/*
DS.attr('object')
*/
App.ObjectTransform = DS.Transform.extend({
deserialize: function(value) {
if (!$.isPlainObject(value)) {
return {};
} else {
return value;
}
@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>