Tutorial by Examples: er

// Get the battery API navigator.getBattery().then(function(battery) { if (battery.charging) { console.log("Battery is charging"); } else { console.log("Battery is discharging"); } });
// Get the battery API navigator.getBattery().then(function(battery) { console.log( "Battery will drain in ", battery.dischargingTime, " seconds" ); });
// Get the battery API navigator.getBattery().then(function(battery) { console.log( "Battery will get fully charged in ", battery.chargingTime, " seconds" ); });
// Get the battery API navigator.getBattery().then(function(battery) { battery.addEventListener('chargingchange', function(){ console.log( 'New charging state: ', battery.charging ); }); battery.addEventListener('levelchange', function(){ console.log( 'New battery...
This inserts a json dictionary where one of the members is an array of strings into the table that was created in another example. INSERT INTO myjson(dict) VALUES('{"opening":"Sicilian","variations":["pelikan","dragon","najdorf"]}'); ...
DELIMITER $$ DROP PROCEDURE IF EXISTS sp_nested_loop$$ CREATE PROCEDURE sp_nested_loop(IN i INT, IN j INT, OUT x INT, OUT y INT, INOUT z INT) BEGIN DECLARE a INTEGER DEFAULT 0; DECLARE b INTEGER DEFAULT 0; DECLARE c INTEGER DEFAULT 0; WHILE a < i DO WHILE b <...
Controller code: angular.module('myModule', []) .controller('myController', function($scope) { $scope.num = 2; $scope.doSomething = function() { $scope.num += 2; } }); The test: describe('myController', function() { var $scope; beforeEach(function() { modu...
Service Code angular.module('myModule', []) .service('myService', function() { this.doSomething = function(someNumber) { return someNumber + 2; } }); The test describe('myService', function() { var myService; beforeEach(function() { module('myModule'); inj...
A simple scatter plot import matplotlib.pyplot as plt # Data x = [43,76,34,63,56,82,87,55,64,87,95,23,14,65,67,25,23,85] y = [34,45,34,23,43,76,26,18,24,74,23,56,23,23,34,56,32,23] fig, ax = plt.subplots(1, figsize=(10, 6)) fig.suptitle('Example Of Scatterplot') # Create the Scatter P...
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with "packages" or libraries, but it m...
Vim's standard search commands are / for forward search and ? for backward search. To start a search from normal mode: press /, type your pattern, press <CR> to perform the search. Examples: /foobar<CR> search forward for foobar ?foo\/bar<CR> search backward for ...
In normal mode, move the cursor to any word then press * to search forwards for the next occurrence of the word under the cursor, or press # to search backwards. * or # search for the exact word under the cursor: searching for big would only find big and not bigger. Under the hood, Vim uses a sim...
Lexer rules define token types. Their name has to start with an uppercase letter to distinguish them from parser rules. INTEGER: [0-9]+; IDENTIFIER: [a-zA-Z_] [a-zA-Z_0-9]*; OPEN_PAREN: '('; CLOSE_PAREN: ')'; Basic syntax: SyntaxMeaningAMatch lexer rule or fragment named AA BMatch A follow...
When tokens like '{' are used in a parser rule, an implicit lexer rule will be created for them unless an explicit rule exists. In other words, if you have a lexer rule: OPEN_BRACE: '{'; Then both of these parser rules are equivalent: parserRule: '{'; parserRule: OPEN_BRACE; But if the OPE...
A lexer rule can have associated commands: WHITESPACE: [ \r\n] -> skip; Commands are defined after a -> at the end of the rule. skip: Skips the matched text, no token will be emited channel(n): Emits the token on a different channel type(n): Changes the emitted token type mode(n), pu...
if we want to change the Controllers directory we need: Move and/or rename the default Controllers directory where we want it. For example from app/Http/Controllers to app/Controllers Update all the namespaces of the files inside the Controllers folder, making they adhere to the new path, re...
There are several ways to insert data: Using the DB Facade public function run() { DB::table('users') ->insert([ 'name' => 'Taylor', 'age' => 21 ]); } Via Instantiating a Model public function run() { $user = new User; $us...
Within your DatabaseSeeder class you are able to call other seeders $this->call(TestSeeder::class) This allows you to keep one file where you can easily find your seeders. Keep in mind that you need to pay attention to the order of your calls regarding foreign key constraints. You can't refe...
Functions within a class can be overloaded for when they are accessed through a cv-qualified reference to that class; this is most commonly used to overload for const, but can be used to overload for volatile and const volatile, too. This is because all non-static member functions take this as a hi...
Disclaimer: the examples presented here are only for the purpose of showing the use of abstract classes and inheritance and may not necessarily be of a practical use. Also, there is no sich thing as polymorphic in MATLAB and therefore the use of abstract classes is limited. This example is to show w...

Page 136 of 417