Skip to content

Instantly share code, notes, and snippets.

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

Saleh Souzanchi zoghal

🏠
Working from home
View GitHub Profile
@haric
haric / CloneEmberView.js
Created June 6, 2012 00:53
Ember clone view
function cloneFromView(obj) {
if (null == obj || "object" != typeof obj) return obj;
var copy = Ember.View.create({
templateName: obj.templateName
});
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr];
}
return copy;
}
@theturtle32
theturtle32 / compilingNode0.8.4onCentOS5.md
Created July 25, 2012 20:57
Compiling and Installing Node v0.8.4 on CentOS 5.x

Compiling/Installing Node 0.8.4 (and Python 2.6, required by Node) on CentOS 5

Update system packages -- will migrate system forward to CentOS 5.8. (Optional?)

$ sudo yum update

Install the EPEL Repo:

@boronine
boronine / fiddle.coffee
Created August 9, 2012 06:38
Synchronous and asynchronous form field validation using Ember.js bindings
window.App = Ember.Application.create()
App.Focusable = Ember.Mixin.create
# Don't let events spoil your Kool-Aid!
# Let's get these out of the way by turning them
# into a magical property:
focused: false
focusIn: (event) -> @set 'focused', true
focusOut: (event) -> @set 'focused', false
// vim: set ft=javascript sw=4 :
window.App = Ember.Application.create({
ApplicationController: Ember.Controller.extend(),
ApplicationView: Ember.View.extend({
templateName: 'application',
click: function(event) {
console.log('appView saw a click');
@Gozala
Gozala / resource.js
Created August 27, 2012 13:42
SDK API for registering new resource URIs
/*jshint asi:true globalstrict:true*/
'use strict';
let { Cc, Ci } = require('chrome')
let ioService = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService)
let resourceHandler = ioService.getProtocolHandler('resource').
QueryInterface(Ci.nsIResProtocolHandler)
@jordanperr
jordanperr / tree_block_helper.js
Created August 28, 2012 03:59
Tree Render, Handlebars
/*** Template Markup
{{#tree my_tree}}
The _id of this node is {{_id}}.
{{/tree}}
***/
/*** Template variable ***/
@ghempton
ghempton / ember-analytics.js
Created October 3, 2012 16:00
Drop in addition of analytics to Ember.js applications
Ember.Route.reopen({
enter: function(router) {
this._super(router);
if(this.get('isLeafRoute')) {
var path = this.absoluteRoute(router);
mixpanel.track('page viewed', {'page name' : document.title, 'url' : path});
_gaq.push(['_trackPageview', path]);
}
}
});
App.PostRoute = Ember.Route.extend({
serialize: function(router, post) {
// what should the state be serialized as
return { post_id: post.get('id') };
},
setupControllers: function(router, post) {
// which content should be used
this.set('controller.content', post);
},
App.Router.map(function(match) {
match("/posts/:post_id").to("post");
});
App.PostRoute = Ember.Route.extend({
// default implementation
deserialize: function(router, params) {
return App.Post.find(params.post_id);
},
@tomdale
tomdale / gist:4004913
Created November 2, 2012 23:10
Per-Type Adapters Proposal

Per-Type Adapter Hooks

Requirements

Many existing JSON APIs are not consistent between types. As JSON endpoints grew organically and were built by different engineers at different times, the style in which records are represented can vary wildly.

Historically, we have asked adapter authors to rely on the fact that the type of record is provided to all adapter hooks (either by passing a type argument, or by passing a record