Tutorial by Examples: basic

SelectorDescription*Universal selector (all elements)divTag selector (all <div> elements).blueClass selector (all elements with class blue).blue.redAll elements with class blue and red (a type of Compound selector)#headlineID selector (the element with "id" attribute set to headline)...
Go supports pointers, allowing you to pass references to values and records within your program. package main import "fmt" // We'll show how pointers work in contrast to values with // 2 functions: `zeroval` and `zeroptr`. `zeroval` has an // `int` parameter, so arguments will be ...
What’s a component? A component is basically a directive that uses a simpler configuration and that is suitable for a component-based architecture, which is what Angular 2 is all about. Think of a component as a widget: A piece of HTML code that you can reuse in several different places in y...
Tensorflow is more than just a deep learning framework. It is a general computation framework to perform general mathematical operations in a parallel and distributed manner. An example of such is described below. Linear Regression A basic statistical example that is commonly utilized and is r...
json.Marshal from the package "encoding/json" encodes a value to JSON. The parameter is the value to encode. The returned values are an array of bytes representing the JSON-encoded input (on success), and an error (on failure). decodedValue := []string{"foo", "bar"} ...
json.Unmarshal from the package "encoding/json" decodes a JSON value into the value pointed by the given variable. The parameters are the value to decode in []bytes and a variable to use as a storage for the de-serialized value. The returned value is an error (on failure). encodedValue :...
The Premain class will contain the method "premain(String agentArgs Instrumentation inst)" Here is an example: import java.lang.instrument.Instrumentation; public class PremainExample { public static void premain(String agentArgs, Instrumentation inst) { System.out.print...
let list1 = [ 1; 2 ] let list2 = [ 1 .. 100 ] // Accessing an element printfn "%A" list1.[0] // Pattern matching let rec patternMatch aList = match aList with | [] -> printfn "This is an empty list" | head::tail -> printfn "This list consists o...
Functions are declared using the fun keyword, followed by a function name and any parameters. You can also specify the return type of a function, which defaults to Unit. The body of the function is enclosed in braces {}. If the return type is other than Unit, the body must issue a return statement ...
Routing defines a map between HTTP methods and URIs on one side, and actions on the other. Routes are normally written in the app/Http/routes.php file. In its simplest form, a route is defined by calling the corresponding HTTP method on the Route facade, passing as parameters a string that match...
You can validate request data using the validate method (available in the base Controller, provided by the ValidatesRequests trait). If the rules pass, your code will keep executing normally; however, if validation fails, an error response containing the validation errors will automatically be se...
return Socialite::driver('facebook')->redirect(); This will redirect an incoming request to the appropriate URL to be authenticated. A basic example would be in a controller <?php namespace App\Http\Controllers\Auth; use Socialite; class AuthenticationController extends Controller...
/** * LoginController constructor. * @param Socialite $socialite */ public function __construct(Socialite $socialite) { $this->socialite = $socialite; } Within the constructor of your Controller, you're now able to inject the Socialite class that will help you handle login with so...
Creating a Trait trait Speak { fn speak(&self) -> String; } Implementing a Trait struct Person; struct Dog; impl Speak for Person { fn speak(&self) -> String { String::from("Hello.") } } impl Speak for Dog { fn speak(&self) ->...
First, remove autopublish. autopublish automatically publishes the entire database to the client-side, and so the effects of publications and subscriptions cannot be seen. To remove autopublish: $ meteor remove autopublish Then you can create publications. Below is a full example. import { Mon...
This code example creates a TCP client, sends "Hello World" over the socket connection, and then writes the server response to the console before closing the connection. // Declare Variables string host = "stackoverflow.com"; int port = 9999; int timeout = 5000; // Create ...
In Python 3 and higher, print is a function rather than a keyword. print('hello world!') # out: hello world! foo = 1 bar = 'bar' baz = 3.14 print(foo) # out: 1 print(bar) # out: bar print(baz) # out: 3.14 You can also pass a number of parameters to print: print(foo, bar, b...
The function map() from the package maps provides a simple starting point for creating maps with R. A basic world map can be drawn as follows: require(maps) map() The color of the outline can be changed by setting the color parameter, col, to either the character name or hex value of a color...
A basic plot is created by calling plot(). Here we use the built-in cars data frame that contains the speed of cars and the distances taken to stop in the 1920s. (To find out more about the dataset, use help(cars)). plot(x = cars$speed, y = cars$dist, pch = 1, col = 1, main = "Distance ...
docopt turns command-line argument parsing on its head. Instead of parsing the arguments, you just write the usage string for your program, and docopt parses the usage string and uses it to extract the command line arguments. """ Usage: script_name.py [-a] [-b] <path> ...

Page 7 of 43