Home

Mar 18

Using Cassette.MSBuild with Mono

Cassette.MSBuild lets you pre-build your asset bundles. This is a key step if you want to upload your bundles to a CDN for release builds instead of serving them from your web server. Unfortunately, Cassette.MSBuild is - as the name indicates - intended for use with MSBuild, not mono-based build processes. Here’s how you can use it in a non-MSBuild environment, like a NancyFX application built in Xamarin Studio on OS X.

Feb 28

List pending production migrations in Rails

Typically, you’ll know what migrations need to be run on the production database on deploy. You can check on a production server with rake db:migrate:status | grep down, but that requires the server to have been deployed with the migrations that need to be run. It’s much more convenient to be able to see what migrations in your local project have yet to be run on the production database.

Logger output

Feb 21

Rails Mixin: Skip automatic params parsing

There’s a common pattern when receiving third-party notifications (a.k.a. webhooks) in Rails applications: using request.raw_post to initialize a wrapper around the notification data. ActionDispatch automatically parses the body of the request into the request.params hash, which can incur significant overhead for large payloads. Skipping this automatic params parsing can result in a big speedup:

New Relic Stats

Feb 14

Rails Mixin: Log which line caused a query

Rails helpfully logs queries to ActiveRecord::Base.logger in development mode. This logging is an easy way to keep an eye on unexpected costs hidden by Rails’ abstractions - like N + 1 queries - which might otherwise slip by unnoticed. One thing I’ve found that makes this query logging even more useful is to log the line of code that caused the query.

Logger output