...like invoices/generated?number=123. This could be your (very careless) controller method: def generated send_file File.join(Rails.root, 'shared', 'invoices', params[:number]) end This allows your users not only to...

...files but also any files your application can read, like this: invoices/generated?number=../../../../../etc/passwd # => send_file '/etc/passwd' You do not want this. In most cases you should prefer a show...

makandra dev

...of control”. A function that accepts a callback instead of a return value is saying, “Don’t call me, I’ll call you.”. Promises un-invert the inversion, cleanly separating...

...the input arguments from control flow arguments. This simplifies the use and creation of APIs, particularly variadic, REST and spread arguments. Note that promises are not a drop-in replacement...

If you want to expand your Areca Raid by swapping out the disks for larger ones you will need to do the following: Swap out all disks one by one...

...and wait until the syncronisation is finished in between. Reboot your server and enter the Raid Controller Configuration by pressing TAB at the right time. In the menu go the...

Haml 3.1.2 displays single quotes in FormBuilder#text_ field html escaped. You may see something like that: David's Chapter Looking at the page's HTML, your field's...

...common providers like the AWS one can quickly add up to a lot of storage space wasted. Each root module will download a copy of the same provider file. The...

...AWS provider is over 200 MB in size. To avoid creating multiple copies of the same file, you can use the Terraform Plugin Cache. Configuring the plugin cache:

makandra dev

...your remote database, you might not want it to dump each time you deploy (say, you're experimenting with staging and don't want ten dumps an hour). How to...

...skip dump creation: Capistrano 2 In your Capistrano file: before 'deploy:update_code', 'db:dump' unless fetch(:skip_dump, false) The second parameter of fetch sets a default value if...

makandra dev
litmus.com

...all for laying out your HTML emails. Email client HTML rendering is way more scattered than browser HTML. While you might have a pretty good understanding of what features and...

...patterns you can use to support all major browsers, I doubt anyone masters this craft for HTML email clients. The only way to ensure your email looks good (acceptable, at...

You can use attribute? as shorthanded version of attribute.present?, except for numeric attributes and associations. Technical Details attribute? is generated for all attributes and not only for boolean...

...These methods are using #query_attribute under the hood. For more details you can see ActiveRecord::AttributeMethods::Query. In most circumstances query_attribute is working like attribute.present?. If your attribute...

...re looking for is not present, first try upgrading ruby-build. If it's still missing, open a request on the ruby-build issue tracker: https://github.com/sstephenson/ruby-build/issues

...all the world to admire. For private gems this is very bad. To make sure this cannot happen, rubygems 2.2+ allows you to restrict eligible push hosts: Gem::Specification.new 'my...

...gem', '1.0' do |s| # ... s.metadata['allowed_push_host'] = 'https://gems.my-company.example' end In case you already messed up, follow these instructions to get your gem removed. Of course, it's not...

...Linux and MacOS, they look horrible on Windows, a problem that gets worse with smaller font sizes. The culprit is something called font hinting: ... hinting is about... programming instructions that...

...hinting, causing horrible rendering for most fonts. Embedding autohinting information into font files A solution is to autohint fonts and replace the existing (bad) hinting with the autohinting information.

You may want this for things where Rationals are being used, like when subtracting Date objects from one another. What's happening? Converting a Rational to a String usually...

...does something like this: 1.8.7 > Rational(2, 3).to_s => "2/3" 1.9.3 > Rational(2, 3).to_s => "2/3" 2.0.0 > Rational(2, 3).to_s => "2/3" However, when you have a...

jetbrains.com

In RubyMine folders can be excluded from search, navigation etc. by marking it as excluded. You might sometimes wish to exclude single files, too. An example could be .byebug_history...

...which is located in the project root directory. Single files can be excluded by pattern in the Settings: In the Settings/Preferences dialog Ctrl+Alt+S, go to Project structure

...Content-Type on GET request (which have a blank body), an external API may still force you to send one. Angular's $http service will strip that header when the...

...is blank. [1] This is possibly a misconception of RFC2616. Here is how to send GET requests with a Content-Type header in Angular. Example Consider this request: $http({ method...

blog.intercom.io

A fantastic guide for a dilemma facing any web-based product. Here’s a simple set of Yes/No questions that you can quickly answer before you add another item to...

...your product roadmap. Saying yes to a feature request – whether it’s a to an existing customer, a product enquiry, a teammate, or a manager – is immediately rewarding. It’s...

Soon after having written our shell-for script, we wanted to easily get dumps of our productions machines, too. This is how we do it: dump-for staging [-s]

...dump to your project's tmp directory and name it according to the capistrano stage you're calling for, here: staging.dump. When you pass the optional -s option, the dump...

blogs.msdn.com

What are Google’s plans for turning WebM into a genuinely open standard, one that is based on consensus like the rest of W3C’s HTML5 effort? Would Google fully...

...support such an effort? Even the WebM project’s domain is controlled by Google. Google chose to release WebM under the Creative Commons license which would theoretically allow a standards...

makandra dev

...Railses. Consul now uses Memoizer for this. Temporarily change the current power When you set Power.current to a power in an RSpec example, you must remember to nilify it afterwards...

...Otherwise other examples will see your global changes. A better way is to use the .with_power method to change the current power for the duration of a block:

makandra dev

Field error steps Spreewald's The...

...field should have an error and The...

...field should have the error...

...steps now have built-in support for Rails and Bootstrap (v3-v5...

...error classes. When using Bootstrap, it is no longer necessary to overwrite the steps in your project. At the same time, support for formtastic has been removed as there were...

On application servers, gems are usually bundled into the project directory, at a location shared across deployments. This is usually shared/bundle inside your project's root directory, e.g. /var/www/your-project/shared/bundle/.

When you are changing the version of RubyGems or Bundler on a system where gems are installed this way, you must wipe that bundle directory in addition to...

clipboardjs.com

We used zeroclipboard.js in some of our projects but now we switched to clipboard.js because it does not rely on flash. Flash support of the major browsers has ended.

...more advantages of clipboard.js: it consists only of a single javascript file, so it does not trigger additional requests with rails it automagically provides user feedback by selecting the text...

When using threads, you must make your code thread-safe. This can be done by either locking (mutexes) all data shared between threads, or by only using immutable data structures...

...Ruby core classes like String or Array are not immutable. There are several gems providing thread-safe collection classes in Ruby. concurrent-ruby The concurrent-ruby gem provides thread-safe...

hackernoon.com

...extremely popular amongst front-end developers the last couple of years. This isn’t surprising, as it has made it a lot easier for us to create dynamic layouts and...

jqueryui.com

UI sortable helps reordering items with drag 'n drop. It works quite fine. Proven configuration for sorting table rows When invoking the plugin, you may pass several options. This set...

...causing the thead border-bottom to grow // when the first table row is dragged tr.ui-sortable-helper:first-child + tr > td border-top: none