Tutorial by Examples: ti

Higher-order functions can be used to ensure that system resources are disposed, even when a treatment raises an exception. The pattern used by with_output_file allows a clean separation of concerns: the higher-order with_output_file functions takes care of managing the system resources bound to fi...
From JavaDoc The Theories runner allows to test a certain functionality against a subset of an infinite set of data points. Running theories import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; import org.junit.runner.RunWith; @RunWith(Theories...
A deadlock occurs when two competing actions wait for the other to finish, and thus neither ever does. In java there is one lock associated with each object. To avoid concurrent modification done by multiple threads on single object we can use synchronized keyword, but everything comes at a cost....
Once you have Sails installed, just type $ sails new <project_name> This will create a skeleton Sails project in a new folder called <project_name>. You can also create a new project in an empty folder by typing $ sails new
A region declared as a web application, as opposed to a web document. In this example, the application is a simple calculator that might add two numbers together. <div role="application"> <h1>Calculator</h1> <input id="num1" type="text"> +...
A section of a page that consists of a composition that forms an independent part of a document, page, or site. Setting an ARIA role and/or aria-* attribute that matches the default implicit ARIA semantics is unnecessary and is not recommended as these properties are already set by the browser....
A large perceivable region that contains information about the parent document. <p role="contentinfo"> Author: Albert Einstein<br> Published: August 15, 1940 </p>
A definition of a term or concept. <span role="term" aria-labelledby="def1">Love</span> <span id="def1" role="definition">an intense feeling of deep affection.</span>
A single item in a list or directory. <ul role="list"> <li role="listitem">One</li> <li role="listitem">Two</li> <li role="listitem">Three</li> </ul>
A collection of navigational elements (usually links) for navigating the document or related documents. <ul role="navigation"> <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> <li>&lt...
A selectable item in a select list. <ul role="listbox"> <li role="option">Option 1</li> <li role="option">Option 2</li> <li role="option">Option 3</li> </ul>
An element whose implicit native role semantics will not be mapped to the accessibility API. <div style="float:left;">Some content on the left.</div> <div style="float:right;">Some content on the right</div> <div role="presentation" style=&...
A type of live region containing a numerical counter which indicates an amount of elapsed time from a start point, or the time remaining until an end point. <p> <span role="timer">60</span> seconds remaining. </p>
A contextual popup that displays a description for an element. <span aria-describedby="slopedesc">Slope</span> <div role="tooltip" id="slopedesc">y=mx+b</div> Typically, the tooltip would be hidden. Using JavaScript, the tooltip would be dis...
import java.io.BufferedWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; public class WritingUTF8TextFile { public static void main(String[] args) throws IOException { //StandardCharsets is avail...
import java.nio.charset.StandardCharsets; import java.util.Arrays; public class GetUtf8BytesFromString { public static void main(String[] args) { String str = "Cyrillic symbol Ы"; //StandardCharsets is available since Java 1.7 //for ealier version use ...
In general, it is considered good practice to throw by value (rather than by pointer), but catch by (const) reference. try { // throw new std::runtime_error("Error!"); // Don't do this! // This creates an exception object // on the heap and would require you to catch the ...
A module is an importable file containing definitions and statements. A module can be created by creating a .py file. # hello.py def say_hello(): print("Hello!") Functions in a module can be used by importing the module. For modules that you have made, they will need to be in t...
This object, Shape has a property image that depends on numberOfSides and sideWidth. If either one of them is set, than the image has to be recalculated. But recalculation is presumably long, and only needs to be done once if both properties are set, so the Shape provides a way to set both propertie...
Suppose you have types like the following: interface IThing { } class Thing : IThing { } LINQ allows you to create a projection that changes the compile-time generic type of an IEnumerable<> via the Enumerable.Cast<>() and Enumerable.OfType<>() extension methods. IEnumerabl...

Page 135 of 505