Skip to content

Instantly share code, notes, and snippets.

View trak3r's full-sized avatar

Thomas "Teflon Ted" Davis trak3r

View GitHub Profile
»brew outdated
ack (1.94 < 1.96)
cassandra (1.1.1 < 1.1.2)
gettext (0.17 < 0.18.1.1)
glib (2.24.2 < 2.32.4)
gnutls (2.10.2 < 2.12.20)
imagemagick (6.6.4-5, 6.7.1-1 < 6.7.7-6)
jpeg (8b, 8c < 8d)
libevent (1.4.14b < 2.0.19)
libgcrypt (1.4.6 < 1.5.0)
#!/usr/bin/ruby
# Copyright 2007 Amazon Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy of the License at:
#
# http://aws.amazon.com/apache2.0
#
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
@trak3r
trak3r / filters_view.js.coffee
Created March 5, 2012 17:23 — forked from kwhitaker/filters_view.js.coffee
Trying to scope back to currentView
class window.PlacementFiltersView extends Backbone.View
el: "#placements form#filters"
initialize: ->
currentView = @
# Create a hash of labels for the filter type-aheads
@filterLabels = []
jQuery(@el).find('.filter-top-level option').each ->
if jQuery(@).val() isnt ''
# saves are queued on a per-model-instance (aka "cid") basis...
Backbone.Model.prototype.saveWithoutQueue = Backbone.Model.prototype.save
Backbone.Model.prototype.save = (key, value, options) ->
if _.isObject(key) or not key? # flip 'em
options = value
value = null
options = (if options then _.clone(options) else {})
problem: if you call .save() on a model that doesn't have a value for "id", it
issues a "create" to the server. this creates a race condition if the model
has *already* issued a prior "create" and is awaiting its "id" assignment from
the server; which results in a *second* instance being created.
solution 1: at the model level, track so see if it has already issued a
"create" and if so wait for the "id" to be assigned. how would we do this?
with an event trigger maybe? throw the "save" operation onto a queue, bind it
to the event from the server response, then fire it off.
*** WTF does the client_destination association return nil unless it was "included" from the original model look-up!?
class Placement < ActiveRecord::Base
belongs_to :client_destination_type
belongs_to :client_destination,
:polymorphic => true,
:foreign_type => 'client_destination_type_class_name'
def client_destination_type_class_name
initialize: function(){
Placements.fetch({
success: _.bind(function(collection, response){
collection.each( _.bind(function(placement){
var view = new PlacementView({model: placement});
this.$(".placement-list").append(view.render().el);
}, this));
}, this)
});
},
$ ls -alR app/assets/
total 0
drwxr-xr-x 4 ted staff 136 Jan 4 09:33 .
drwxr-xr-x 9 ted staff 306 Jan 4 09:33 ..
drwxr-xr-x 3 ted staff 102 Jan 4 09:33 javascripts
drwxr-xr-x 4 ted staff 136 Jan 4 09:33 stylesheets
app/assets//javascripts:
total 8
drwxr-xr-x 3 ted staff 102 Jan 4 09:33 .
ruby-1.9.2-p0 :004 > date_format = '%m/%d/%G'
=> "%m/%d/%G"
ruby-1.9.2-p0 :005 > date = 17.days.from_now.to_date
=> Sat, 07 Jan 2012
ruby-1.9.2-p0 :008 > date_string = date.strftime(date_format)
=> "01/07/2012"
ruby-1.9.2-p0 :009 > Date.strptime(date_string, date_format)
=> Fri, 07 Jan 2011
UPDATE:
the problem is ActionDispatch::Routing::RouteSet::Dispatcher.controller_reference is
returning the controller's name as a String rather than the controller's class.
i have monkey-patched this to work as expected but there's no f'ing way this
is a legitimate bug or no Rails 3 sites anywhere would be working on Rack;
so i'm really curious as to WTF is the real problem here.
---