Tutorial by Examples: c

In order to record audio from a user's microphone, we must first gain permission from the user to access the device: navigator.mediaDevices.getUserMedia({ audio: true }) .then(successCallback) .catch(failureCallback); On success, our successCallback will be called with a MediaStream ob...
Predicates that impede or prohibit a declarative reading of Prolog programs are extra-logical. Examples of such predicates are: !/0 (->)/2 and if-then-else (\+)/1 These predicates can only be understood procedurally, by taking into account the actual control flow of the interpreter, and a...
The keyword auto provides the auto-deduction of type of a variable. It is especially convenient when dealing with long type names: std::map< std::string, std::shared_ptr< Widget > > table; // C++98 std::map< std::string, std::shared_ptr< Widget > >::iterator i = table.fin...
Unification is a pure relation. It does not produce side effects and can be used in all directions, with either or both arguments fully or only partially instantiated. In Prolog, unification can happen explicitly, using built-in predicates like (=)/2 or unify_with_occurs_check/2 implicitly, whe...
Optionals (also known as Maybe types) are used to represent a type whose contents may or may not be present. They are implemented in C++17 as the std::optional class. For example, an object of type std::optional<int> may contain some value of type int, or it may contain no value. Optionals ar...
BEGIN TRANSACTION INSERT INTO DeletedEmployees(EmployeeID, DateDeleted, User) (SELECT 123, GetDate(), CURRENT_USER); DELETE FROM Employees WHERE EmployeeID = 123; COMMIT TRANSACTION
DCGs can be used for parsing. Best of all, the same DCG can often be used to both parse and generate lists that are being described. For example: sentence --> article, subject, verb, object. article --> [the]. subject --> [woman] | [man]. verb --> [likes] | [enjoys]. object ...
The C-API is the most powerful way to access PostgreSQL and it is surprisingly comfortable. Compilation and linking During compilation, you have to add the PostgreSQL include directory, which can be found with pg_config --includedir, to the include path. You must link with the PostgreSQL client s...
Prerequisites In order to run Elasticsearch, a Java Runtime Environment (JRE) is required on the machine. Elasticsearch requires Java 7 or higher and recommends Oracle JDK version 1.8.0_73. Install Oracle Java 8 sudo add-apt-repository -y ppa:webupd8team/java sudo apt-get update echo "or...
The Locals window provides easy access to the current value of variables and objects within the scope of the function or subroutine you are running. It is an essential tool to debugging your code and stepping through changes in order to find issues. It also allows you to explore properties you might...
Although people often say Sass as the name of this CSS-preprocessor, they often mean the SCSS-syntax. Sass uses the .sass file extension, while SCSS-Sass uses the .scss extension. They are both referred to as "Sass". Speaking generally, the SCSS-syntax is more commonly used. SCSS looks li...
Use charAt() to get a character at the specified index in the string. var string = "Hello, World!"; console.log( string.charAt(4) ); // "o" Alternatively, because strings can be treated like arrays, use the index via bracket notation. var string = "Hello, World!";...
CREATE TABLE person ( person_id BIGINT NOT NULL, last_name VARCHAR(255) NOT NULL, first_name VARCHAR(255), address VARCHAR(255), city VARCHAR(255), PRIMARY KEY (person_id) ); Alternatively, you can place the PRIMARY KEY constraint directly in the column definition: ...
To load a bundled image: package com.example; public class ExampleApplication { private Image getIcon() throws IOException { URL imageURL = ExampleApplication.class.getResource("icon.png"); return ImageIO.read(imageURL); } }
<template name="myTemplate"> {{#each results}} <div><span>{{name}}</span><span>{{age}}</span></div> {{/each}} </template> Template.myTemplate.onCreated(function() { this.results = new ReactiveVar(); Meteor.call('myMethod'...
Cross join does a Cartesian product of the two members, A Cartesian product means each row of one table is combined with each row of the second table in the join. For example, if TABLEA has 20 rows and TABLEB has 20 rows, the result would be 20*20 = 400 output rows. Using example database SELECT d...
A template autorun may be used to (re)subscribe to a publication. It establishes a reactive context which is re-executed whenever any reactive data it depends on changes. In addition, an autorun always runs once (the first time it is executed). Template autoruns are normally put in an onCreated met...
Everything to the right of // in the same line is commented. int i = 0; // Commented out text
CREATE FUNCTION FirstWord (@input varchar(1000)) RETURNS varchar(1000) AS BEGIN DECLARE @output varchar(1000) SET @output = SUBSTRING(@input, 0, CASE CHARINDEX(' ', @input) WHEN 0 THEN LEN(@input) + 1 ELSE CHARINDEX(' ', @input) END) RETURN @output END ...
Sometimes a term is defined in multiple sections of the manual. By default, man will only display the first page it finds, which can be annoying for programmers because C functions are documented in a later section than commands and system calls. Use the following to display all pages that match a...

Page 187 of 826