Skip to content

Instantly share code, notes, and snippets.

View SweeD's full-sized avatar

Markus Schwed SweeD

View GitHub Profile

Keybase proof

I hereby claim:

  • I am sweed on github.
  • I am sweed (https://keybase.io/sweed) on keybase.
  • I have a public key ASBVw4LlvjW7bKfkBV9k2jky_-OCqzJ6fzNsgmZE-Ey-cwo

To claim this, I am signing this object:

@SweeD
SweeD / rest_adapter_config.coffee
Last active December 17, 2015 18:40
DS.RESTAdapter plurals configuration (Ember-Data)
DS.RESTAdapter.configure("plurals",
galleries: "galleries" # If your model is called App.Galleries
gallery: "galleries" # If your model is called App.Gallery
)
locationToUse = if window.history.replaceState then 'history' else 'hash'
App.Router.reopen
location: locationToUse
App.Router.map ->
@resource 'portal', ->
@route 'dashboard'
@resource 'developers', ->
@resource 'messages', ->
@route 'inbox'
@route 'hidden'
@resource 'sysops', ->
@SweeD
SweeD / models.coffee
Created January 30, 2013 09:04
I try to load hasMany associations embedded...what am I doing wrong?!
App.User = DS.Model.extend
#...
addresses: DS.hasMany(GleichklangWeb.Address, { embedded: true })
App.Address = DS.Model.extend
#...
user: DS.belongsTo(GleichklangWeb.User)
@SweeD
SweeD / store.js.coffee
Created January 16, 2013 14:17
Sad try to to use a DS.Model and DS.Store up and running.
When I try to find a model in the console, i get an error.
MyApp.User.find(98)
> TypeError: Object Ember has no method 'merge'
@SweeD
SweeD / breadcrumb.handlebars
Created December 7, 2012 07:53
EmberJS - Dynamic breadcrumb rendering (with action as variable)
<!---- Version 1 with #each -->
<ul class="breadcrumb">
{{#each view.breadcrumbElements}}
<li><a {{action lastObject href=true}}>{{firstObject}}</a><span class="divider">/</span></li>
{{/each}}
</ul>
<!--- Version 2 with custom helper -->
<ul class="breadcrumb">
{{renderBreadcrumb view.breadcrumb}}
@SweeD
SweeD / base_menu_view.js
Created November 22, 2012 11:49
EmberJS - Add a computed property via method
App.BaseMenuView = Ember.View.extend{
statesForActiveCheck: [],
init: function(){
this._super()
this.get('statesForActiveCheck').forEach(this.addActiveCheckMethod, this)
},
addActiveCheckMethod: function(statePart){
functionName = statePart.replace('.', '_').camelize() + 'Active'; // the function name for 'account.settings' should be 'accountSettingsActive'
@SweeD
SweeD / new_trophy_route.rb
Created February 7, 2012 16:13
Routing with constraints
class NewTrohpyRoute
def self.matches?(request)
trophy_id = request.params[:trophy_id] # Not sure if you can get the params this way
return NewTrophy.where(:id => trophy_id).count > 1
end
end
@SweeD
SweeD / gist:948896
Created April 29, 2011 19:41
Ugly arrayify
class Object
def arrayify
[*self]
end
end