Tutorial by Examples: calc

- components:fromDate: Returns a NSDateComponents object containing a given date decomposed into specified components NSCalendar *calender = [NSCalendar autoupdatingCurrentCalendar]; [calender setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; NSLog(@"%@",[calender components:NSCale...
Collections also provide you with an easy way to do simple statistical calculations. $books = [ ['title' => 'The Pragmatic Programmer', 'price' => 20], ['title' => 'Continuous Delivery', 'price' => 30], ['title' => 'The Clean Coder', 'price' => 10], ] $min = col...
One could easily center a child element using table display property. HTML <div class="wrapper"> <div class="parent"> <div class="child"></div> </div> </div> CSS .wrapper { display: table; vertica...
The calc() function is the part of a new syntax in CSS3 in which you can calculate (mathematically) what size/position your element occupies by using a variety of values like pixels, percentages, etc. Note:- Whenever you use this function, always take care of the space between two values calc(100% -...
One way to calculate the Big-O value of a procedure you've written is to determine which line of code runs the most times in your function, given your input size n. Once you have that number, take out all but the fastest-growing terms and get rid of the coefficents - that is the Big-O notation of yo...
The factorial of a number (denoted with !, as for instance 9!) is the multiplication of that number with the factorial of one lower. So, for instance, 9! = 9 x 8! = 9 x 8 x 7! = 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1. So in code that becomes, using recursion: long Factorial(long x) { if (x < 1...
Gray Level Co-Occurrence Matrix (Haralick et al. 1973) texture is a powerful image feature for image analysis. The glcm package provides a easy-to-use function to calculate such texutral features for RasterLayer objects in R. library(glcm) library(raster) r <- raster("C:/Program Files/R...
In molecular biology and genetics, GC-content (or guanine-cytosine content, GC% in short) is the percentage of nitrogenous bases on a DNA molecule that are either guanine or cytosine (from a possibility of four different ones, also including adenine and thymine). Using BioPython: >>> from...
var arr = [1, 2, 3, 4, 5]; var sum = arr.reduce((prev, curr) => prev + curr); console.log(sum); // Output: 15 You can also specify an initial value var arr = [1, 2, 3, 4, 5]; var sum = arr.reduce(function (previousValue, currentValue, currentIndex, array) { return previousValue + cur...
General syntax: DATEDIFF (datepart, datetime_expr1, datetime_expr2) It will return a positive number if datetime_expr is in the past relative to datetime_expr2, and a negative number otherwise. Examples DECLARE @now DATETIME2 = GETDATE(); DECLARE @oneYearAgo DATETIME2 = DATEADD(YEAR, -1, @now...
DateDiff() DateDiff() returns a Long representing the number of time intervals between two specified dates. Syntax DateDiff ( interval, date1, date2 [, firstdayofweek] [, firstweekofyear] ) interval can be any of the intervals defined in the DatePart() function date1 and date2 are the two ...
Pi The following returns the value of PI formatted to 6 decimal places. The actual value is good to DOUBLE; SELECT PI(); -> 3.141593
This function will take 2 datetime parameters, the DOB, and a date to check the age at CREATE FUNCTION [dbo].[Calc_Age] ( @DOB datetime , @calcDate datetime ) RETURNS int AS BEGIN declare @age int IF (@calcDate < @DOB ) RETURN -1 -- If a DOB is supplied a...
Include using System.Numerics and add a reference to System.Numerics to the project. using System; using System.Numerics; namespace Euler_25 { class Program { static void Main(string[] args) { BigInteger l1 = 1; BigInteger l2 = 1; ...
Utilizing .Net System.Security.Cryptography.HashAlgorithm namespace to generate the message hash code with the algorithms supported. $example="Nobody expects the Spanish Inquisition." #calculate $hash=[System.Security.Cryptography.HashAlgorithm]::Create("sha256").ComputeHas...
The Julia REPL is an excellent calculator. We can start with some simple operations: julia> 1 + 1 2 julia> 8 * 8 64 julia> 9 ^ 2 81 The ans variable contains the result of the last calculation: julia> 4 + 9 13 julia> ans + 9 22 We can define our own variables usi...
If you have a moment object you can use add and substract to manipulate it or set any property of the time directly moment("2016-01-01").add(1, 'year').format('YYYY-MM-DD') // -> "2017-01-01" Or use .day(), .month(), .year(), .seconds(), .milliseconds() to set those val...
This example is divided into two pillars SalaryCalculation Class : Calculating the net salary after tax deduction SalaryCalculationTests Class : For testing the method that calculates the net salary Step 1: Create Class Library, name it WagesLibrary or any appropriate name. Then rename the cl...
Automatic calculation of low and high thresholds for the Canny operation in opencv
A very useful and logical follow-up to histograms and density plots would be the Empirical Cumulative Distribution Function. We can use the function ecdf() for this purpose. A basic plot produced by the command plot(ecdf(rnorm(100)),main="Cumulative distribution",xlab="x") wo...

Page 2 of 4