When you need the DOM node of a tag (e.g. to read extra attributes, or to modify the DOM near it), you can usually reference it via document.currentScript. However, document.currentScript is unsupported in ancient browsers, like Internet Explorer 11 or wkhtmltopdf's Webkit engine. If you are not running async scripts, you can easily polyfill it: document.scripts[document.scripts.length - 1] It works because document.scripts grows with each tag that was evaluated. That is also the reason why this solution will not work reliably for async code. Demo: https://codepen.io/foobear/pen/poRLxQm
...values for the current scope, similar to # ActiveRecord's `ids` method. For performance, we read id and type # directly from the database and create GIDs from them. # Note that we...
There are several gems that make it easy to read and process xlsx files. Parsing the entire file at once however is error-prone since each cell is transformed to...
...Creek since a badly formatted 12MB Sheet broke the 500MB Staging Memory limit when reading it as a whole. The implementation follows the Creek's documentation: document = Creek::Book.new('/path/to/file.xlsx...
In discussions many developers argue that REST APIs are easier for developers to read if they are completely documented. Even if GraphQL APIs are always completely documented in the...
...to access Paperclip storage objects (like this: File.read(file.to_file.path)) you can use Paperclip.io_adapters.for(file).read
Font Awesome 5 is a comprehensive solution for vector icons on your website. Originally, Font Awesome came as an icon...
PostgreSQL and ActiveRecord have a good support for storing dynamic attributes (hashes) in columns of type JSONB. But sometimes you...
...in the context menu to open RubyMine's merge conflict tool. Left pane: local copy (read-only) Right pane: checked in version from repository (read-only) Central pane: base revision...
...actually more powerful. When setting cookies this way, remember to set the path=/ option. Reading cookies A result may look like this: hello=universe; foo=bar This means that there...
It is actually just a String without any magic powers. In order to read a cookie's value, you need to parse the string: document.cookie.match(/hello=([^;]+)/)[1] // => "universe"
There is a bit more to all that, so I suggest you read the attached article by @tenderlove. I could confirm his observations on Ruby 2.2 and 2.3, too...
...can be misleading when combined with a location like "Munich". So you could just read TimeWithZone#zone, right? >> '2019-03-28 16:00'.in_time_zone('Berlin').zone => "CET"
ImageMagick has a command line tool called identify which can read image metadata: >identify -verbose DSC00136.JPG Image: DSC00136.JPG Format: JPEG (Joint Photographic Experts Group JFIF format) Class: DirectClass Geometry: 5472x3648...
...of 28cm × 21cm and landscape orientation in the advanced options of FreePDF (not Adobe Reader, can be accessed from Reader's print dialog). Note that all your colors will be...
...fix this, choose "Let printer determine colors" in the advanced print options of Adobe Reader (not FreePDF). Note that reprinting the PDF will recompress all the images that were already...
...that returns whatever you need. You can reference other GTM variables with {{ }}. You can read cookies with a "1st Party Cookie" variable Triggers "Click - All Elements" triggers are handy when...
...Remove all old config.gem...
...lines in environment.rb and environments/*.rb Run bundle install. This reads Gemfile and builds Gemfile.lock with all dependencies etc. If you see "Missing the Rails...
...can be helpful in many cases, but the cassette yml is not easy to read. Follow these steps to make a recorded VCR request more human readable: Search the cassette...
How to fix it Since you can't really expect outside code (read: Gems) to not use $1 (and there is plenty, believe me) when calling gsub on...
...is a rather accessible XML API for interacting with Exchange. This allows you to read and send e-mails, create appointments, invite meeting attendees, track responses, manage to-do tasks...
Sometimes, you may want to open up a second database connection, to a read slave or another database. When doing that, you must make sure you don't overwrite an...
...other ActiveRecord classes. Instead, use a class to "proxy" your connection, like this: class ReadDatabaseConnection < ActiveRecord::Base def self.abstract_class? true # So it gets its own connection end end ReadDatabaseConnection.establish...
...having 100% loss rate does not necessarily mean that there is trouble. You should read about how traceroute works to get an idea how to interpret it...
...your Hash to and from JSON, and you can index JSON paths for fast reads. As an alternative, ActiveRecord::Store offers a way to store hashes in a single database...
...your images. Here is a quick summary of them, if you need more details read the docs. You can also use all command line options from RMagick directly if these...
white for jpeg). Side note about MiniMagick and RMagick from the Carrierwave README: MiniMagick is similar to RMagick but performs all the operations using the 'mogrify' command which...
...of the file hasn’t changed. Without a % sign, the number is to be read as a fraction, with a decimal point before it. I.e., -M5 becomes 0.5, and is...
This string array tag_list is magical in several ways: It is read from and written to a has_many association It can be manipulated in forms using...
...with its underlying association: class Note < ActiveRecord::Base include DoesListField[:topic_list] private def read_topic_list topics.collect(&:name) end def write_topic_list(list) topics.delete_all for name in...