Sometimes you want to have a time in a given timezone independent from you Rails timezone settings / system timezone. I usually have this use case in tests. Example
...results e.g. 2020-08-09 00:00:00 +0200 depending on the Rails timezone settings / system timezone. But in this example we always want to have the given time in...
ZSH is an alternative command line shell that includes some features like spelling correction, cd automation, better theme, and plugin support. You can replace Bash with ZSH like following:
...apt-get install zsh Setting ZSH as default login shell sudo usermod -s /usr/bin/zsh $(whoami) Opening a new terminal window will show you a dialog where you can configure your...
In rare cases you might need something like form_for (for using form builder methods on the resulting block element) but without the surrounding form. One such case would be...
...updating some of a form's fields via XHR. You can simply use Rails' fields_for to do things like this in your views (HAML here): - fields_for @user do...
...dependeny of capybara gem 'nokogiri', '< 1.6' # dependency of capybara gem 'rubyzip', '< 1' # dependency of selenium-webdriver, rubyzip 1+ requires Ruby 1.9 gem 'cucumber_factory' gem 'database_cleaner', '< 1'
...spinner', '~> 0.2.5' gem 'launchy', '~> 2.1.2' With these versions set, selenium-webdriver will be at version 2.35.1. This is because all later versions depend on rubyzip 1+. More info. After upgrading...
...image formats like JPG or PNG, each pixel is basically drawn on a fixed size canvas. To display such an image in a different size (say: 1.5 times larger than...
...Monitor) needs to interpolate the color values of missing pixels. The image will appear slightly blurred. This is different for vector graphics like the SVG (Scalable Vector Graphics) format. You...
PostgreSQL and ActiveRecord have a good support for storing dynamic attributes (hashes) in columns of type JSONB. But sometimes you are missing some kind of validation or lookup possibility (with...
...plain attributes you can use Active Record's built-in validations and have your schema.rb). One approach about being more strict with dynamic attributes is to use JSON Schema validations...
Rails ships with two separate build pipelines: Sprockets ("asset pipeline") and Webpacker. Webpacker has many more moving parts, but allows us to use ES6 modules and npm packages (through Yarn...
...does for JavaScript roughly what Bundler does for Ruby. Read the first couple of sections of its official documentation. You should learn how to: Install and update packages Remove packages...
change_association :parent, class_name: 'Parent::AsForm', inverse_of: :children end When saving a Parent::AsForm record with nested Child::AsForm records, the children will not be saved...
...case where you override the association with has_many :children,...
...and belongs_to :parent, .... Solution This can be fixed with appending autosave: true to the Parent model: class Parent < ApplicationRecord...
...aws-credential-file ./aws-credential.txt The output should look something like this: arn:aws:iam::322191361670:server-certificate/www.example.com arn:aws:iam::322191361670:server-certificate/testCert Now you have to upload...
...and includes the server certificate Amazon Resource Name (ARN) and GUID: arn:aws:iam::322191361670:server-certificate/www.example.com-2011 ASCACexampleKEZUQ4K If you got the error message similar to A client error...
Here is some JavaScript code that allows you to click the screen and get the clicked element's text contents (or value, in case of inputs). The approach is simple...
...element. When you click the overlay, we look up the element underneath it and show its text in a browser dialog. You can then copy it from there.
...To reconfigure later, call s3cmd --configure. Once you're done setting up, s3cmd gives you shell-like commands like s3cmd ls or s3cmd del somefile.png. Here is a full list...
s3cmd accesslog s3://BUCKET Sign arbitrary string using the secret key s3cmd sign STRING-TO-SIGN Sign an S3 URL to provide limited public access with expiry
...frame('iframe-id') do fill_in 'E-mail', with: 'foo@bar.com' fill_in 'Password', with: 'secret' click_button 'Submit' end Instead of the frame's [id] attribute you may also pass...
If you're also using Cucumber you could make a meta-step like this: When /^(.*?) inside the (.*?) frame$/ do |step_text, frame_id| page.within_frame(frame_id...
Let's say you have two screens: Show a given project Show a report for all projects Ideally you want both screens to be handled by different controllers like this...
...action ProjectsController#report. But these are all unsatisfying. What you can do is wrap the sub-resource in a collection block like you would do with custom collection actions:
S3cmd is a free command line tool and client for uploading, retrieving and managing data in Amazon S3. S3cmd reads its configuration by default from ~/.s3cfg, which is created once...
...you run s3cmd --configure. If you have many configurations, we recommend to always specify the configuration you want to use. This prevents applying actions to the wrong bucket. Examples:
Using CSS sprites for background images is a technique for optimizing page load time by combining smaller images into a larger image sprite. There are ongoing arguments on how useful...
...this still is, as modern browsers become more comfortable to load images in parallel. However, many major websites still use them, for example amazon, facebook, or twitter.
We often use VCR to stub external APIs. Unfortunately VCR can have problems matching requests to recorded cassettes, and these issues are often hard to debug. VCR's error messages...
...any way it will assume an error, because it can not know how the system it mocks would answer a request it has not yet recorded. Some signs an error...
...offers an 8 month paid trainee program 🇩🇪 for junior developers that are looking to start a professional career in web development. This curriculum contains goals, resources and code exercises for...
...When an exercise asks you to do multiple versions, these should be reviewable as separate commits or branches. After the review with mentor you can keep the best version and...
...signal("mouse::enter", function(c) local focused = client.focus if focused and focused.class == c.class and focused.instance == "sun-awt-X11-XDialogPeer" and c.instance == "sun-awt-X11-XFramePeer" then return end if awful.layout.get...
...change that one). Known issues This will not affect "find anything" as IntelliJ uses a sun-awt-X11-XFramePeer for it. There are no properties which allow distinguishing the "find...
...you upgraded it everywhere. But because it's FreeBSD it does not restart running services. After every old version is removed from /var/cache/pkg you restarted collectd and it does not...
...start anymore, you really want to downgrade to 5.8.1 again. But even pkg now has 5.9.0 and you need your own make config setup anyway. portdowngrade Enter portdowngrade. Install it...
...format ("2021-02-22T20:34:53.686Z") Google API guideline: https://google.aip.dev/ Numbers: String vs. Number The JSON number type is not a double. It's just a number...
...parsed as whatever the parser finds fitting. Pagination: Limit + Offset vs. Object ID / Pointer vs. System-Version Tables Filter Attributes e.g. ?fields=f1,f2,f3 Version in path (/api/v1/) or...
...truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. This will cause horrible, data-destroying bugs...
...this reason you should probably not use GROUP_CONCAT ever. At least you must set the value of group_concat_max_len to an insanely high value on every database...
jQuery is still a useful and pragmatic library, but chances are increasingly that you’re not dependent on using it in your projects to accomplish basic tasks like selecting elements...
...styling them, animating them, and fetching data—things that jQuery was great at. With broad browser support of ES6 (over 96% at the time of writing), now is probably a...
gem install ruby-debug (Ruby 1.8) or gem install debugger (Ruby 1.9) Start your server with script/server --debugger Set a breakpoint by invoking debugger anywhere in your code...
...path that crosses the breakpoint Once you reach the breakpoint, the page loading will seem to "hang". Switch to the shell you started the server with. That shell will be...
...Invoked Function Expessions (or IIFEs) to prevent local variables from bleeding into an outside scope: (function() { var foo = "value"; // foo is scoped to this IIFE })(); In Coffeescript an IIFE looks...
(-> foo = "value" # foo is scoped to this IIFE )() There is also a shorthand syntax with do: do -> foo = "value" # foo is scoped to this IIFE