David StevensonDavid Stevenson
Standup 2/6/2012: Tracker UI updates
edit Posted by David Stevenson on Monday February 06, 2012 at 01:17PM

Ask for Help

"pg gem version 0.12.2 seems to be leaving connections open sometimes after our application server is dead. This results in transactions that never finish. Anyone know what's up?"

Interesting Things

  • Tracker released major UI updates on Saturday, and we're getting a lot of positive and negative feedback about it. Fear the change!
  • If you change code that's part of the rails asset pipeline, it won't really take effect until you deleted the cached files and allow the asset pipeline to regenerate them. This is because the pipeline watches for changes in the input files, but not in the source code.

Stephan HagemannStephan Hagemann
Test your Rake tasks!
edit Posted by Stephan Hagemann on Sunday February 05, 2012 at 10:05AM

There are several reasons why you should test your Rake tasks:

  • Rake tasks are code and as such deserve testing.
  • When untested Rake tasks have a tendency to become overly long and convoluted. Tests will help keep them in bay.
  • As Rake tasks typically depend on your models, you (should) loose confidence in them if you don't have tests and are attempting refactorings.

Kevin FitzpatrickKevin Fitzpatrick
SF Standup 2/3/2012: Fixnum[what?]
edit Posted by Kevin Fitzpatrick on Friday February 03, 2012 at 09:55AM

Ask for Help

"In an android web browser, if I have an autocomplete menu, and I click on one of the items, the click is registered on that item, but also seems to pass through to the elements behind it. For instance, a different text input was behind it, and became focused."

"Yep, that bug sucks." "The world may never know."

Interesting Things

  • Fixnum's [] operator works! According to the ruby docs

    "Bit Reference—Returns the nth bit in the binary representation of fix, where fix is the least significant bit."

    # 2:Fixnum in binary is 10, right? So…
    
    
    2[0] = 0
    2[1] = 1
    

    Also:

    a = 0b11001100101010
    30.downto(0) do |n| print a[n] end
    

    produces:

    0000000000000000011001100101010
    
  • innotop innotop is a 'top' clone for MySQL with more features and flexibility than similar tools. It'll let you do all sorts of dangerous things to your database! Have fun!!

  • Parse.com apparently accepts job applications via API! Check it out at https://parse.com/jobs#api

  • jQuery and the resize event – If you trigger a resize even on any object other than the window, it will not trigger the binding on that element. It will, however, trigger any resize bindings you have on window.

  • Did you commit to git under the wrong author's name and email? Use
    --ammend --reset-author after committing, but before pushing (unless you want a pain in the tuchus)

    mkdir foo  
    cd foo  
    git init  
    touch README  
    git config --global user.name "Santa Claus"  
    git config --global user.email "santa@claus.no"  
    git add .  
    git commit -m "Commit from Santa Claus" 
    git show 
    # commit e5f4ebe6c689ddbf4ff595855fec544da5d8ce01
    # Author: Santa Claus <santa@claus.no>
    
    
    # Oops! I'm not Santa Claus  
    
    
    git config --global user.name "Easter Bunny"  
    git config --global user.email "easter@bunny.cl"  
    git commit --amend --reset-author  
    
    
    git show  
    # commit d523479d487d04388972bea872913ffda734ef89
    # Author: Easter Bunny <easter@bunny.cl>
    
  • Looking to game the system on Superbowl Game day? Check out Onsi's Super Square http://supersquare.heroku.com/ stats app for your Squares pool.

Kevin FitzpatrickKevin Fitzpatrick
[Standup][SF] 2/2/2012: When does Van Damme show up?
edit Posted by Kevin Fitzpatrick on Thursday February 02, 2012 at 09:29AM

Interesting Things

  • When using TimeCop to travel in time in your specs, Time works normally, however DateTime will round to the nearest second. You have been warned

Help!

"What's going on with Facebooker and :class/:class_name_?"

Normally, in an ActiveRecord class definition you can use :class_name to change the class of an association.

has_many :foos, :class_name => 'Bar'

With Facebooker installed, one project found that their project was able to use :class

has_many :foos, :class => 'Bar'

When Facebooker was removed, it all blew up. No one had a solid answer as to why this worked in the first place.


"How do can we tell if our app's email has been marked as spam like Campaign Monitor claim to do? How else can I get spam reports?"

*"Does anyone know to get this info from ISPs?"

Services like Return Path can give you aggregate reports, but not specifics.

All other suggestions were vague and/or said "Contact the ISP."


*"How do I sign up for Heroku with a Google Group email?"

Allow non-member emails. You want to do this before you sign up, because some Pivots have reported that they could not get a second confirmation message to be sent.

Jacob MaineJacob Maine
Standup 2012/2/1: Speed kills
edit Posted by Jacob Maine on Wednesday February 01, 2012 at 10:17AM

Interesting Things

  • If you haven't noticed, Jasmine tests are at least twice as fast in Chrome as they are in Firefox. Closing the inspection pane makes it even faster. Be aware that part of the speed is from Chrome's aggressive caching, which can lead to erroneous test results.
  • One team is using Backbone's local storage. When they add model.clear() after every test run, their tests go from 20 seconds to over 100 seconds. Someone suggested the silent: true option, to suppress the change events that clear triggers.
  • To avoid bugs in minified JS put semicolons in the right spots. The easiest way to do that is to run a tool like JSLint or JSHint over your code. Add it to your test suite to prevent mistakes.

