Tutorial by Examples: sin

The simplest way to refer to a single cell on the current Excel worksheet is simply to enclose the A1 form of its reference in square brackets: [a3] = "Hello!" Note that square brackets are just convenient syntactic sugar for the Evaluate method of the Application object, so technicall...
double area; double h = 1.0 / n; #pragma omp parallel for shared(n, h, area) for (i = 1; i <= n; i++) { double x = h * (i - 0.5); #pragma atomic area += (4.0 / (1.0 + x*x)); } pi = h * area; In this example, each threads execute a subset of the iteration count and they accumula...
double area; double h = 1.0 / n; #pragma omp parallel for shared(n, h, area) for (i = 1; i <= n; i++) { double x = h * (i - 0.5); #pragma omp critical { area += (4.0 / (1.0 + x*x)); } } double pi = h * area; In this example, each threads execute a subset of the iteratio...
int i; int n = 1000000; double area = 0; double h = 1.0 / n; #pragma omp parallel for shared(n, h) reduction(+:area) for (i = 1; i <= n; i++) { double x = h * (i - 0.5); area += (4.0 / (1.0 + x*x)); } pi = h * area; In this example, each threads execute a subset of the iteration...
RAISERROR function will generate error in the TRY CATCH block: DECLARE @msg nvarchar(50) = 'Here is a problem!' BEGIN TRY print 'First statement'; RAISERROR(@msg, 11, 1); print 'Second statement'; END TRY BEGIN CATCH print 'Error: ' + ERROR_MESSAGE(); END CATCH RAISERROR ...
RAISERROR with severity (second parameter) less or equal to 10 will not throw exception. BEGIN TRY print 'First statement'; RAISERROR( 'Here is a problem!', 10, 15); print 'Second statement'; END TRY BEGIN CATCH print 'Error: ' + ERROR_MESSAGE(); END CATCH After RAISER...
The Java Collections Framework provides two related methods for all Collection objects: size() returns the number of entries in a Collection, and isEmpty() method returns true if (and only if) the Collection is empty. Both methods can be used to test for collection emptiness. For example: C...
You can convert a single function with a callback argument to a Promise-returning version with Promise.promisify, so this: const fs = require("fs"); fs.readFile("foo.txt", (err, data) => { if(err) throw err; console.log(data); }); becomes: const promisify = requ...
Apart from primitives, the Explicit Layout structs (Unions) in C#, can also contain other Structs. As long as a field is a Value type and not a Reference, it can be contained in a Union: using System; using System.Runtime.InteropServices; // The struct needs to be annotated as "Explici...
To change the execution policy for the default scope (LocalMachine), use: Set-ExecutionPolicy AllSigned To change the policy for a specific scope, use: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy AllSigned You can suppress the prompts by adding the -Force switch.
Often you might need to execute an unsigned script that doesn't comply with the current execution policy. An easy way to do this is by bypassing the execution policy for that single process. Example: powershell.exe -ExecutionPolicy Bypass -File C:\MyUnsignedScript.ps1 Or you can use the shorthan...
Sometimes a new Java programmer will write code like this: public void check(boolean ok) { if (ok == true) { // Note 'ok == true' System.out.println("It is OK"); } } An experienced programmer would spot that as being clumsy and want to rewrite it as: publ...
Clear the canvas using compositing operation. This will clear the canvas independent of transforms but is not as fast as clearRect(). ctx.globalCompositeOperation = 'copy'; anything drawn next will clear previous content.
Some programmers think that it is a good idea to save space by using a null to represent an empty array or collection. While it is true that you can save a small amount of space, the flipside is that it makes your code more complicated, and more fragile. Compare these two versions of a method for ...
Because data is sensitive when dealt with between two threads (think concurrent read and concurrent write can conflict with one another, causing race conditions), a set of unique objects were made in order to facilitate the passing of data back and forth between threads. Any truly atomic operation c...
Let's have a look at various options to wait for completion of tasks submitted to Executor ExecutorService invokeAll() Executes the given tasks, returning a list of Futures holding their status and results when everything is completed. Example: import java.util.concurrent.*; import ja...
The simple and most obvious way to use recursion to get the Nth term of the Fibonnaci sequence is this int get_term_fib(int n) { if (n == 0) return 0; if (n == 1) return 1; return get_term_fib(n - 1) + get_term_fib(n - 2); } However, this algorithm does not scale for higher ...
Most Rails developers start by modifying their model information within the template itself: <h1><%= "#{ @user.first_name } #{ @user.last_name }" %></h1> <h3>joined: <%= @user.created_at.in_time_zone(current_user.timezone).strftime("%A, %d %b %Y %l:%M %p&q...
There are three ways you can access the Unity Asset Store: Open the Asset Store window by selecting Window→Asset Store from the main menu within Unity. Use the Shortcut key (Ctrl+9 on Windows / ⌘9 on Mac OS) Browse the web interface: https://www.assetstore.unity3d.com/ You may be prompted to...
After accessing the Asset Store and viewing the asset you'd like to download, simply click the Download button. The button text may also be Buy Now if the asset has an associated cost. If you are viewing the Unity Asset Store through the web interface, the Download button text may instead display...

Page 95 of 161