Skip to content

Instantly share code, notes, and snippets.

View mikegrassotti's full-sized avatar

Michael Grassotti mikegrassotti

View GitHub Profile
@raytiley
raytiley / auth.js
Last active August 29, 2015 13:56
A controller using SimpleLogin from Firebase. Returns promises from login / logout to make working with Ember Routing simple.
var dbRef = new Firebase("https://YOUR-FIREBASE.firebaseio.com/");
export default Ember.Controller.extend({
/**
@property currentUser
@type {User}
@default null
*/
currentUser: null,
@lukas-vlcek
lukas-vlcek / gist:1012051
Created June 7, 2011 11:18
Full search query #BBUZZ 2011
{
"from" : 0,
"query" : {
"filtered" : { "query" : { "query_string" : { "query" : "jboss server" } },
"filter": {
"and" : [
{"range" : { "date" : {"from":"2007-07-25","to":"2010-12-16"}}},
{"terms" : { "_index" : ["weld"]}},
{"terms" : {"mail_list" : ["dev"]}},
{"terms" : {"from.not_analyzed" : [ "Galder Zamarreno <galder.zamarreno@redhat.com>","Pete Muir <pmuir@redhat.com>"]}}
@jkamenik
jkamenik / proxy.rb
Created August 17, 2011 13:01
Sinatra Proxy
res = Net::HTTP.start(<server>,<port>) do |http|
http.get <url>
end
res.body
@joshed-io
joshed-io / js2coffee_converter.rb
Created November 3, 2011 04:00
Ruby script to automate running js2coffee against existing javascript folders
#!/usr/bin/env ruby
#run from within a folder containing your .js files
#each file will be converted to a .coffee file and copied to ../coffeescripts
#respects nested directory structure, creating what's necessary
Dir.glob("**/*.js").each do |file|
`mkdir -p ../coffeescripts/#{file_path = file.gsub(/[\/]?[^\/]*\.js/, "")}` unless file_path == ""
`js2coffee #{file} > ../coffeescripts/#{file.gsub(/\.js/, "")}.coffee`
end
@lancejpollard
lancejpollard / index.md
Created May 10, 2012 20:50
Ember.js code that *will* cause performance problems

ember-views/view.js

Your element won't render until the next frame. This will cause a flash.

// Schedule the DOM element to be created and appended to the given
// element after bindings have synchronized.
this._insertElementLater(function() {
  this.$().appendTo(target);
});
@rlivsey
rlivsey / modal.js.coffee
Created May 24, 2012 09:56
Ember.js modal
MB.ModalHeaderView = Ember.View.extend({
classNames: ["modal-header"]
contentBinding: "parentView.content"
titleBinding: "parentView.title"
defaultTemplate: Ember.Handlebars.compile("""
<a href="#" {{action close target="view.parentView"}} class="close">x</a>
<h3>{{view.title}}</h3>
""")
})
@ghempton
ghempton / async-routing-example.md
Created July 20, 2012 17:43
Async Routing Example

Example of the Need for Async Routing

App.Profile = DS.Model.extend({

});

App.User = DS.Model.extend({
  profile: DS.belongsTo(App.Profile)
casper.test.emberDidRender = function(cbk){
casper.evaluate(function(){
return window.Ember.run.end();
});
cbk.call(casper)
};
// use
casper.then(I_click_edit);
@matthijsgroen
matthijsgroen / README.md
Last active December 12, 2015 10:39
Unit testing views in Ember

We (at Kabisa ICT) are in the process of learning Ember.js. We do all our development TDD, and want Ember.js to be no exception. We have experience building Backbone.js apps test-driven, so we are familiar with testing front-end code using Jasmine or Mocha/Chai.

When figuring out how to test views, we ran into a problem when the template for the view uses has a #linkTo statement. Unfortunately we are unable to find good test examples and practices. This gist is our quest to get answers how to decently unit-test ember applications.

When looking at the test for linkTo, we noticed it contains a full wiring of an ember app to support #linkTo. Does this mean we cannot stub this behaviour when testing a template?

How do you create tests for ember views using template renders?

@dmonagle
dmonagle / ember_crud.coffee
Last active December 12, 2015 12:39
Ember mixins for CRUD functionality.
Ember.EditController = Ember.Mixin.create(
saveError: false
saveInvalid: false
isEditing: false
# Set associations to be associations of the content. These will then be checked for validity on save
# and all of the flags, such as isDirty and isLoaded, will take these associations into consideration.
#
# Eg: A user may have an address model which is edited within the same transaction.
# In this case you would put: