...s possible you get this "error" message: *** [err :: example.com] There are no Phusion Passenger-served applications running whose paths begin with '/var/www/example.com'. *** [err :: example.com] This is just because there were...

...no running passenger process for this application on the server which could be restarted. It's not a real error. The application process will start if the first request for...

makandra Curriculum

Goals After finishing this lesson you should be able to read and write simple Ruby programs. Gain an understanding of the following concepts: Working with basic datatypes: String, Integer...

Classes and inheritance The difference between class methods and instance methods (def self.method vs. def method) Modules and include Code blocks ("procs", "lambdas") Input and output Simple regular...

This RailsCast demonstrated a very convenient method to activate VCR for a spec by simply tagging it with :vcr. For RSpec3 the code looks almost the same with a few...

...minor changes. If you have the vcr and webmock gems installed, simply include: # spec/support/vcr.rb VCR.configure do |c| c.cassette_library_dir = Rails.root.join("spec", "vcr") c.hook_into :webmock end RSpec.configure do |c...

Normally, Rails handles encryption and signing of cookies, and you don't have to deal with the matter. Should you need to decrypt a session cookie manually: here is how...

...Obviously, you can only decrypt a session cookie from within the corresponding Rails application. Only the Rails application that encrypted a cookie has the secrets to decrypt it.

makandra Curriculum

Understand how nested attributes appear in the params. See how the Rails form helpers encode the names of nested inputs. Understand how the record and all of its nested...

...attributes are saved in a transaction. That means the entire structure is saved or not. Resources Rails Guide: Nested forms Nested Forms in Rails Popular mistakes when using nested forms...

...good UI design, you should always be able to come up with a default. Since the user interface makes up 70% of a typical web application, this is closely related...

...and a "user" are both human beings, it's rarely practical to have them share a model or inheritance hierarchy. Try to model everything as CRUD (regardless of whether a...

...driver_opts directly. However, this is deprecated and will be removed in version 4 of selenium-webdriver. Version 5.x will drop support for passing the service options as hash...

...Option 2: Connect tests to a manually started chromedriver Warning This does not work with selenium-webdriver > 4 anymore. You can pass in a specific port as attribute of the...

Option 0: Download from the official page (preferred) Open https://googlechromelabs.github.io/chrome-for-testing/ In Section "Stable" > chromedriver / linux64 > Download ZIP from URL Take the chromedriver binary from the ZIP file and...

...your path like this: echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile Option 2: Use apt source Warning Wo no longer recommend this option. After a chrome update, the chromedriver package sometimes...

makandra Operations

...is great when dealing with JSON data. Check out the official jq Manual. Content Select only specific keys Modify keys Set default value Filter by key name Delete specific keys...