Ask for Help

  • "In IE8 the numbers don't show up on ordered lists if we dynamically create lis"

Or rather, they do, but only after hovering over the list. The common wisdom is that this has been broken in IE for a long time.

  • "Our project does some DNS resolution. Is there a preferred way to mock this in tests?"

No suggestions.

  • "When replying to an email each email system adds different junk to the message. We're processing those incoming replies. Any standard way to strip out the junk?"

Everyone is using the ugly regex approach. Are there mail gems that handle this?

Jacob MaineJacob Maine
Standup 2012/1/31: The bleeding edge
edit Posted by Jacob Maine on Tuesday January 31, 2012 at 10:09AM

Interesting Things

  • There's a new release of Backbone - 0.9.0. It's billed as a release candidate for 1.0, and seems to be a bit buggy, as RCs can be. However, it's exciting to see that Backbone is getting close to that milestone.
  • You should default boolean fields to true or false, at the database layer. Otherwise your queries have to deal with three-valued logic.
  • Rails 3.2 has some unexpected behavior. First, the generated form ids have changed ... what used to be id=user_new is now id=new_user. Second, if your routes file is missing an entry, you will no longer get errors in controller tests. If you liked that behavior, try out request specs.

Ask for Help

  • "Anyone seen problems with the latest REE and iconv?"

Everything works on the Linux machines, but on Macs, there's an error about an unrecognized target encoding. Iconv works on the command line, so it's something about REE.

Max BrunsfeldMax Brunsfeld
A convenient 'super' method for Backbone.js
edit Posted by Max Brunsfeld on Monday January 30, 2012 at 07:56PM

Inheritance in Backbone

Backbone.js comes with a minimalist OO inheritance framework similar to the one employed by CoffeeScript. Each base class has a static method called extend that is used to create a subclass, like this:

User = Backbone.Model.extend({
  // instance methods
},
{
  // class methods
});

extend returns a constructor whose prototype inherits from Backbone.Model.prototype. References to all of Backbone.Model's static methods and properties (including extend) are copied to the new constructor.

Calling 'super'

The constructor also receives a __super__ property, which references its superclass.

User.__super__ === Backbone.Model.prototype

This makes it possible to call super inside of a class or and instance method:

User.prototype.save = function(attrs) {
    this.beforeSave(attrs);
    User.__super__.save.apply(this, arguments);
};

CoffeeScript has a super keyword that compiles to the line above, but when using Backbone with plain javascript, its a little grating to have to type that out.

A small layer of convenience

I wrote this little super method (test-driven using jasmine) which saves me having to repeat the constructor's name all over the place. You call it like this:

User.prototype.save = function(attrs) {
    this.beforeSave(attrs);
    this._super("save", arguments);
};

The second parameter to _super is the array of arguments to pass to the overridden method. This is to optimize for the common case of passing the arguments object straight through.

There's no way to avoid having to repeat the method name like that, unless you wrap every method definition with a helper function that either passes the overridden method as a parameter (a la Prototype.js) or reassigns a hidden super property behind the scenes (like JS.Class or John Resig's approach). These approaches won't work with Backbone's ultra-minimalist inheritance system.

Jacob MaineJacob Maine
Standup 1/30/2012: It's all about sharing
edit Posted by Jacob Maine on Monday January 30, 2012 at 10:07AM

Interesting Things

  • should_not render_with_layout can be flaky. For example, asserting that an XHR request doesn't have a layout could fail if the request renders an email template that does have a layout. These matchers are not very sophisticated, mostly doing string matching, not real template resolution.

Ask for Help

Since the models are all built beforehand, it's tricky to write tests that make assertions about relative time. There were a variety of suggestions. You can write all the tests relative to a model: some_time.should == model.created_at - 3.days. You can wrap the entire suite and fixture generation in a Timecop block, but you'll have to deal with losing that context whenever any test calls Timecop.return.

  • "How do I separate multiple FixtureBuilder files, but allow them to reference objects created in each other?"

Typically you want to separate fixtures into smaller files. But, you also often want to reference objects in other files, for example so you can assign a user from user_fixtures.rb to a post in post_fixtures.rb. One solution is to eval each file in a loop, so they can share instance variables. You can also use User.where(:name => "Tom") but that's awkward and repetitive.

  • "Any suggestions for a CMS that would allow lots of different visual presentations of the content?"

The questioner is experimenting with branding. Not many suggestions... a shared database perhaps?

Dirk KellyDirk Kelly
[Standup][NYC] 01/30/2012
edit Posted by Dirk Kelly on Monday January 30, 2012 at 09:14AM

Interesting

  • Assigning a collection with an = operator will not set the id on the parent object, to do this use <<.

Events

  • This weeks brown bag will be on SQL, three of our Australian pivots will be presenting it. You can join our meetup group to find out more information.

Austin PutmanAustin Putman
Standup 1/24/2012 - Lobot Needs New Neighborhood
edit Posted by Austin Putman on Tuesday January 24, 2012 at 09:30AM

Ask for Help

*"Has anyone used Lobot to install CI somewhere other than EC2?"

Crrrrrrickets.......

Other articles: