When you create a temporary file (e.g. to store a generated Excel sheet) and try to send it to the browser from a controller, it won't work by default...
...this controller action: class FoosController < ApplicationController def download file = Tempfile.new('foo') file.puts 'foo' file.close send_file file.path end end Accessing this controller action will usually raise a 404 not found...
There is an option you can set so that when using the cd command, small typos are automatically corrected. Add the following to your ~/.bashrc: # cd: autocorrect small typos and...
shopt -s cdspell Example: cd Porjects # Projects pwd # /home/judith/Projects Also, I recommend adding aliases for your most common typos of commands you regularly use to your ~/bashrc...
Rendering thousands of records on one page is slow. Pagination loads one page at a time and keeps large lists fast. Important Work on this lesson in advisor mode.
You can explain why rendering a large collection on one page is slow — queries, object instantiation, rendering — and how pagination avoids it. You can add pagination to a list...
...measurement metrics in Linux. These are the differences: Code Name Description vsz virtual memory size Total amount of memory a process may hypothetically access. Includes swapped memory, memory from external...
...libraries and allocated memory that’s not used. rss resident set size Total amount of non-swapped used physical memory. Includes memory from external shared libraries. pss proportional share size...
...T06:22:17.484221 #2698200] INFO -- : [53a240c1-489e-4936-bbeb-d6f77284cf38] more Goal When searching through Rails logs on production, it's often hard to see all lines that belong to...
...the same requests, since output of different requests is often interwoven. Instead, we want to find all requests that match a pattern, and then print all lines that share the...
Traveling Ruby is a project which supplies self-contained, "portable" Ruby binaries: Ruby binaries that can run on any Linux distribution and any OS X machine. This allows Ruby app...
...to bundle these binaries with their Ruby app, so that they can distribute a single package to end users, without needing end users to first install Ruby or gems...
...posts; if you use pagination the queries will be more complicated, but the point still stands. Looks harmless enough? It is not. The problem ActiveRecord will rewrite this into a...
...query using LEFT JOINs which looks something like this: SELECT "blog_posts".*, "comments".*, "attachments".* FROM "blog_posts" LEFT OUTER JOIN "comments" ON "comments"."blog_post_id" = "blog_posts"."id"
Rails wraps your parameters into an interface called StrongParameters. In most cases, your form submits your data in a nested structure which goes hand in hand with the strong parameters...
...However, there are cases where this does not fit your use case, or has side effects. If you do it differently, be extra careful not to introduce security issues.
#!/usr/bin/env ruby require_relative "../config/boot" require "active_support/continuous_integration" ActiveSupport::ContinuousIntegration.run do step "Setup", "bin/setup --skip-server" step "Security: Rubygems audit", "bundle", "audit" step "Security: NPM audit", "npm", "audit"
#!/usr/bin/env ruby require_relative "../config/boot" require "active_support/continuous_integration" ActiveSupport::ContinuousIntegration.run do step "Setup", "bin/setup --skip-server" step "Style: Ruby", "bin/rubocop" step "Style: JS", "npx prettier", ".", "--check" step "Style: CSS...
When you're using feature branches, they will stack up if you don't delete them after the merge to master. Here's how to tidy them up. Delete feature...
...Find already-merged branches by running # On branch master git branch --merged You may safely delete each of the listed branches, because they point to commits that are contained in...
window.getSelection().toString(); Browser support: IE9+, Android 4.3+, Safari...
Surprisingly exhaustive new icon set by Google. Available as PNG, SVG and as a icon font. Comment from Henning I tried using the icon set in a project. I found...
...the quality, selection and handling far worse than what we are used to in FontAwesome...
curl http://ipecho.net/plain; echo
The Paper elements are a set of UI elements that implement the material design system...
Impressive set of design guidelines from Google...
Declare an enum attribute where the values map to integers in the database, but can be queried by name.
...the dot-underscore (._foo, ._bar, etc.) files created by (badly-behaved) Mac OS X systems on non-AFP server volumes...
Since we are migrating from our homegrown mixins.sass and helpers.sass to Compass, here is a list of all the mixins provided by Compass...
...about what HTTP was designed for. The original post has been removed for some stupid gender discussion...
Great look at the tradeoffs between progressive enhancement with jQuery or similiar, vs. client-side views...
For custom Rake tasks, you shouldn't need to modify them after the original definition. However, if you want to add behavior to some vendor tasks (such as those defined...
...always been able to access the humanized version for the current value like this: song = Song.new(:genre => 'pop') song.humanized_genre # => 'Pop music' You can now also retrieve the humanized version...
...of any given value by passing it as an argument: song.humanized_genre('rock') # => 'Rock music...
The amount helper now retrieves the decimal separator from your I18n dictionary (number.format.separator) instead of hardcoding it to a comma. money_amount helper tunnels options to amount New money_amount...
Nice article to educate your non-geek girlfriend/boyfriend about the joys of programming.