Tutorial by Examples: v

Inventory is the Ansible way to track all the systems in your infrastructure. Here is a simple static inventory file containing a single system and the login credentials for Ansible. [targethost] 192.168.1.1 ansible_user=mrtuovinen ansible_ssh_pass=PassW0rd Write these lines for example to host...
Here's how you can destructure a vector: (def my-vec [1 2 3]) Then, for example within a let block, you can extract values from the vector very succinctly as follows: (let [[x y] my-vec] (println "first element:" x ", second element: " y)) ;; first element: 1 , second ele...
If the mimetype of the HTTP request is application/json, calling request.get_json() will return the parsed JSON data (otherwise it returns None) from flask import Flask, jsonify app = Flask(__name__) @app.route('/api/echo-json', methods=['GET', 'POST', 'DELETE', 'PUT']) ...
Python minimally evaluates Boolean expressions. >>> def true_func(): ... print("true_func()") ... return True ... >>> def false_func(): ... print("false_func()") ... return False ... >>> true_func() or false_func() true_func(...
public void iterateAndFilter() throws IOException { Path dir = Paths.get("C:/foo/bar"); PathMatcher imageFileMatcher = FileSystems.getDefault().getPathMatcher( "regex:.*(?i:jpg|jpeg|png|gif|bmp|jpe|jfif)"); try (Direc...
Add gem to the Gemfile: gem 'devise' Then run the bundle install command. Use command $ rails generate devise:install to generate required configuration file. Set up the default URL options for the Devise mailer in each environment In development environment add this line: config.action_mailer...
Boolean(0) === false Boolean(0) will convert the number 0 into a boolean false. A shorter, but less clear, form: !!0 === false
To convert a string to boolean use Boolean(myString) or the shorter but less clear form !!myString All strings except the empty string (of length zero) are evaluated to true as booleans. Boolean('') === false // is true Boolean("") === false // is true Boolean('0') === fals...
Iterating over List List<String> names = new ArrayList<>(Arrays.asList("Clementine", "Duran", "Mike")); Java SE 8 names.forEach(System.out::println); If we need parallelism use names.parallelStream().forEach(System.out::println); Java SE 5 fo...
When a controller action is rendered, Rails will attempt to find a matching layout and view based on the name of the controller. Views and layouts are placed in the app/views directory. Given a request to the PeopleController#index action, Rails will search for: the layout called people in app/...
Assuming the route: resources :users, only: [:index] And the controller: class UsersController < ApplicationController def index respond_to do |format| format.html { render } end end end The view app/users/index.html.erb will be rendered. If the view is: Hello &lt...
git config --global merge.conflictstyle diff3 Sets the diff3 style as default: instead of the usual format in conflicted sections, showing the two files: <<<<<<< HEAD left ======= right >>>>>>> master it will include an additional section containi...
The following query returns the database options and metadata: select * from sys.databases WHERE name = 'MyDatabaseName';
parseFloat accepts a string as an argument which it converts to a float/ parseFloat("10.01") // = 10.01
You can also use loop with curly brackets like this: if ( have_posts() ) { while ( have_posts() ) { the_post(); var_dump( $post ); } }
Redis is an in-memory remote database that offers high performance, replication, and a unique data model to produce a platform for solving problems. Redis is an open source (BSD licensed), in-memory data structure , used as database, cache and message broker. It is categorized as a NoSQL key-value s...
To set up a controller with user authentication using devise, add this before_action: (assuming your devise model is 'User'): before_action :authenticate_user! To verify if a user is signed in, use the following helper: user_signed_in? For the current signed-in user, use this helper: current_us...
There is also a way to have a single method accept a covariant argument, instead of having the whole trait covariant. This may be necessary because you would like to use T in a contravariant position, but still have it covariant. trait LocalVariance[T]{ /// ??? throws a NotImplementedError de...
Omitting the return statement in a function which is has a return type that is not void is undefined behavior. int function() { // Missing return statement } int main() { function(); //Undefined Behavior } Most modern day compilers emit a warning at compile time for this kind o...
If no ordering function is passed, std::sort will order the elements by calling operator< on pairs of elements, which must return a type contextually convertible to bool (or just bool). Basic types (integers, floats, pointers etc) have already build in comparison operators. We can overload this ...

Page 45 of 296