When redirecting you should take care to use the right HTTP status code.
When redirecting from a controller Archive , the default status code is 302 Found (aka Moved Temporarily):
red...
If you have a JS fiddle, you can open it in fullscreen by appending /show
to the URL.
Example: https://jsfiddle.net/b275g910/3
=> https://jsfiddle.net/b275g910/3/show
Browsers support different types of redirects.
Be very careful with these status codes:
301 Moved Permanently
308 Permanent Redirect
Most browsers seem to cache these redirects forever, unless you set different Cache-Control
headers. If you don't have any cache control headers, you can never change them without forcing users to empty their cache.
Note
When starting a project we always make a good estimate of all known requirements, and plan budgets and available developers accordingly.
Requirements change. Budgets usually don't.
To make sure a project stays on track, we update our estimates once a month and compare them to the remaining budget. If this doesn't match any more, we have to act.
To update an estimate, do the following:
Adding a gem means you take over the liability towards the external code.
Based on " To gem, or not to gem Archive ":
Recent IRB versions include a multi-line autocomplete which may be helpful to novice users but can be distracting.
Cycling through options works by pressing the Tab key (as usual), and for some methods you also get some kind of documentation, though the quality of results is usually not on par with your IDE of choice.
I have found that it also slows down my IRB in some cases, or that pressing the Backspace key does not always reliably remove characters, which I find more annoying than useful.
You may disable multi-line autocomplete by
It might sometimes be useful to check whether your Rails application accesses the file system unnecessarily, for example if your file system access is slow because it goes over the network.
The culprit might be a library like carrierwave that checks file existence or modification times, whereas your application could determine all this from your database.
One option it to use strace for this, which logs all system calls performed by a process.
To do this, start your rails server using something like
DISABL...
TL;DR Most web applications do not require action on this. SameSite=None
(old browser default) will continue to work, and SameSite=Lax
(new Chrome default,
gradually rolled out
Archive
) is an even better default for cookies. Set SameSite=Strict
only for extra security in special cases (see below). If your application is rendered in an iframe (e.g. a video player or some news stream), you need to configure its relevant cookies as SameSite=None
.
The SameSite
cookie attribute targets **c...
We're always striving towards keeping our website's JavaScript as small as possible.
If you're using webpack(er), you can use the webpack-bundle-analyzer plugin Archive to get a good overview, which of your JavaScript modules take up how much space, and where you can optimize.
To use it, add it via npm or yarn
yarn add webpack-bundle-analyzer
Then add this to your environment.js
:
// Uncomment this code to show statistics of bundle sizes. Generated file will automatically o...
There was an issue with makandra_sidekiq < 0.2 concerning the stopping of Sidekiq.
Sidekiq < 6 has two finishing timeouts
Archive
: one for finishing things itself (A), and one for sidekiqctl
before killing a running Sidekiq instance (B). While USAGE banner of sidekiqctl
advises to have B always greater than A, makandra_sidekiq < 0.2 runs sidekiqctl
without passing a timeout. If the Sidekiq instance is configured with a timeout higher than the default 10s timeout of sidekiqctl
, `sideki...
Testing file download links in an end-to-end test can be painful, especially with Selenium.
The attached download_helpers.rb
provides a download_link
method for your Capybara tests. It returns a hash describing the download's response:
details = download_link('Download report')
details[:disposition] # => 'attachment' or 'inline'
details[:filename] # => 'report.txt'
details[:text] # => file content as string
details[:content_type] # => 'text/plain'
Compared to [other approaches](...
When you have a string containing umlauts which don't behave as expected (are not matched with a regexp, can't be found with an SQL query, do not print correctly on LaTeX documents, etc), you may be encountering umlauts which are not actually umlaut characters.
They look, depending on the font, like their "real" umlaut counterpart:
However, they are not the same:
>> 'ä' == 'ä'
=> false
>> 'ä'.size
=> 1
>> 'ä'.size
=> 2
Looking at how those strings are constructed reveals what is going...
Within a Flexbox layout, there are multiple CSS attributes that may affect a child's basis (the initial width before flexing). You might be confused how flex-basis
, width
, min-width
and the intrinsic width of your content play together.
The attached article Archive explains the differences. In summary:
flex-basis
is set, that is used as the basisflex-basis
is set, the width
is used as the basisflex-basis
nor width
is set, the content...Ruby's __FILE__
keyword returns the path to the current file. On popular for this are Ruby binaries:
#!/usr/bin/env ruby
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
require 'my_cli'
MyCli.run!
However, if you create a symlink to this file, this will no longer work. __FILE__
will resolve to the path of the symlink, not to its target.
One solution is to use File.realpath(__FILE__)
.
In Ruby 2+ you can also use this:
$LOAD_PATH << File.expand_path('../lib', __dir__)
__dir__
is simply a shortcut for `Fi...
Is your application doing something expensive every few seconds? Maybe an animated slider that rotates images? Maybe you are updating data over the network every five minutes?
It's a good idea to pause this if the your document tab is not even visible to the user. This saves your user's battery and data plan.
You can ask
document.visibilityState
Archive
whether this tab is visible:
function pulse() {
if (!document.visibilityState || document.visibilityState =...
Checking if a JavaScript value is of a given type can be very confusing:
typeof
and instanceof
which work very differently."foo"
) and sometimes an object (new String("foo")
) and each form requires different checksnull
(null
, undefined
and NaN
) and each has different rules for...Current webkit browsers like Chrome and Safari have a special variable in their consoles that refers to the selected DOM node in the elements panel. This lets us easily inspect Angular scopes.
Right click in the page and click "Inspect" to open the Dev Tools
Select the element you're interested in from the elements panel
Focus the console (in Chrome, hit ESC)
Get the scope object and store it
s=$($0).scope()
// That is:
element = $0 // Store element
$element = $(element) // Wrap with j...
Ruby version 3.1
uses by default the gem openssl-3.0.0
. This can cause issues with the gem net-ssh (6.1.0
). This is
a known bug
Archive
.
Typically this can cause an error while deploying an application with capistrano:
could not verify server signature (SSHKit::Runner::ExecuteError)
or
Ed25519::VerifyError: signature verification failed!
As temporary workaround add the following line to your Gemfile
:
gem 'openssl', '<3'
For more information check [the compatibility no...