...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.
...Compliance Level; Asset file size could be reduced 2 New slider library has a better API Add capybara_lockstep 2 0 - 5 Reduce flaky integration tests
Here are some popular mistakes when using nested forms: You are using fields_for instead of form.fields_for.
...selectively for your current need of change. For a more detailed example on this behavior compared to the --worktree option you can have a look on the example within the...
...git restore with --source for the usage --staged compared to --worktree To get a better idea, why this behavior might be useful I will add an example for both commands...
...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...
Your objects are now inspected with pretty colors: Note that if your inspection becomes wider than your terminal, IRB will automatically break it across multiple lines, like you probably...
TypeScript Code Playground Let's take a look at the same behavior for functions: interface User { name: string; age: number; } function greet(user: User) { console.log(`Hello ${user.name}`); }
...type assertion. You're saying: "Treat this variable as a different type; I know better than what you can guess." This can be useful when you're retrieving a point...
When an event listener on a DOM element throws an error, that error will be silenced and not interrupt your...
...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...
...issues, where you want to have a specific order of after_commit actions. Documented behavior Taken from the API documentation Registers a block to be called after all the current...
...may feel odd that the SQL statement says "UPDATE new_table". If your migration becomes too complex, you could put your logic into multiple reversible blocks (so they contain only...
end end A word of advice: Depending on your migration, you might be better off just defining 2 separate up and down methods instead of using change...
...data is guaranteed. There are however cases where you want to improve the user behavior (Rails error box) or reduce the number of exceptions e-mailed to your / collected by...
...I've seen examples using directory but there are no indications this attribute will become standard soon. Feel free to use to feel future-proof. On JavaScript file objects, webkitRelativePath...
So you have a heading that is just barely wider than the container it should fit into, and it wraps...
...named main, add a file app/webpack/packs/main.js. This will be your entry point. All assets belonging to that pack need to be imported here. Since webpack is configured to use Babel...
...its own import statements to load any dependencies it might have. Since this quickly becomes cumbersome, we usually add the following to simply import all our JavaScript files at once...
...request and model using implicit and convoluted protocols. We prefer a different approach. We believe that among all the classes in a Rails project, controllers are some of the hardest...
...to test and understand and should receive special care. It is our belief that: Controllers should be short and tidy Controllers should receive the same amount of programming discipline as...
Debugging performance issues in your Rails app can be a tough challenge. To get more detailed insights consider using the...
> {% client.global.set("auth_token", response.body.token); %} ### //Accessing a variable GET https://example.com/api Authorization: Bearer {{auth_token}} Complete documentation can be found here: https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html
CSS variables are very different from preprocessor variables. While preprocessors use variables to compile a static piece of CSS, CSS...
Sometimes you have a test expectation but actually want a better error message in case of a failure. Here is how to do that. Background Consider this test: expect(User.last...
Why is this cool? One might argue why we would want to have better error messages for test expectations when our tests are supposed to be always passing. Well...
...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...
This card existed before, but was outdated due to browser implementation changes. The information below is validated for the current...
...byebug commands, it comes in handy with it's features for many use cases beyond that to make your life easier. For this cheatsheat I tried to structure the most...
...instance_methods(false). method -- The same as running .methods. Commands to change (or add) behavior at breakpoints display / undisplay [ ] - display or undisplays an expression at stopped breakpoint enable / disable [id...