JavaScript: How to check if an object is NaN

NaN is difficult to compare in JavaScript because it never equals itself. Object.is() works in ES6; ES5 needs a number type check plus isNaN().

Angular-xeditable :: Edit in place for AngularJS

AngularJS directives for click-to-edit interfaces and editable grids, enabling in-place editing with support for complex forms.

jQuery: Run an event handler only once

Use one(...) for handlers that should fire a single time; it accepts the same arguments as on(...) and removes itself after the first event.

Managing vendor assets in Rails with Bower

Rails asset management becomes easier with bower-rails, using a Bowerfile and rake tasks to install, list, update, and rewrite vendored front-end packages.

Dealing with "TypeError: Converting circular structure to JSON" on JavaScript

Circular references make JSON.stringify fail with TypeError; a custom serializer or safe stringifier is needed to inspect or export object graphs.

Returning an empty ActiveRecord scope

none returns an empty ActiveRecord::Relation for default objects and other cases where no records should match, with a fallback initializer for older Rails versions.

When Sass-generated stylesheets print a Encoding::CompatibilityError

Sass-generated stylesheets can surface Encoding::CompatibilityError after a Rails and Ruby upgrade, often from stale cache files or mismatched UTF-8 and ASCII-8BIT encodings.

Reveal the indexes of an ActiveRecord table

ActiveRecord::Base.connection.indexes(:table_name) returns the database indexes defined for an ActiveRecord table, useful for checking schema performance and uniqueness constraints.

CoffeeScript: How to instantiate a class with an attributes hash

CoffeeScript classes can initialize instance properties directly from an attribute hash, similar to ActiveRecord-style mass assignment. constructor: ({ @name, @email }) -> binds fields automatically.

Sending raw JSON data to a member action in a controller spec

Rails 4 controller specs can send raw JSON in a member action request by passing the JSON body before the route parameters.

HTML5: Allow to choose multiple files with a vanilla file picker

Native file inputs can accept several uploads at once with multiple, but server parsing usually needs array-style names and custom Rails adaptation.

Angular Filters

Useful AngularJS filters for fuzzy string search and formatting values such as percentages.

Tagging in Rails 4 using Postgres Arrays

Store multiple labels in one field and query records by any or all of them with PostgreSQL array operators and a GIN index in Rails 4.

Iterate over any enumerable with an index

Iterating with a position counter helps rank or label items from any enumerable, including find_each and map, by chaining with_index to the enumerator.

rails/activeform

Alternative form objects for Rails may fit better than model-based validation and could become part of Rails 5.

Wrapping Your API In A Custom Ruby Gem

Packaging API bindings as a custom Ruby gem makes reuse and distribution easier, with tests recording HTTP interactions through VCR.

How to fix: Font too small when reading e-mails in Thunderbird

Plain-text e-mails in Thunderbird can ignore custom font settings because fonts are stored per character encoding, so some messages still appear tiny or default.

Backup an entire website using wget

Copying a whole website for offline browsing is simple with wget; recursive fetching and link conversion make local viewing possible.

pdfkit/wkhtmltopdf: When a header is invisible

header_html and footer_html can stay invisible in PDFKit and wkhtmltopdf unless the header or footer HTML starts with <!doctype html>.

Eager-loading polymorphic associations

Polymorphic eager loading avoids n+1 queries, but includes can fail when ordering or filtering on joined tables; explicit joins or preload keep loading efficient.

Rails 4.1+: New locale files require a Spring restart

Rails 4.1 development can ignore newly added I18n YAML files because Spring caches the load path; restarting Spring makes new translations appear.

Pete Hunt: React - Rethinking Best Practices

React.js shifts UI development toward reusable components and declarative rendering, reducing the complexity of manual DOM updates.

Use a Bash function to alias the rake command to Spring binstubs or "bundle exec" fallback

A Bash function can route rake to bin/rake when Spring binstubs exist, otherwise to bundle exec rake, speeding Rails 4.1+ and avoiding version conflicts on older apps.

Linux: Running a program with a different locale than your default

Run a command with a different locale when scripts or output parsing need English labels or predictable text. LC_ALL, LANG, and locale -a control and list available locales.