Today I’d like to share a simple but very useful practice for managing Ruby and JS code under version control.
In our team, we always use trailing…
BetterSettings is a settings-management library for Ruby apps, which was designed in response to certain issues we faced when using settingslogic (one of the most popular…
Mongoid provides support for MongoDB’s Aggregation Framework, but writing raw queries can be confusing and is extremely verbose:
Product.collection.aggregate [
{ '$match' => { 'country' => 'US' } },…
Like most object-oriented languages, Ruby has both instance and class variables. The syntax is @name
for instance variables, and @@name
for class variables.
Let’s look at a simple…
In this post we take a look at effective ways to reduce the amount of watchers in our AngularJS application and improve the performance of our app.
AngularJS might not be hip anymore, but it’s still a useful framework to create interactive web apps. In this post we will take a brief tour through Angular’s internals: watchers and the digest cycle.
Cucumber steps often involve asserting a condition or the opposite of it. For example:
Then(/^I should see a "(.*?)" comment$/) do |message|
expect(page).to have_css('li.comment', text: message)
end…
jquery-rails
powers links and forms in Rails: it’s what makes remote: true
work, allowing any link to make an AJAX request unobtrusively.
rails-ajax_redirect
is an extension to this unobtrus…
Anko is a library for Android development in Kotlin. The library provides helper methods that take advantage of Kotlin’s extension functions as a way to reduce the amount of boilerplate the And…
A language helps to shape the libraries that are written on it. This can have unexpected side-effects when using these libraries from a different language.
In the frontend this has become increasingly more common because of all the availab…
Bash is the default terminal for most Unix distributions, so it’s very appealing to get the best out of it. If you enjoy customizing your setup, you might want to try something like zsh instead, which comes with similar functionality ou…
Blocks are a very unique part of Ruby’s syntax, but sometimes it can be tedious to write a block to perform a simple method call. An extremely common idiom in Ruby uses symbols to specify the method that should be called, but.. how does it work?
Mongoid is not designed for extensibility; if you need to modify its behaviour in a slight way, you will probably have no choice but to monkey-patch it.
A while ago I was working on a feature that required displaying information from several mongodb collections. The performance was pretty bad, since for each item being displayed it was necessary to traverse nested and polymorphic associations to get the rest of the data.…
One of the downsides of using an ORM is that it abstracts the queries in a way that it’s difficult to understand which queries are being performed; it’s harder to notice inefficient queries, since we didn’t actually write them!
A performance issue that is very common when using ORMs is the N+1…
By default, Mongoid will use single-collection inheritance when extending a Ruby class, by storing a _type
attribute in every document in the collection that contains the concrete class name,…
Recently I’ve been digging into the #lesscode movement, which proposes that software tools exist to solve real problems—a piece of code that doesn’t solve a problem is just waste. It also implies t…