Skip to content

Instantly share code, notes, and snippets.

View ppcano's full-sized avatar

Pepe Cano ppcano

View GitHub Profile
@ppcano
ppcano / app.html
Created February 22, 2012 11:04
app.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta charset="utf-8">
@ppcano
ppcano / Assetfile.rb
Created February 22, 2012 14:56
ember assetfile with less and 0.6 rake-pipeline
require "rake-pipeline-web-filters"
require "json"
require "less"
class HandlebarsFilter < Rake::Pipeline::Filter
def initialize(&block)
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') }
super(&block)
end
@ppcano
ppcano / assetfile.rb
Created February 22, 2012 17:26
Suggestions for rake-pipeline
input "less" do
match "views/*.less" depends "import/*.less" do
filter CustomLessFilter
concat "project.css"
end
end
@ppcano
ppcano / assetfile.rb
Created March 13, 2012 16:22
Attempting concat multiple match to contact to the same output file
input "assets/vendor" do
match "*.js" do
filter Rake::Pipeline::OrderingConcatFilter,
["minispade.js", "qrcode.js", "jquery.js", "jquery.transit.js"], "app.js"
end
end
@ppcano
ppcano / assetfile.rb
Created March 13, 2012 17:38
assetfile
input "app" do
match "app/lib/**/*.js" do
minispade :rewrite_requires => true, :string=> false, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
#id.sub!('/tests', '/~tests')
require 'execjs'
class HandlebarsFilter < Filter
class << self
def contents
@@contents ||= [File.read("headless-ember.js"), File.read("ember.js")].join("\n")
end
def context
@@context ||= ExecJS.compile(contents)
@ppcano
ppcano / django_task_pie_adapter.js
Created April 11, 2012 14:26
ember rest adapter
findAll: function(store, type) {
var root = this.rootForType(type);
this.ajax(root, "GET", {
success: function(json) {
store.loadMany(type, json["objects"]);
store.typeMapFor(type).modelArrays.forEach( function(item) {
item.set('isLoaded', true);
});
@ppcano
ppcano / state.js
Created April 13, 2012 19:56
How to eliminate the following unnecesary code with ember-data
// I need to identify if the app is in a callback environment or fixtures
// ending with the following code which seems not to be the correct way to do that
insertCode: function(stateManager, code ) {
var invitations = Yn.store.find(Yn.Invitation, {code: code});
var self = this;
invitations.addObserver('isLoaded', function() {
self._callback(stateManager, invitations);
});
@ppcano
ppcano / with_i18n_integration.handlebars
Created May 30, 2012 13:33
What should be modified to integrate i18n at the object level?
{{view Yn.ActionButtonView action="login" textI18n="login"}}
{{view Yn.FormInputView type="tel" nameI18n="phone"}}
@ppcano
ppcano / bound_view.js
Created May 31, 2012 15:16
Is there any view in Ember to avoid something like the view below?
Yn.BoundView = Em.View.extend({
item: null,
render: function(buffer) {
buffer.push( this.get('item') );
},
_itemDidChange: Ember.observer(function() {