file.write open('http://example.com/your.file', :http_basic_authentication => [your_username, your_password]).read
...it with two niceties: support for passing a block (which could e.g. render a "read on" link), and html_safe knowledge. Prefer the truncate() helper Warning: truncate() calls html_safe...
...conditions => ['state = ?', 'draft']) or a hash (:conditions => { 'state' => 'draft' }). The later is nicer to read, but has horrible security implications in some versions of Ruby on Rails. Affected versions
...to access Paperclip storage objects (like this: File.read(file.to_file.path)) you can use Paperclip.io_adapters.for(file).read
...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...
...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.
...htpasswd -v htpass_test firstname.lastname You probably should not use the -b switch to read the password from the command line as the password will then be visible in your...
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...
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...
...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...
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...
Font Awesome 5 is a comprehensive solution for vector icons on your website. Originally, Font Awesome came as an icon...
...might leak memory: @app.directive 'awesomeMap', -> link: (scope, element, attributes) -> AwesomeMap.init(element) To prevent leaks, read the plugin's documentation for a way to destroy the plugin instance when you're...
...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...
PostgreSQL and ActiveRecord have a good support for storing dynamic attributes (hashes) in columns of type JSONB. But sometimes you...
...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...
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...