Ask for help
A team is migrating from PaperClip to CarrierWave and while the site seems to work fine, however tests are failing in strange ways. Specifically, tests about replacing images aren’t saving any changes to the database, but there are no validation errors.
The easy recommendation was HighCharts (http://www.highcharts.com/)
And there is also D3 (http://mbostock.github.com/d3/) but it is much more low level
- According to Amazons AWS newsletter, S3 now has 762 billion objects and is serving 500,000 requests per second.
Ask for help
- Where are the cool parking garages around the new office?
There appear to be many options close by.
- What is the best way to estimate hosting costs? (e.g. how many dynos on heroku etc.)
One suggestion was to try load testing the app in the real hosting environment to get an idea on what you can realistically take.
- A new version of Apache has been released that is trying to compete better with nginx
“Want to teach college students Rails/Pairing in a Software Engineering class?”
Write an email to Rob. Details to follow soon.
“How do I set the type of a Backbone class to not always be “child”?”
You can rename the constructor, it’s going to have that name. Don’t forget to call the constructor of the super class in it.
“Is there any tool to run Jasmine tests in several windows/browsers in parallel?”
Let us know.
The CSS property ‘box-sizing’ allows you to control the width of an element, including its border and padding.
is the default setting, where the width specifies the width of only the content
specifies the width for both the content, and the border and padding
have a wild guess.
Ember.js Meetup tonight at 6:30pm
Technically sold out, but if you just stick around after work, you can still attend.
- assert_template Matching: RSpec’s template matcher uses a reg ex, which is loose enough to cause some false positives.
will pass cause both of these to pass:
should render_template "_foo_bar.haml"
should render_template "_bar.haml"
The best solution presented was to explicitly say what you expect not to be rendered(should_not render_template “_bar.haml”). There has been some activity on Github recently around ActionController’s assert_template method, but none addressing this exact problem(1 example: https://github.com/rails/rails/pull/3879/files). The regex is complicated by the fact that it has to match ambiguous partials rendered with specific paths(should render_template “_bar.haml” needs to match render “foo/_bar.haml”).
Let It Be: If you declare a “let!” variable at the top of a file, and redeclare that variable with a “let” statement in a nested context, the variable will not be lazily loaded. RSpec evaluates it as a “let!”.
Binary Tempfiles: There is no way to open a new Tempfile in binary mode; you must open it first and then call foo.binmode.
Airbrake was acquired by Exceptional
Auto compiling SASS, pre-3.0: Adam used ‘compass watch’ and Foreman to automate the regeneration of stylesheets in development. This prevents him from having to wait for the sass to recompile on the first request he makes after modifying stylesheets. https://github.com/ddollar/foreman
Should receive, in any order: Ian & Suman were attempting to write an RSpec 1.3 spec that asserted a method was called with an array that included the correct elements; however, the order of the elements within the array was not important. Seems there is no array_including equivalent to hash_including. The solution they came to was to use the block style expectation as defined here: https://www.relishapp.com/rspec/rspec-mocks/docs/argument-matchers
foo.should_receive(:bar) do |arg1|
arg1.should =~ [3,1,2]
Anyone know of a built-in matcher for arrays similar to hash_including?
Ask for Help
“How can I know all the descendants of a class in the superclass at load time in ruby? I want to create a scope for each subclass.”
“What popovers should I use?”
We’ve used at least these two before:
“What recurring billing system should I use?”
We’ve had good luck with BrainTree and Recurly.
- backbone-forms is a plugin to backbone that provides model-based form views similar to rails’
- EmberJS meetup will be Feb 21, at our new pivotal office!
Ask for Help
“Are there any good enum gems that work with Rails 3.2?”
Try simple_enum. But watch out: by default it will take your array of string values and store the numeric indices in the database. To avoid having to migrate your existing data, you can pass it a hash:
as_enum :status, :pending => "pending", :active => "active"
A fun thing to try at standup: get everyone to clap once simultaneously without counting down.
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.”
 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
2 = 1
a = 0b11001100101010
30.downto(0) do |n| print a[n] end
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)
git config --global user.name "Santa Claus"
git config --global user.email "firstname.lastname@example.org"
git add .
git commit -m "Commit from Santa Claus"
# commit e5f4ebe6c689ddbf4ff595855fec544da5d8ce01
# Author: Santa Claus <email@example.com>
# Oops! I'm not Santa Claus
git config --global user.name "Easter Bunny"
git config --global user.email "firstname.lastname@example.org"
git commit --amend --reset-author
# commit d523479d487d04388972bea872913ffda734ef89
# Author: Easter Bunny <email@example.com>
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.
- 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
“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
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.
- 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
- 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
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?”
- “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?
- 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.
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
- “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?