...for :freeze support. As an example, consider the following Yaml file: --- message: - hello - universe foo: bar: baz: "example" We can now load it as usual, but pass freeze: true.

...YAML.safe_load_file('example.yml', freeze: true) => {"message"=>["hello", "universe"], "foo"=>{"bar"=>{"baz"=>"example"}}} The Hash itself is frozen: >> test.frozen? => true And no matter how deep you dig, everything inside that...

docs.ruby-lang.org

The sprintf method has a reference by name format option: sprintf("% d : % f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000 sprintf("%{foo}f", { :foo => 1 }) # => "1f" The format identifier % stands for...

...parameters as described below. If possible, specify allowed parameters explicitly, e.g. url_for(params.permit(:foo, :bar)). Rails 7.1+ url_for(path_params: request.path_parameters, params: request.query_parameters) Rails versions before...

makandra dev

...and will return an enumerator. This is what allows you to do things like ['foo', 'bar', 'baz'].each.with_index.collect { |name, index| name * index } # -> ["", "bar", "bazbaz"] If you write your own each...

...parentheses (()) are not optional in JavaScript function calls. Understand the difference between function pointers (foo) and function invocations (foo()). Notice the parallels between blocks ("procs", "lambdas") in Ruby and function...

mysqlperformanceblog.com

...index when your query is well-formed: mysql> EXPLAIN SELECT * FROM users WHERE email = 'foo@example.com'; +----+-------------+-------+-------+----------------------+----------------------+---------+-------+------+-------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+----------------------+----------------------+---------+-------+------+-------+

makandra dev

...using Capybara, functions like click_link or expectations like expect(page).to have_css('.foo') already retry internally. See other card for in depth explanation At makandra we use Spreewald...

DevOps Curriculum

Was ist STDOUT und STDERR? Was ist |? Was ist der Unterschied zwischen echo foo > /tmp/txt und echo foo >> /tmp/txt? Was ist eine ENV Variable und wie kann ich diese...

...with a GET request, even if the requesting method is PATCH or DELETE: def foo redirect_to '/bar', status: :see_other end See Modern HTTP Status codes for redirecting for...

atlassian.com

By file Only commits that introduced changes to a specific file git log -- foo.rb bar.rb Note In case the file was renamed or moved the --follow option can be...

git log --follow -- foo.rb By content If you want to know when a specific line of code was added in the project git log -S"def function_name"

...sets the value to the specified query parameter more Example const params = new URLSearchParams('foo=bar') params.append('baz', 'baq') params.toString() // 'foo=bar&baz=baq' params.delete('baz') params.toString() // 'foo=bar'

params.has('foo') // true params.set('foo', 'baz') params.toString() // 'foo=baz' Working with URLs You can also easily use the URLSearchParams API if you have an URL or an URL...

CONCAT('foo', 'bar', NULL) = NULL the NULL always wins in MySQL. If you would rather treat NULL as an empty string, use CONCAT_WS (concatenation with separator) instead...

...CONCAT_WS('', 'foo', 'bar', NULL) = 'foobar' PostgreSQL In PostgreSQL the NULL is not viral in CONCAT: CONCAT('foo', 'bar', NULL) = 'foobar...

echo "Hello $NAME!" } $ hello # $?=1 bash: 1: provide name as first parameter $ hello Foo # $?=1 Hello Foo! Parameter with default hello() { NAME=${1:-Marvin} echo "Hello $NAME!" }

$ hello Foo # $?=1

it { should allow_value("email@addresse.foo").for(:sender) } it { should_not allow_value("foo").for(:sender) } # Rspec 3 expect syntax it { is_expected.to allow_value("email@addresse.foo").for(:sender) } it { is_expected.not...

...to allow_value("foo").for(:sender) } end Errors that may occur if you do use should validate_format_of(...): NoMethodError: private method `gsub' called for /\A[a-z0-9\-_]+\z...

Typhoeus has a different way of representing array params in a get request than RestClient. Typhoeus: http://example.com/?foo[0]=1&foo[1]=2&foo[2]=3

...If the mocked property is a simple value, it will not work: const x = { foo: 1 } console.log(x.foo) // 1 spyOnProperty(x, 'foo').and.returnValue(2) // Throws: Error: : Property foo does not...

...it can be mocked with Jasmine. You can use it like this: const x = { foo: 1 } console.log(x.foo) // 1 spyOnValueProperty(x, 'foo').and.returnValue(2) expect(x.foo).toBe(2)

github.com

...for sidekiq works as expected and the retries total duration fits. # Example: TestWorker.perform_async('foo', 'bar') class TestWorker include Sidekiq::Worker def perform(*args) raise 'This is a test error...

...to remove blank values from collections (e.g. arrays). Remove nil values from an array ['foo', nil].compact # => ['foo'] # You can use the splat operator to ignore nil values when constructing...

['foo', *nil] # => ['foo'] Remove blank values from collections Array array = [1, "", nil, 2, " ", [], {}, false, true] # Any Rails version array.reject(&:blank?) # => [1, 2, true] # Since Rails 6.1+ array.compact_blank...

thoughtbot.github.io

...share some attributes and traits: FactoryBot.define do factory :user do screen_name 'john' email 'foo@bar.de' trait :with_profile do age 18 description 'lorem ipsum' end end factory :client do

...name 'John Doe' email 'foo@bar.de' trait :with_profile do age 18 description 'lorem ipsum' end end end You can re-use the shared fields by defining a trait outside the...

...Date and Time to that list, but other classes could also make sense. data = {foo: 'bar'}.to_yaml ::YAML.safe_load(data) Psych::DisallowedClass: Tried to load unspecified class: Symbol

...load(data, [Symbol]) => {:foo=>"bar"} Pitfall 2: Psych::BadAlias Psych#dump will create aliases if you reference the same object more than one time. By default this is disabled by...

Check if an object (or its prototype) has a property CoffeeScript var hasFoo = 'foo' of object JavaScript var hasFoo = 'foo' in object; Iterate through all properties of an object...

makandra dev

...you can also render a partial within a helper. #_mobile_navigation.html.haml .mobile_navigation .htmlclass .htmlclass .foo links.each do |link| = link_to(link) module SomeHelper def render_mobile_navigation links = build_links...

def long_message puts(<<-EOT) Here goes a very long message... Sincerely, foobear EOT end <<-EOT will be somewhat of a placeholder: anything you write in the line...

...the example above will be " Here goes a very long message...\n Sincerely,\n foobear\n". Depending on where you use it, this may or may not be a problem...

makandra dev
ruby-doc.org

...When you compare two objects in ruby, you most often see the use of foo == bar. By default the == operator inherits from Object and is implemented as object identity (see...