When you allow file uploads in your app, a user might upload content that hurts other users. Our primary concern...
...use ActionDispatch::RemoteIp use Rails::Rack::Logger use ActionDispatch::ShowExceptions use ActionDispatch::DebugExceptions use BetterErrors::Middleware use ActionDispatch::Reloader use ActionDispatch::Callbacks use ActiveRecord::Migration::CheckPending use ActionDispatch::Cookies
This guide shows how to create an AngularJS application that consumes more and more memory until, eventually, the browser process...
Here are some popular mistakes when using nested forms: You are using fields_for instead of form.fields_for.
You can use RSpec::Matchers.define_negated_matcher to define a negated version of an existing matcher. This is particularly useful...
...application does not need to support time zones. Disable them like this: config.time_zone = 'Berlin' # Your local time zone config.active_record.default_timezone = :local config.active_record.time_zone_aware_attributes = false
...s Time will use that. In the example above, it should be in the Berlin zone. Using time zones If your application should support time zones, the default ActiveRecord configuration...
CarrierWave comes with some RSpec matchers which will make testing more comfortable. Let's say you have an Uploader like...
RSpec allows you to mark a single Example/ExampleGroup so that only this will be run. This is very useful when...
...timing in your tests, this requires a lot of work and sustained diligence. A better approach is to use feature flags to only enable these features for the one test...
...is something that we fixed in the code, not the test. The code is better now. However, it took a day to find a bug that no user has seen...
...use a library like Lodash or Unpoly's up.util that will hide this inconsistency behind functions like _.isBoolean(x) or _.isObject(x). However, I encourage every JavaScript developer to understand...
...JavaScript has a caveat that typeof null returns 'object'. No developer would consider this behavior useful, since you cannot get or set properties with null. Taking into consideration all of...
...many thousand rows. Once your database tables grows to millions of rows, migration performance becomes an issue. We will talk about this in another card. 1. Use the full power...
...updates with it. As a first example, we have Post has_many :followers. For better performance, we want to cache the number of followers in Post#followers_count.
...this issue for PATCH/DELETE. If you make requests yourself, watch out for the following behavior. When you make an AJAX request PATCH /foo and the /foo action redirects to /bar...
SVG files often contain redundant information, like editor metadata or hidden elements. When esbuild handles your static assets, you can...
...test (of course, you should be using parallel_tests). However, in projects that go beyond clicking around in a web GUI and checking results, there might be various measures to...
...need a library for it. With ActiveRecord you could implement it with a single belongs_to association: class Node < ActiveRecord::Base belongs_to :parent, class: 'Node' end Any modification of...
...even the worst method had time average saving of 00:54 minutes and the best 01:11 minutes. For 25 commits per day this would be an average time saving...
...have not been normalized to the total execution time of the testsuite. A cost benefit analysis could give greater insight into the amortization of costs and about the actual time...
Before any technical considerations, you need to understand the old system as best as possible. If feasible, do not only look at its API, or database, or frontend...
"Special object attributes" like frozen, tainted and singleton methods are ignored (like dup) Behavior depends on implementation Hash: returns a deep copy, i.e. referenced objects/values will be deep_duped...
...not waste your time optimizing code where it does not even matter. However, I believe there are some kinds of optimizations you should do right away, because they are either...
...how a library works. This is especially true for all polyfill that fix browser behaviours with all weird kinds of tricks. In your own scripts, don't add event handles...
...should help understanding the basic concepts of Ruby's object model and how things behave. Usage of objects in Ruby When working with objects in Ruby, you might think of...
...declare instance methods. This may seem completely counterintuitive. The reason is that class_eval behaves as if you would open the class manually and then write code into it. The...
Debugging performance issues in your Rails app can be a tough challenge. To get more detailed insights consider using the...
An introduction to mangling When you minify ("compress", "optimize") your JavaScript for production, the names of your functions and variables...
...if .second-item could be rendered smaller without problems or has because you defined behavior for it. +---------+--------------------------------------+ | | - 1000 characters looooooooooooong | | +---------+--------------------------------------+ Try it on CodePen. There are two ways to fix...
...may just set overflow: hidden or maybe on .second-item and/or add some overflow behavior and you're done. In some cases, this might not be the solution because the...
...an attack) will fill up our conntrack tables. Decide which option resolves the situation best with minimal impact on production: $ sudo conntrack -D -s 49.12.3.247 # example: delete all conntrack table...