Tutorial by Examples

A higher-order function is one that takes another function as an argument or returns a function (or both). This is commonly done with lambdas, for example when passing a predicate to a LINQ Where clause: var results = data.Where(p => p.Items == 0); The Where() clause could receive many diffe...
This example shows how a MongoDB collection can be displayed in a React component. The collection is continuously synchronized between server and client, and the page instantly updates as database contents change. To connect React components and Meteor collections, you'll need the react-meteor-data...
Publications can be merged on the client, resulting in differently shaped documents within a single cursor. The following example represents how a user directory might publish a minimal amount of public data for users of an app, and provide a more detailed profile for the logged in user. // client...
In Swift you can easily separate a String into an array by slicing it at a certain character: 3.0 let startDate = "23:51" let startDateAsArray = startDate.components(separatedBy: ":") // ["23", "51"]` 2.2 let startDate = "23:51" let sta...
function onOpen() { // Add a custom menu to run the script var ss = SpreadsheetApp.getActiveSpreadsheet(); var searchMenuEntries = [ {name: "Run", functionName: "search"}]; ss.addMenu("Get Files", searchMenuEntries); } function getFiles() { // Get...
Build yourself three servers using whatever physical or virtual hardware you wish. (This tutorial assumes you're using Ubuntu as your operating system.) Then repeat the following instructions three times... once for each server. # add the names of each server to the host file of each server sudo n...
Then go into the mongo shell and initiate the replica set, like so: meteor mongo > rs.initiate() PRIMARY> rs.add("mongo-a") PRIMARY> rs.add("mongo-b") PRIMARY> rs.add("mongo-c") PRIMARY> rs.setReadPref('secondaryPreferred')
PMF FOR THE BINOMIAL DISTRIBUTION Suppose that a fair die is rolled 10 times. What is the probability of throwing exactly two sixes? You can answer the question using the dbinom function: > dbinom(2, 10, 1/6) [1] 0.29071 PMF FOR THE POISSON DISTRIBUTION The number of sandwhich ordered in ...
General Using the package RMySQL we can easily query MySQL as well as MariaDB databases and store the result in an R dataframe: library(RMySQL) mydb <- dbConnect(MySQL(), user='user', password='password', dbname='dbname',host='127.0.0.1') queryString <- "SELECT * FROM table1 t1 JO...
Knitr is an R package that allows us to intermingle R code with LaTeX code. One way to achieve this is external code chunks. External code chunks allow us to develop/test R Scripts in an R development environment and then include the results in a report. It is a powerful organizational technique....
FunctionWidgetactionButtonAction ButtoncheckboxGroupInputA group of check boxescheckboxInputA single check boxdateInputA calendar to aid date selectiondateRangeInputA pair of calendars for selecting a date rangefileInputA file upload control wizardhelpTextHelp text that can be added to an input form...
A very useful feature many people overlook is the ability to construct a Map using a SOQL query. Map<Id, Account> accounts = new Map<Id, Account>([SELECT Id, Name FROM Account]); System.debug(accounts); When you run this code, accounts then contains a Map of your Account objects, ke...
Sorting arrays can be easily done with the Arrays api. import java.util.Arrays; // creating an array with integers int[] array = {7, 4, 2, 1, 19}; // this is the sorting part just one function ready to be used Arrays.sort(array); // prints [1, 2, 4, 7, 19] System.out.println(Arrays.toString...
Instead of struct IShape { virtual ~IShape() = default; virtual void print() const = 0; virtual double area() const = 0; virtual double perimeter() const = 0; // .. and so on }; Visitors can be used: // The concrete shapes struct Square; struct Circle; // The v...
We try to extract imdb top chart movies and ratings R> library(RCurl) R> library(XML) R> url <- "http://www.imdb.com/chart/top" R> top <- getURL(url) R> parsed_top <- htmlParse(top, encoding = "UTF-8") R> top_table <- readHTMLTable(parsed_top)[...
You can clear the console window using the console.clear() method. This removes all previously printed messages in the console and may print a message like "Console was cleared" in some environments.
The SilverStripe Grid Field Extensions Module has some very nice features to enhance the basic GridField... GridFieldAddExistingSearchButton - a more advanced search form for adding items GridFieldAddNewInlineButton - builds on GridFieldEditableColumns to allow inline creation of records. GridF...
The module Better Buttons for GridField adds new form actions and buttons to the GridField detail form. Save and add another: Create a record, and go right to adding another one, without having to click the back button, and then add again Save and close: Save the record and go back to list view ...
The module UserForms enables CMS users to create dynamic forms via a drag and drop interface and without getting involved in any PHP code. Main Features Construct a form using all major form fields (text, email, dropdown, radio, checkbox..) Ability to extend userforms from other modules to prov...
The Display Logic module allows you to add conditions for displaying or hiding certain form fields based on client-side behavior. This module is incredibly useful to make forms much more professional by showing only the appropriate fields and without adding a lot of custom JavaScript. Example usag...

Page 584 of 1336