...A word of advice Note that this does not necessarily increase your test's readability. If you have a very long test, you obviously do not want to duplicate it...

...sweet spot between duplication and over-engineering (and thus making the test impossible to read). An alternative is also to hide that functionality behind other steps that do more complex...

...parse it in chunks, otherwise it will need lots of memory. Nokogiri offers a reader that lets you parse your XML one node at a time. Given an XML library.xml...

def each_book(filename, &block) File.open(filename) do |file| Nokogiri::XML::Reader.from_io(file).each do |node| if node.name == 'book' and node.node_type == XML::Reader::TYPE_ELEMENT...

Elasticsearch defaults to go into readonly mode when you run low on disk space (< 95%). You might then see an error like this when you try to write to elastic...

...Transport::Errors::Forbidden: [403] {"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only...

Individual transform properties are great because they allow you to write more readable and maintainable CSS, especially when applying multiple transformations and/or when animating transforms.

...should be on 20 or 21, so you can use these in production now. Read on for details and edge cases. Readable and maintainable CSS Without individual transform properties, modifying...

CSS is a lot easier to write and read than clumsy XPath expressions. So when you need to use XPath, you can have Nokogiri help you out on creating it...

Not all email clients support external images in all situations, e.g. an image within a link. In some cases, a...

Building application assets with esbuild is the new way to do it, and it's great, especially in combination with...

In case Ruby does not detected the expected encoding of a file automatically you can specify the known encoding manually...

makandra dev

Here is a full-fledged example: describe Lock, '.acquire' do before :each do @reader, @writer = IO.pipe end def fork_with_new_connection config = ActiveRecord::Base.remove_connection fork do

...the same lock' do (1..20).each do |i| fork_with_new_connection do @reader.close ActiveRecord::Base.connection.reconnect! Lock.acquire('lock') do @writer.puts "Started: #{i}" sleep 0.01 @writer.puts "Finished: #{i}" end @writer.close...

Old structure: /attachments/123456789/ /file.pdf New structure: /attachments/123/456/789/ /file.pdf Be sure to also read our card on migrating from Paperclip to Carrierwave, especially the list of possible errors that...

...collection to be a somewhat grouped collection (array of arrays, hash, ...) that it can read from. In "the real world" you usually already have your list of items to select...

...this only works if you are grouping by something that should be the human-readable optgroup label which is almost always the case...

makandra dev

...result in data loss! Stop your database via the MySQL shell: FLUSH TABLES WITH READ LOCK; Do not close the shell as this would remove the read lock we just...

...in a new terminal): mysqldump -uroot -p -r the_dump.sql some_project_production Remove the read lock (from the MySQL shell): UNLOCK TABLES; The master server will now resume operations. New...

makandra dev
iamvdo.me

...value 1, but the default is normal. OK, but what normal is? We often read that it is (or should be) 1, or maybe 1.2, even the CSS spec is...

...result into ps2eps. cat input.svg | cairosvg -f ps - | ps2eps -q > output.eps ps2eps by default reads from stdin and writes to stdout. You can either capture that output in your own...

...in parallel tests manually, you normally need to handle these issues: When multiple processes read and write to a directory with the same name e.g. tmp/some-test-folder you might end up...

...like "#{Rails.env}#{ENV['TEST_ENV_NUMBER']}" in you directory path when using Dir.mkdir. Further reading: If a single temporary file is enough for you, use Tempfile.new

makandra dev

...feature without the -i flag, but until now it seems not to be possible. Read more about our recommended git workflow for feature branches. Also have a look at git...

makandra dev

...to rebase onto' | awk '{print $1}') test_command="git rebase -i --onto $branch $commit~" read -p "Execute command '$test_command' (Y/n)? " choice case "$choice" in n|N ) echo "aborted.";;

...are some implementation details you might want to reuse: Use the existing models to read the files from Use your own carrierwave models to write the files to the new...

makandra dev
content-security-policy.com

...Does not affect CSS or Images img-src and style-src directives still apply. Read further A good default CSP can be found at Strict CSP...

config.active_record.schema_format = :sql This will make a db/development_structure.sql appear which is then also read and loaded when you do a db:test:prepare. rake db:test:clone

...the schema.rb for you) -- but you may run into problems. The task's description reads: rake db:test:clone # Recreate the test database from the current environment's database schema...

...it replaces the legacy switches --no-rdoc --no-ri. Its abbreviated version is -N.) Read the RubyGems command reference for more information...

...delegators and def_delegator is a complete mess that makes your code hard to read. Consider these classes: class Topic < ActiveRecord::Base def title "A title" end def category

def_delegators :topic, :title, :category end Here, we can say Post.new.title and actually read title from the Post's Topic object. Because of what we defined for Post, this...

...Luckily, we can use PostgreSQL's window functions to speed things up. You can read more about window functions here, but for our purposes, know that the following SQL does...

This is not very flexible, and failure messages will be hard to read. Instead, consider doing this: SomeApi.should_receive(:find) do |params| params[:query].should == '*foo*' params[:sort...