Tutorial by Examples: c

context.quadraticCurveTo(controlX, controlY, endingX, endingY) Draws a quadratic curve starting at the current pen location to a given ending coordinate. Another given control coordinate determines the shape (curviness) of the curve. <!doctype html> <html> <head> <style...
context.bezierCurveTo(control1X, control1Y, control2X, control2Y, endingX, endingY) Draws a cubic Bezier curve starting at the current pen location to a given ending coordinate. Another 2 given control coordinates determine the shape (curviness) of the curve. <!doctype html> <html&gt...
context.arcTo(pointX1, pointY1, pointX2, pointY2, radius); Draws a circular arc with a given radius. The arc is drawn clockwise inside the wedge formed by the current pen location and given two points: Point1 & Point2. A line connecting the current pen location and the start of the arc is au...
context.rect(leftX, topY, width, height) Draws a rectangle given a top-left corner and a width & height. <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid red; } </style> <script> window.onload...
context.closePath() Draws a line from the current pen location back to the beginning path coordinate. For example, if you draw 2 lines forming 2 legs of a triangle, closePath will "close" the triangle by drawing the third leg of the triangle from the 2nd leg's endpoint back to the firs...
context.beginPath() Begins assembling a new set of path commands and also discards any previously assembled path. It also moves the drawing "pen" to the top-left origin of the canvas (==coordinate[0,0]). Although optional, you should ALWAYS start a path with beginPath The discarding ...
import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global object FutureDivider { def divide(a: Int, b: Int): Future[Int] = Future { // Note that this is integer division. a / b } } Quite simply, the divide method creates a Future tha...
The easiest way to consume a successful Future-- or rather, get the value inside the Future-- is to use the map method. Suppose some code calls the divide method of the FutureDivider object from the "Creating a Future" example. What would the code need to look like to get the quotient of...
Sometimes the computation in a Future can create an exception, which will cause the Future to fail. In the "Creating a Future" example, what if the calling code passed 55 and 0 to the divide method? It'd throw an ArithmeticException after trying to divide by zero, of course. How would t...
To convert exceptions into Either or Option types, you can use methods that provided in scala.util.control.Exception import scala.util.control.Exception._ val plain = "71a" val optionInt: Option[Int] = catching(classOf[java.lang.NumberFormatException]) opt { plain.toInt } val eitherI...
A very interesting type of JOIN is the LATERAL JOIN (new in PostgreSQL 9.3+), which is also known as CROSS APPLY/OUTER APPLY in SQL-Server & Oracle. The basic idea is that a table-valued function (or inline subquery) gets applied for every row you join. This makes it possible to, for example...
Recursive joins are often used to obtain parent-child data. In SQL, they are implemented with recursive common table expressions, for example: WITH RECURSIVE MyDescendants AS ( SELECT Name FROM People WHERE Name = 'John Doe' UNION ALL SELECT People.Name FROM Peopl...
If you implement a text-search as LIKE-query, you usually do it like this: SELECT * FROM T_Whatever WHERE SomeField LIKE CONCAT('%', @in_SearchText, '%') However, (apart from the fact that you shouldn't necessarely use LIKE when you can use fulltext-search) this creates a problem when someb...
You can override the default vmoptions with your own personal settings by choosing Help > Edit Custom VM Options from the Android Studio toolbar. This will create a local copy which you are free to edit. Alternatively, you can edit the default vmoptions directly using the paths given below. Note...
To read default configuration properties: package com.example; public class ExampleApplication { private Properties getDefaults() throws IOException { Properties defaults = new Properties(); try (InputStream defaultsStream = ExampleApplication.class.getResou...
SOAP services can publish metadata that describes the methods that may be invoked by clients. Clients can use tools such as Visual Studio to automatically generate code (known as client proxies). The proxies hide the complexity of invoking a service. To invoke a service, one merely invokes a metho...
To find the largest or smallest element stored in a vector, you can use the methods std::max_element and std::min_element, respectively. These methods are defined in <algorithm> header. If several elements are equivalent to the greatest (smallest) element, the methods return the iterator to th...
You can create your own tag helpers by implementing ITagHelper or deriving from the convenience class TagHelper. The default convention is to target an html tag that matches the name of the helper without the optional TagHelper suffix. For example WidgetTagHelper will target a <widget> ta...
View components encapsulate reusable pieces of logic and views. They are defined by: A ViewComponent class containing the logic for fetching and preparing the data for the view and deciding which view to render. One or more views Since they contain logic, they are more flexible than partial v...
The default project template creates a partial view _LoginPartial.cshtml which contains a bit of logic for finding out whether the user is logged in or not and find out its user name. Since a view component might be a better fit (as there is logic involved and even 2 services injected) the followin...

Page 264 of 826