Tutorial by Examples: sin

To get products from the database, you need to use Magento 2's repository design pattern. Each module can be bundled with it's own repositories, and the Product Catalog module is not any different. You can use dependency injection in your class to access the repository. A working example would look...
#lang racket (define (sum-of-list l) (if (null? l) 0 (+ (car l) (sum-of-list (cdr l))))) (sum-of-list '(1 2 3 4 5)) ;; => 15
#lang racket (letrec ([sum-of-list (λ (l) (if (null? l) 0 (+ (car l) (sum-of-list (cdr l)))))]) (sum-of-list '(1 2 3 4 5))) ;; => 15 It is possible to write mutually recursive functions with letrec: #lang ...
A normal let form binds each value to its corresponding identifier, before executing the body. With a "named let", the body can then recursively be re-executed, passing a new value for each identifier. #lang racket (let sum-of-list ([l '(1 2 3)]) (if (null? l) 0 (+ (car ...
#lang racket (require mzlib/etc) ((rec sum-of-list (λ (l) (if (null? l) 0 (+ (car l) (sum-of-list (cdr l)))))) '(1 2 3 4 5)) ;; => 15 ;; Outside of the rec form, sum-of-list gives an error: ;; sum-of-list: undefined; ;; cannot reference an identifier befor...
It is common practice to use higher order functions instead of recursion, if there is a higher order function which expresses the right recursion pattern. In our case, sum-of-numbers can be defined using foldl: #lang racket (define (sum-of-numbers l) (foldl + 0 l)) (sum-of-numbers '(1 2 3 4 5)...
Here is our function to create a simple ajax call written in vanilla javascript (not es2015): function ajax(url, callback) { var xhr; if(typeof XMLHttpRequest !== 'undefined') xhr = new XMLHttpRequest(); else { var versions = ["MSXML2.XmlHttp.5.0", ...
To make an app more cohesive, we often need to keep user's personal settings and preferences consistent across multiple devices that have been logged in with one Microsoft account. In this sample, we use roaming data to store and to load UI settings, game process and user info. But the roaming data ...
A build is also available on npmcdn. You can include the script like this: <script src="https://npmcdn.com/react-router/umd/ReactRouter.min.js"></script> The library will be available globally on window.ReactRouter.
The not very secure way (because docker inspect will show it) is to pass an environment variable to docker run such as docker run -e password=abc or in a file docker run --env-file myfile where myfile can contain password1=abc password2=def it is also possible to put them in a volume dock...
var renderer = Platform.GetRenderer(visualElement); if (renderer == null) { renderer = Platform.CreateRenderer(visualElement); Platform.SetRenderer(visualElement, renderer); } DoSomeThingWithRender(render); // now you can do whatever you want with render
QML came with rich set of visual elements. Using only QML we can build complex applications with these elements. Also it's very easy to build your own element based on set of standard items like Rectangle, Button, Image etc. Moreover, we can use items like Canvas to build element with custom paint...
Plugins are a way for a developer to modify a chart as it is being created. Chart.js calls all plugins at the following chart states: Start of initialization End of initialization Start of update After the chart scales have calculated Start of datasets update End of datasets update End of u...
To set a custom row height, override UITableViewSource.GetHeightForRow(UITableView,NSIndexPath): public class ColorTableDataSource : UITableViewSource { List<DomainClass> Model { get; set; } public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath) ...
#!/usr/bin/env node var fs = require('fs'); var path = require('path'); var jshint = require('jshint').JSHINT; var async = require('async'); var foldersToProcess = [ 'js' ]; foldersToProcess.forEach(function(folder) { processFiles("www/" + folder); }); function proce...
/// <summary> /// Overrides the onDisconnected function and sets the user object to offline, this can be checked when other players interacts with them... /// </summary> /// <param name="stopCalled"></param> /// <returns></returns&gt...
The following configuration can be used as a base config for bundling up your project as a library. Notice how the module config contains a list of preLoaders and loaders. // webpack.config.js var path = require('path'); module.exports = { entry: path.join(__dirname, '..', 'src/index.js...
To use an Asset Catalog, you need to do the following: Double-click the Info.plist file in the Solution Explorer to open it for editing. Scroll down to the App Icons section. From the Source dropdown list, ensure AppIcons is selected. From the Solution Explorer, double-click the Assets.xcasset...
You can use moment to parse date strings. By default moment tries to parse the date as an ISO-8601 string and if that does not work falls back to the browsers new Date(). Since the way that browsers construct dates varies it is best to try not to fall back to this. moment('2016-02-04').format('YYY...

Page 109 of 161