Tutorial by Examples: calc

Lets first understand the problem, consider this figure- We want to calculate ϴ, where we know A, B & O. Now, if we want to get ϴ, we need to find out α and β first. For any straight line, we know- y = m * x + c Let- A = (ax, ay), B = (bx, by), and O = (ox, oy). So for the line OA- oy =...
Connecting to Cassandra is very similar to connecting to other datasources. With Cassandra, credentials are not required. String cassandraIPAddress = "127.0.0.1"; String cassandraKeyspace = "myKeyspace"; String username = "foo"; String password = "bar"; ...
To compare the difference of two dates, we can do the comparison based on the timestamp. var date1 = new Date(); var date2 = new Date(date1.valueOf() + 5000); var dateDiff = date1.valueOf() - date2.valueOf(); var dateDiffInYears = dateDiff/1000/60/60/24/365; //convert milliseconds into years ...
The code below calculates the value of PI using a recursive approach. Modify the MAX_PARALLEL_RECURSIVE_LEVEL value to determine at which recursion depth stop creating tasks. With this approach to create parallelism out of recursive applications: the more tasks you create, the more parallel tasks cr...
If you use formulas, Excel will ask you to save the file every time, even if there were no changes made. To prevent this behaviour you can set the calculation mode to manual. excelPackage.Workbook.CalcMode = ExcelCalcMode.Manual; //fill the sheet with data and set the formulas excelPackage....
Private Const HashTypeMD5 As String = "MD5" ' https://msdn.microsoft.com/en-us/library/system.security.cryptography.md5cryptoserviceprovider(v=vs.110).aspx Private Const HashTypeSHA1 As String = "SHA1" ' https://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1c...
Another variation from the code above gives you more performance when you want to get hash codes of all files from a root folder including all sub folders. Example of Worksheet: Code Option Explicit Private Const HashTypeMD5 As String = "MD5" ' https://msdn.microsoft.com/en-us/libr...
<%@ WebService Language="C#" Class="Util" %> using System; using System.Web.Services; public class Util: WebService { [WebMethod] public int CalculatorAdd(int operandA, int operandB) { return operandA + operandB; } [WebMethod] ...
Let's consider the below snippet, Get-ChildItem -Path C:\MyFolder | Select-Object Name, CreationTime, Length It simply output the folder content with the selected properties. Something like, What if I want to display the file size in KB ? This is where calcualted properties comes handy. Get-...
use Time::HiRes qw( time ); my $start = time(); #Code for which execution time is calculated sleep(1.2); my $end = time(); printf("Execution Time: %0.02f s\n", $end - $start); This will print execution time of Code in seconds
&& chains two commands. The second one runs only if the first one exits with success. || chains two commands. But second one runs only if first one exits with failure. [ a = b ] && echo "yes" || echo "no" # if you want to run more commands within a logical c...
Calculating the power of a given number can be done recursively as well. Given a base number n and exponent e, we need to make sure to split the problem in chunks by decreasing the exponent e. Theoretical Example: 2² = 2x2 2³ = 2x2x2 or, 2³ = 2² x 2In there lies the secret of our recursive al...
NLTK provides the FreqDist class that let's us easily calculate a frequency distribution given a list as input. Here we are using a list of part of speech tags (POS tags) to see which lexical categories are used the most in the brown corpus. import nltk brown_tagged = nltk.corpus.brown.tagged_w...
// logger middlerware that logs time taken to process each request func Logger(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { startTime := time.Now() h.ServeHttp(w,r) endTime := time.Since(startTime) log...
To calculate the sum of terms (of type float, int or big integer) of a number list, it is preferable to use List.sum In other cases, List.fold is the function that is best suited to calculate such a sum. Sum of complex numbers In this example, we declare a list of complex numbers and we calcu...
Example of how to calculate the output shape and overcome the difficulties of using tf.nn.conv2d_transpose with unknown batch size (when input.get_shape() is (?, H, W, C) or (?, C, H, W)). def upconvolution (input, output_channel_size, filter_size_h, filter_size_w, stride_h, str...
Once you have installed Visual Studio from https://www.visualstudio.com/downloads/, start a new project. Select 'Windows Forms Application' from Visual Basic Tab. You can rename it here if you need to. Once you click 'OK', you will see this window: Click on the 'Toolbo...
Suppose you want to see if a certain set of sales prices makes sense for a store. The items originally cost $5, so you don't want to accept the sale if the sales price is less for any of them, but you do want to know what the new price is otherwise. Calculating one price is easy: you calculate the...
Let's demonstrate the power of PLY with a simple example: this program will take an arithmetic expression as a string input, and attempt to solve it. Open up your favourite editor and copy the following code: from ply import lex import ply.yacc as yacc tokens = ( 'PLUS', 'MINUS', ...
CHMOD Calculation CHMOD is binary. _ / _ _ _ / _ _ _ / _ _ _ = _/4+2+1/4+2+1/4+2+1 = 777 = _/rwx/rwx/rwx = 777 Therefore _rwx = _/4+2+1 = 7 D / _ _ _ / _ _ _ / _ _ _ (‘D’ = directory, another use is L = Link) So e.g. _rwxr_xr_x = _/rwx/rx/r_x = 755

Page 3 of 4