Why Rails has multiple schema formats When you run migrations, Rails will write your current database schema into db/schema.rb. This...

dev.to

...possible products, categories and vendors and it is updated once a month. When you read this file with the Nokogiri default (DOM) parser, it creates a tree structure with all...

...easily navigate through it via css/xpath selectors. The only problem is that if you read the whole file into memory, it takes a significant amount of RAM. It is really...

config.file_fixture_path = "spec/custom_directory" end Alternatives: Rails.root.join('spec/fixtures/files/avatar.jpg').open('r') Rails.root.join('spec/fixtures/files/avatar.jpg').read File.open('spec/fixtures/files/avatar.jpg') (might only work if you run the command from the Rails root directory...

...binary string which we can use to create a file binary_string = binary_data_array.pack('C*') Read the docs for more information about packing data in ruby Caveats make sure you can...

...inside the gem. ActiveScaffold provides a quick and powerful user interfaces for CRUD (create, read, update, delete) operations for Rails applications. It offers additonal features including searching, pagination & layout control...

...run into the limits of our previous approaches (e.g. ChoiceTrait cannot be internationalized). Please read the assignable_values README to familiarize yourself with the new solution. Also see our instructions...

regular-expressions.info

...will match This test. possessive: specified by adding a plus sign to the qualifier. Reads like "greedy without backtracking" – *+ and ++ try to match everything but immediately return if it doesn...

...s logger utility, it is often useful to sync them. So other process can read the output just in time. Example with enabled sync log_path = '/tmp/some_log.log' log_file = File.open...

I used two lab days to read the The framework field guide - Fundamentals, the first of a three part series to learn the basics of frontend technologies. I can highly...

makandra dev

...OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 Re-read permissions When you're done making the above changes, we need to re-read mysql...

If you ever need to restore exact records from one database to another, Marshal might come in handy. Marshal.dump is...

...you usually use is probably a bit too small and makes code hard to read for users on smaller screens or low-bandwidth connections when the image quality is lower...

linux.die.net

Reading a URL via GET: curl http://example.com/ Defining any HTTP method (like POST or PUT): curl http://example.com/users/1 -XPUT Sending data with a request: curl http://example.com/users...

...password@example.com/users/1 -XPUT -d"screen_name=batman" Check the man page for more features. Read more You can also use Cookies with cURL. For easily making HTTP requests in an...

makandra dev

...Version 4.6 introduces deprecation warning for Redis.current, which will be removed altogether in 5.0. Read this card for ways to deal with this. Now we can determine the correct REDIS...

island94.org

config.secret_key_base = config.secrets.secret_key_base def secrets config.secrets end config_for reads from config/secrets.yml. It expects config to be nested by environment. def secrets defines that method...

...true } to activate this behavior. Note that since this executes a function on every read, this is slower than a dumb property. Full example Full example from the docs:

# config/deploy/production.rb (analog to config/deploy/staging.rb) ... server ' ', user: ' ', roles: %w(... webpack) Make sure to read as well: Webpack(er): Serving identical assets from all servers. Capistrano: Speeding up asset compile...

...the two linked files, dummy_ok.pdf and dummy_fail.pdf. Both are valid PDF files, your PDF Reader will be able to open them and they seem to be the same. But if...

...fool the binary? method. But how can we check if a file is entirely readable with our preferred encoding (We'll use the default UTF-8)? The following method tries...

You can use this Code Pen to play around with the different options. Read Inspect Grid to check for full details. Discover The Layouts Pane to inspect

...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...

gist.github.com

The NestedHash class allows you to read and write hashes of any depth. Examples: hash = {} NestedHash.write hash, 'a', 'b', 'c', 'value' # => { a: { b: { c: 'value' } } } NestedHash.read hash, 'a', 'b', 'c...

...b: { c: 'value' } } NestedHash.read hash, 'foo', 'bar' # => undefined Inspired by victusfate. Code class @NestedHash @read: (objekt, keys...) -> if objekt and keys.length @read objekt[keys[0]], keys[1...]... else objekt

...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...

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...