makandra dev

...of control”. A function that accepts a callback instead of a return value is saying, “Don’t call me, I’ll call you.”. Promises un-invert the inversion, cleanly separating...

...the input arguments from control flow arguments. This simplifies the use and creation of APIs, particularly variadic, REST and spread arguments. Note that promises are not a drop-in replacement...

Ruby's regular expressions can be represented differently. When serializing them, you probably want to use inspect instead of to_s. For the examples below, consider the following Regexp object...

>> regexp.to_s => "(?mi-x:^f(o+)!)" inspect As the Ruby docs say: Perhaps surprisingly, #inspect actually produces the more natural version of the string than #to_s...

makandra dev

...IDENTIFIED BY 'some_password'; GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%'; Adjust MySQL configuration : Edit /etc/mysql/my.cnf: server-id = 1 log_bin = /var/log/mysql/mysql-bin.log replicate-do-db = some_project_production replicate-do-db...

...other_project_production replicate-ignore-db = mysql server-id needs to be unique among all connected master and slave servers. When replicate-do-db is provided only the chosen databases...

...inputs, where one contains the name of the other (eg. Name and Name with special treatment), Capybara's fill_in method will fail with the following message: Ambiguous match, found...

...value = 'Bettertest Cucumberbatch' fill_in(field, with: value, match: :prefer_exact) Furthermore, we recommend setting Capybara's matching strategy globally to :prefer_exact. This will positively affect all you steps...

makandra dev

Field error steps Spreewald's The...

...field should have an error and The...

...field should have the error...

...steps now have built-in support for Rails and Bootstrap (v3-v5...

...error classes. When using Bootstrap, it is no longer necessary to overwrite the steps in your project. At the same time, support for formtastic has been removed as there were...

jetbrains.com

In RubyMine folders can be excluded from search, navigation etc. by marking it as excluded. You might sometimes wish to exclude single files, too. An example could be .byebug_history...

...which is located in the project root directory. Single files can be excluded by pattern in the Settings: In the Settings/Preferences dialog Ctrl+Alt+S, go to Project structure

So I had the issue that User input (coming from many different sources and users) often contains the same long word. Maybe that's a super german thing...

...compiler that crawls the document and replaces all occurencies of certain word and puts a soft-hyphen (­, or \xAD) where i want the word to break. This is only...

# the value from the form field's ngModel (which means it's not sent to the # server, and old values would not be overwritten). # # This directive makes sure that...

...form fields with an invalid value return an # empty string instead of undefined. for elementType in ['input', 'textarea', 'select'] @app.directive elementType, -> priority: 1 restrict: 'E' require: '?ngModel' link: (scope, element...

On application servers, gems are usually bundled into the project directory, at a location shared across deployments. This is usually shared/bundle inside your project's root directory, e.g. /var/www/your-project/shared/bundle/.

When you are changing the version of RubyGems or Bundler on a system where gems are installed this way, you must wipe that bundle directory in addition to...

When using threads, you must make your code thread-safe. This can be done by either locking (mutexes) all data shared between threads, or by only using immutable data structures...

...Ruby core classes like String or Array are not immutable. There are several gems providing thread-safe collection classes in Ruby. concurrent-ruby The concurrent-ruby gem provides thread-safe...

...unwrap(). Here is how. Consider the following example element. $container = $(' Hello World ') Let's say we want to discard any tags, but keep their contents. Simply find them, then dive...

When using state_machine you sometimes need to know whether an object may execute a certain transition. Let's take an arbitrary object such as a blog article as an...

...example that has those states: A -> B -> C -> D Additionally, you have transitions between the states as shown above. Let's call the transition between 'A' and 'B' transition_ab...

github.com

When using Sidekiq in your application, you must write thread-safe code. This wiki page also lists gems that are known to be unsafe on threaded applications.

...gem that will also be used by a Sidekiq worker, make sure to confirm it's thread-safe...

Note: Making a reverse proxy with nginx is much more straightforward. A reverse proxy is a "man in the middle" server that tunnels requests to another server. You can use...

...makes sure that it can fetch from HTTPS internally. You've basically built your custom SSL-stripping MITM attack server. If your proxy server should be accessible over HTTPS, use...

RSpec's let allows you to super into "outside" definitions, in parent contexts. Example: describe '#save' do subject { described_class.new(attributes) } let(:attributes) { title: 'Example', user: create(:user) } it 'saves' do...

...expect(subject.save).to eq(true) end context 'when trying to set a disallowed title' do let(:attributes) { super().merge(title: 'Hello') } # <== it 'will not save' do expect(subject.save).to eq...

This is how you regain disk space from OpenStack instances if you are using kvm and qcow. If your instance used up all configured disk space once the disk file...

...remains big. You can end up in a situation where for example the instance use only 20GB disk space but the disk file on the server has 100GB (or even...

Haml 3.1.2 displays single quotes in FormBuilder#text_ field html escaped. You may see something like that: David&#x27;s Chapter Looking at the page's HTML, your field's...

makandra dev
litmus.com

...all for laying out your HTML emails. Email client HTML rendering is way more scattered than browser HTML. While you might have a pretty good understanding of what features and...

...patterns you can use to support all major browsers, I doubt anyone masters this craft for HTML email clients. The only way to ensure your email looks good (acceptable, at...

github.com

...Request, visit /__better_errors on your app's root path (e.g. http://localhost:3000/__better_errors). It shows the error page for the last exception that occurred, even when it has been triggered...

To read the Rails session from a Rack middleware, use env['rack.session']. It's an ActionDispatch::Request::Session object. class MyMiddlware def initialize(app) @app = app end def call(env...

...status, headers, body = @app.call(env) session = env['rack.session'] Rails.logger.info("Value of session['foo'] is: " + session['foo'].inspect) [status, headers, body] end end You may not be able to write to...

Our old solution for cronjobs, the "craken" plugin, is no longer maintained and does not work on Rails 3.2+. We will instead use the whenever gem. "Whenever" works just like...

...craken", by putting your rake tasks into the server's cron table. Everything seems to work just like we need it. Installation for new projects Add "whenever" to your Gemfile...

WProofreader is a spelling and grammar checking tool that integrates with textareas and numerous WYSIWYG editors. While it usually activates automatically, depending on your application, it may fail to boot...

...do that ourselves, so we disable it autoDestroy: true, lang: 'de_DE', serviceId: '...', // ... } Ensure https://svc.webspellchecker.net/spellcheck31/wscbundle/wscbundle.js is loaded as described in the docs. To activate WProofreader, you can now...

Deadlocks only occur if two transactions in separate threads compete for the same rows in the database. They usually (but not necessarily) only happen when trying to update or otherwise...

...lock several rows in different order. Solving deadlocks is potentially complicated, so here are a few pointers: MySQL should always detect the deadlock right when it happens, and will throw...

...the kind of query). It may help to understand youtube's domain model before starting. It's best to just try out your requests in the browser to see what...

...key in order to make this request work): https://www.googleapis.com/youtube/v3/playlistItems?playlistId= &key= A&part=snippet&fields=nextPageToken,items(snippet(publishedAt,resourceId(videoId))) There are more examples and explanations in the...