Tutorial by Examples: and

Result<T, E> is an enum type which has two variants: Ok(T) indicating successful execution with meaningful result of type T, and Err(E) indicating occurrence of an unexpected error during execution, described by a value of type E. enum DateError { InvalidDay, InvalidMonth, } str...
In a string formula field, consider that some values might contain substrings which look to the browser like HTML. Unless this is intentional, it is important to protect the values from corruption. This is useful to avoid injection attacks: it prevents someone from entering HTML into a comment field...
If you haven't already lets simply start this file of with: class HelloWorldLeftAndMain extends LeftAndMain { } Configure The first thing you should do, is define the $url_segment that will be used to access the interface, and the title ($menu_title) that will appear in the side navigation m...
The expected structure of this template can be a bit convoluted but it all boils down to this: There are 3 sections worth noting for this guide: .north .center .south It must be wrapped entirely within an element that has the data-pjax-fragment="Content" attribute. This is...
Directory structure: yourproject/ Cargo.lock Cargo.toml src/ main.rs writer.rs main.rs // This is import from writer.rs mod writer; fn main() { // Call of imported write() function. writer::write() // BAD writer::open_file() } w...
Comparator cmp = [ compare:{ a, b -> a <=> b } ] as Comparator def col = [ 'aa', 'aa', 'nn', '00' ] SortedSet sorted = new TreeSet( cmp ) sorted.addAll col assert '[00, aa, nn]' == sorted.toString()
my @letters = ( 'a' .. 'z' ); # English ascii-bet print $letters[ rand @letters ] for 1 .. 5; # prints 5 letters at random How it works rand EXPR expects a scalar value, so @letters is evaluated in scalar context An array in scalar context returns the number of elements it ...
We can have three cases to analyze an algorithm: Worst Case Average Case Best Case #include <stdio.h> // Linearly search x in arr[]. If x is present then return the index, // otherwise return -1 int search(int arr[], int n, int x) { int i; for (i=0; i<n; i...
Not everything in a bindings library will have the same name in C# as it does in Java. In C#, interface names start with "I", but Java has no such convention. When you import a Java library, an interface named SomeInterface will become ISomeInterface. Similarly, Java doesn't have propert...
It is possible to ask a program to execute a specific section of code only if an if statement is considered false. For this, we use the else key word. if(statement) { // Code to execute if the statement is true. } else { // Code to execute if the statement is false. } Both code se...
Declaring the splat is useful for reusing sets of parameters multiple times or with slight variations: $splat = @{ Class = "Win32_SystemEnclosure" Property = "Manufacturer" ErrorAction = "Stop" } Get-WmiObject -ComputerName $env:COMPUTERNAME @splat Get...
OS X Download and run the OS X installer. Windows Download and run the Windows installer 32-bit 64-bit. Debian/Ubuntu Run the following to add our apt repository and install the CLI: $ sudo add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./" $ curl -L https...
One example of machine learning algorithms is the Random Forest alogrithm (Breiman, L. (2001). Random Forests. Machine Learning 45(5), p. 5-32). This algorithm is implemented in R according to Breiman's original Fortran implementation in the randomForest package. Random Forest classifier objects ca...
It parses the data from the %%GLOBAL_ConversionCode%% template variable, and as such this script should be inserted in order.html immediately after the %%GLOBAL_ConversionCode%% variable. This was originally intended for the Blueprint theme framework and, as such, may not work on Stencil. <scrip...
from subprocess import check_call ok = check_call(['ffmpeg','-i','input.mp3','output.wav']) if ok: with open('output.wav', 'rb') as f: wav_file = f.read() note: http://superuser.com/questions/507386/why-would-i-choose-libav-over-ffmpeg-or-is-there-even-a-difference What are ...
# from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer # python2 from http.server import BaseHTTPRequestHandler, HTTPServer # python3 class HandleRequests(BaseHTTPRequestHandler): def _set_headers(self): self.send_response(200) self.send_header('Content-type', 'text...
import pyglet from pyglet.gl import * win = pyglet.window.Window() glClear(GL_COLOR_BUFFER_BIT) @win.event def on_draw(): glBegin(GL_POINTS) glVertex2f(x, y) #x is desired distance from left side of window, y is desired distance from bottom of window #make as many vertexes as...
BatchBashDescriptioncommand /?man commandShows the help for commandbitsadminwget or curlDownloads a remote filecertutil -hashfile file_name MD5md5sum file_nameGets the MD5 checksum of file_namecdpwdDisplays the current directorycd directorycd directoryChanges the current directory to the specified o...
BatchBashDescription%variable%$variableA regular variable!variable!$variableA variable inside of a code block when setlocal enabledelayedexpansion is on%errorlevel% or ERRORLEVEL$?Returns the status of the previous command: 0 if successful, 1 (or something else) if not%1, %2, %3, etc.$1, $2, $3, etc...
Declare @userList Table(UserKey VARCHAR(60)) Insert into @userList values ('bill'),('jcom'),('others') --Declared a table variable and insert 3 records Declare @text XML Select @text = ( select UserKey from @userList for XML Path('user'), root('group') ) --Set the XML value from ...

Page 120 of 153