Skip to content

Instantly share code, notes, and snippets.

View AmilKey's full-sized avatar
🏠
Working from home

DekkoSecure 2 AmilKey

🏠
Working from home
View GitHub Profile
@AmilKey
AmilKey / gist:61068af43bd7963d7151
Created February 8, 2016 09:45
JSONSerializer ember data
`JSONSerializer` will normalize the JSON payload to the JSON API format that the
Ember Data store expects.
You can customize how JSONSerializer processes its payload by passing options in
the `attrs` hash or by subclassing the `JSONSerializer` and overriding hooks:
- To customize how a single record is normalized, use the `normalize` hook.
- To customize how `JSONSerializer` normalizes the whole server response, use the
`normalizeResponse` hook.
- To customize how `JSONSerializer` normalizes a specific response from the server,
use one of the many specific `normalizeResponse` hooks.
- To customize how `JSONSerializer` normalizes your id, attributes or relationships,

fetch pull request locally: git fetch upstream refs/pull/{number}/head:{local_branch}

@AmilKey
AmilKey / javascript-query-string.js
Created February 26, 2016 07:23 — forked from DavidWells/javascript-query-string.js
JavaScript :: Regex trick: Parse a query string into an object
// http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
// JavaScript regex trick: Parse a query string into an object
var queryString = {};
anchor.href.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
function($0, $1, $2, $3) { queryString[$1] = $3; }
);
// Usage
@AmilKey
AmilKey / gist:cc68a8d105bce2a402d7
Created February 29, 2016 10:46
Ember.js 2.3 implement @each.property observer
The problem is that steps.[].stepStatus is not a valid dependent key anymore. You should replace it by steps.@each.stepStatus.
Here is a summary of valid and invalid dependent keys in current Ember versions:
array - this observes if the array reference itself changes, e.g replacing the entire array with another value or array such as that oldValue !== newValue.
array.[] - this observes both when the array itself changes (above) and when the array length changes (functionally equivalent of array.length)
array.@each.property - observes both cases above and when property of some of the array's items change
array.@each.{prop,anotherProp} - you can also observe multiple properties while specifying only one key. This expands to array.@each.prop and array.@each.anotherProp.
array.@each - isn't valid anymore, no trailing @each. Use .[] instead.
array.@each.property.property - Also not valid. Note that @each only works one level deep. You cannot use nested forms like todos.@each.owner.name or todos.@each.owner.@each
You can reset your branch to the state it was in just before the merge if you find the commit it was on then.
One way is to use git reflog, it will list all the HEADs you've had.
I find that git reflog --relative-date is very useful as it shows how long ago each change happend.
Once you find that commit just do a git reset --hard <commit id> and your branch will be as it was before.
@AmilKey
AmilKey / best_practices.md
Created April 25, 2016 18:10 — forked from alanpeabody/best_practices.md
Ember Best Practices

Ember Best Practices

Some thoughts and ideas on best practices building Ember apps after 2 years building and maintaining 6+ apps. This is less about the obvious best practices, like use ember-cli, and more along the lines of when to use what technique. As with every best practice there are exceptions to every rule.

Ember data

Ember data relationships

Routing

for simple charts https://github.com/aomran/ember-cli-chart
for more complex charts https://github.com/ahmadsoe/ember-highcharts
for custom charts simply d3
@AmilKey
AmilKey / js-micro.js
Created May 29, 2016 19:32 — forked from yuval-a/js-micro.js
Javascript micro-optimizations
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
var obj = {};
// property === undefined is faster than hasOwnProperty(property)
// http://jsperf.com/hasownproperty-vs-in-vs-undefined/17
http://miguelcamba.com/blog/2016/01/24/ember-closure-actions-in-depth/
http://miguelcamba.com/blog/2016/04/13/tricks-for-build-composable-components-part-1/
https://dockyard.com/blog/categories/ember
http://frontside.io/blog/
@AmilKey
AmilKey / gist:fe4d2471b7b246a455afb2efe5048b60
Last active June 17, 2016 14:20
compare ember-cli versions
https://github.com/ember-cli/ember-addon-output/compare/v2.3.0...v2.5.0
https://github.com/ember-cli/ember-new-output/compare/v2.3.0...v2.5.0