Tutorial by Examples: ai

RVM is a great tool to manage your ruby versions and set up your working environment. Assuming you already have RVM installed, to get the latest version of ruby, which is needed for these examples, open a terminal and run: $ rvm get stable $ rvm install ruby --latest Check your ruby version by...
In cases such as restoring a database dump, or otherwise wishing to push some information through a pipe from the host, you can use the -i flag as an argument to docker run or docker exec. E.g., assuming you want to put to a containerized mariadb client a database dump that you have on the host, in...
NSString *someString = @" Objective-C Language \n"; NSString *trimmedString = [someString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //Output will be - "Objective-C Language" Method stringByTrimmingCharactersInSet returns a new str...
This code makes sure that all nested containers are always the same height. This is done by assuring that all nested elements are the same height as the containing parrent div. See working example: https://jsfiddle.net/3wwh7ewp/ This effect is achieved due to the property align-items being set to...
3.0 let someString = " Swift Language \n" let trimmedString = someString.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) // "Swift Language" Method stringByTrimmingCharactersInSet returns a new string made by removing from both ends of t...
A common problem is having a collection of items that all need to meet a certain criteria. In the example below we have collected two items for a diet plan and we want to check that the diet doesn't contain any unhealthy food. // First we create a collection $diet = collect([ ['name' => ...
You will often find yourself with a collection of data where you are only interested in parts of the data. In the example below we got a list of participants at an event and we want to provide a the tour guide with a simple list of names. // First we collect the participants $participants = colle...
When adding content from sources outside your domain, or from the local file system the canvas is marked as tainted. Attempt to access the pixel data, or convert to a dataURL will throw a security error. vr image = new Image(); image.src = "file://myLocalImage.png"; image.onload = funct...
XML <Data> <BioLight> <name>Firefly</name> <model>Insect</model> </BioLight> <ArtificialLight> <name>Fire</name> <model>Natural element</model> <source>flint<...
If we try to change an object on the UI thread from a different thread we will get a cross-thread operation exception: Private Sub Button_Click(sender As Object, e As EventArgs) Handles MyButton.Click ' Cross thread-operation exception as the assignment is executed on a different thread '...
Custom events usually need custom event arguments containing information about the event. For example MouseEventArgs which is used by mouse events like MouseDown or MouseUp events, contains information about Location or Buttons which used to generate the event. When creating new events, to create a...
Be careful, this approach might be considered as a bad design for angular apps, since it requires programmers to remember both where functions are placed in the scope tree, and to be aware of scope inheritance. In many cases it would be preferred to inject a service (Angular practice - using scope ...
It is possible to save a Docker container's filesystem contents to a tarball archive file. This is useful in a pinch for moving container filesystems to different hosts, for example if a database container has important changes and it isn't otherwise possible to replicate those changes elsewhere. Pl...
This function returns the floating-point remainder of the division of x/y. The returned value has the same sign as x. #include <math.h> /* for fmod() */ #include <stdio.h> /* for printf() */ int main(void) { double x = 10.0; double y = 5.1; double modulus = fmod(x,...
If you have both Python 3 and Python 2 installed, you can specify which version of Python you would like pip to use. This is useful when packages only support Python 2 or 3 or when you wish to test with both. If you want to install packages for Python 2, run either: pip install [package] or: p...
This example assumes that you have experience in creating Rails applications. To create an API-only app in Rails 5, run rails new name-of-app --api Add active_model_serializers in Gemfile gem 'active_model_serializers' install bundle in terminal bundle install Set the ActiveModelSeriali...
Installing Rails on Ubuntu On a clean ubuntu, installation of Rails should be straight forward Upgrading ubuntu packages sudo apt-get update sudo apt-get upgrade Install Ruby and Rails dependecies sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyam...
(defun fn (x) (cond (test-condition the-value) (t (fn reduced-argument-x))))
PHP only allows single inheritance. In other words, a class can only extend one other class. But what if you need to include something that doesn't belong in the parent class? Prior to PHP 5.4 you would have to get creative, but in 5.4 Traits were introduced. Traits allow you to basically "copy...
MAINTAINER <name> The MAINTAINER instruction allows you to set the Author field of the generated images. DO NOT USE THE MAINTAINER DIRECTIVE According to Official Docker Documentation the MAINTAINER instruction is deprecated. Instead, one should use the LABEL instruction to define the aut...

Page 14 of 47