...Overwrite/add nested key value Select only specific keys Command jq '.[] | { Name, OriginString }' Input [ { "Id": 1, "Name": "foobar.net", "OriginString": "/FOOBAR/foobar.net" }, { "Id": 2, "Name": "barfoo.baz", "OriginString": "/FOOBAR/barfoo.baz" } ] Output { "Name": "foobar.net", "OriginString": "/FOOBAR/foobar.net...

makandra dev

Ever wondered how you can create a simple table output in bash? You can use the tool column for creating a simple table output. Column gives you the possibility to...

...same level. Pipe output to column -t (maybe configure the delimeter with -s) and see the magic happening. detailed example I needed to separate a list of databases and their...

We're always striving towards keeping our website's JavaScript as small as possible. If you're using webpack(er), you can use the webpack-bundle-analyzer plugin to get...

...a good overview, which of your JavaScript modules take up how much space, and where you can optimize. To use it, add it via npm or yarn yarn add webpack...

...on a very good network connection. To test how your application behaves on a slow network (e.g. mobile), you can simulate limited bandwidth. Chrome Open the dev tools (Ctrl+Shift...

...I or F12) and switch to the "Network" tab In the row below the dev tool tabs, there's a throttling dropdown which reads "Online" by default. Inside the dropdown...

The recommended way is to define a method on your module's singleton class: module SomeTrait as_trait do define_singleton_method :foo do # ... end end end

...def (has caveats!) Alternatively, you can def the method on self: module SomeTrait as_trait do def self.foo # ... end end end This is quite concise and results in faster methods...

In MovieDB, add a new field “Principal filming location”. In a movie’s show view, geocode that location and show a Google map centered around it

...E2E feature that tests that the map shows the correct location. Hints The purpose of this lesson to learn interacting with external APIs from JavaScript. Even though this exercise can...

makandra dev

...text right next to the code: notes for other developers, and for your future self. You can imagine comments as post-its (or sometimes multi-sheet letters ...) on real-world...

...objects like cupboards, light switches etc. As always, with power comes responsibility. Code comments can go wrong in many ways: they may become outdated, silently move away from the code...

...not necessary to add a version constraint next to your packages in the package.json. Since all versions are saved in a lockfile, everyone running yarn install will get exactly the...

...within the yarn install command: Before: unpoly@^2.7.2: version "2.7.2" resolved "https://registry.yarnpkg.com/unpoly/-/unpoly-2.7.2.tgz#55044c08bce0984c000f7cd32450af39271727de" integrity sha512-jfBbBRBQMCZZcNS6fckKpFunfdiTDBXW8yxRKqLs09jSrYYUDPd+YuyDoXjABXOro0aDUIMcmyTc7moc1/Z5Tw== After: unpoly@x: version "2.7.2" resolved "https://registry.yarnpkg.com/unpoly/-/unpoly-2.7.2.tgz#55044c08bce0984c000f7cd32450af39271727de" integrity sha512-jfBbBRBQMCZZcNS6fckKpFunfdiTDBXW8yxRKqLs09jSrYYUDPd...

makandra dev

If you want to play music or sounds from a browser, your choice is to use either Flash or the new tag in HTML5. Each method has issues, but depending...

Can play MP3s or Wave files. Cannot play OGG Vorbis audio. Cannot reliably seek to a given position when playing VBR-encoded MP3s. HTML5 audio Is the future, but...

...loading associations. By preloading associations you can prevent the n+1 query problem that slows down a many index view. You might have noticed that using :include randomly seems to...

...involved table with a condition like...

...WHERE id IN (123, 125, 170). Execute a single query for a huge table joined from all involved tables. ActiveRecord prefers option 1, probably...

caniuse.com

All major browsers (IE8+, FF3.5+, Safari 4+, any Chrome) support sessionStorage, a JavaScript storage object that survives page reloads and browser restores, but is different per new tab/window (in contrast...

...to localStorage which is shared across all tabs). MDN says: The sessionStorage object is most useful for hanging on to temporary data that should be saved and restored if the...

...hints on best practices to maintain your tasks in larger projects. Rake Tasks vs. Scripts The Rails default is using rake tasks for your application tasks. These live in lib/tasks...

...case you want to avoid rake for your tasks and just use plain ruby scripts, consider lib/scripts/* as folder. Keeping tasks slim For readability and testing it's easier to...

TL;DR: Rails ships two methods to convert strings to constants, constantize and safe_constantize. Neither is safe for untrusted user input. Before you call either method you must validate...

...the input string against an allowlist. The only difference between the two methods is that unresolvable constants raise an error with constantize, but return nil with safe_constantize. If you...

...to the public (as it should be!), here's how to open a psql shell inside Kubernetes and connect to the database. Make sure to replace the variables appropriately.

...run postgresql-client \ --image=postgres \ --namespace=$NAMESPACE \ --stdin=true --tty=true \ --rm=true \ --env="PGPASSWORD=$PASSWORD_FOR_POSTGRES \ --command -- \ psql --host=$HOSTNAME_FOR_POSTGRES --username=$USERNAME_FOR_POSTGRES $DATABASE_FOR...

makandra dev

...to add some custom functionality. This card contains some tips how to achieve this. Setup Basically, follow the guide in the Rails documentation. The automated script may not work with...

...it should be easy to fix. If you don't want the default css shipped with Action Text, you can copy the stylesheet from basecamp's github into your project...

...Chrome to check if the problem disappears. Keep in mind though that running outdated software, especially web browsers, is in most cases not a good idea. Please verify periodically if...

...you still need to run the old version or if an even more recently updated version fixes the problems introduced in your version. Here's how to get old versions...