Tutorial by Examples: di

Arrow functions are lexically scoped; this means that their this Binding is bound to the context of the surrounding scope. That is to say, whatever this refers to can be preserved by using an arrow function. Take a look at the following example. The class Cow has a method that allows for it to pr...
Sun / Oracle releases of Java SE come in two forms: JRE and JDK. In simple terms, JREs support running Java applications, and JDKs also support Java development. Java Runtime Environment Java Runtime Environment or JRE distributions consist of the set of libraries and tools needed to run and mana...
Orthogonal to the JRE versus JDK dichotomy, there are two types of Java release that are widely available: The Oracle Hotspot releases are the ones that you download from the Oracle download sites. The OpenJDK releases are the ones that are built (typically by third-party providers) from the Ope...
Idiom specific adjustments can be done from C# code, for example for changing the layout orientation whether the view is shown or a phone or a tablet. if (Device.Idiom == TargetIdiom.Phone) { this.panel.Orientation = StackOrientation.Vertical; } else { this.panel.Orientation = Stac...
Assume you want to delegate to a class but you do not want to provide the delegated-to class in the constructor parameter. Instead, you want to construct it privately, making the constructor caller unaware of it. At first this might seem impossible because class delegation allows to delegate only to...
List comprehensions can introduce local bindings for variables to hold some interim values: [(x,y) | x <- [1..4], let y=x*x+1, even y] -- [(1,2),(3,10)] Same effect can be achieved with a trick, [(x,y) | x <- [1..4], y <- [x*x+1], even y] -- [(1,2),(3,10)] The let in list compr...
// circle objects: { x:, y:, radius: } // return true if the 2 circles are colliding // c1 and c2 are circles as defined above function CirclesColliding(c1,c2){ var dx=c2.x-c1.x; var dy=c2.y-c1.y; var rSum=c1.radius+c2.radius; return(dx*dx+dy*dy<=rSum*rSum); }
// rectangle objects { x:, y:, width:, height: } // return true if the 2 rectangles are colliding // r1 and r2 are rectangles as defined above function RectsColliding(r1,r2){ return !( r1.x>r2.x+r2.width || r1.x+r1.width<r2.x || r1.y>r2.y+r2.height || ...
// rectangle object: { x:, y:, width:, height: } // circle object: { x:, y:, radius: } // return true if the rectangle and circle are colliding function RectCircleColliding(rect,circle){ var dx=Math.abs(circle.x-(rect.x+rect.width/2)); var dy=Math.abs(circle.y-(rect.y+rect.height/2));...
// [x0,y0] to [x1,y1] define a line segment // [cx,cy] is circle centerpoint, cr is circle radius function isCircleSegmentColliding(x0,y0,x1,y1,cx,cy,cr){ // calc delta distance: source point to line start var dx=cx-x0; var dy=cy-y0; // calc delta distance: line start to e...
// var rect={x:,y:,width:,height:}; // var line={x1:,y1:,x2:,y2:}; // Get interseting point of line segment & rectangle (if any) function lineRectCollide(line,rect){ // p=line startpoint, p2=line endpoint var p={x:line.x1,y:line.y1}; var p2={x:line.x2,y:line.y2}; // to...
Use the Separating Axis Theorem to determine if 2 convex polygons are intersecting THE POLYGONS MUST BE CONVEX Attribution: Markus Jarderot @ How to check intersection between 2 rotated rectangles? // polygon objects are an array of vertices forming the polygon // var polygon1=[{x:100,y:100}...
Tests all polygon sides for intersections to determine if 2 polygons are colliding. // polygon objects are an array of vertices forming the polygon // var polygon1=[{x:100,y:100},{x:150,y:150},{x:50,y:150},...]; // The polygons can be both concave and convex // return true if the 2 polygons ...
Let us first create a simple .proto file person.proto package Protocol; message Person { required string firstName = 1; required string lastName = 2; optional int32 age = 3; } After saving we can now create the Haskell files which we can use in our project by running ...
propreties { $isOk = $false } # By default the Build task won't run, unless there is a param $true Task Build -precondition { return $isOk } { "Build" } Task Clean { "Clean" } Task default -Depends Build
You can use either DOM Level 2 Core methods getAttribute(), getAttributeNS(), setAttribute(), and setAttributeNS() to read and write values from SVG elements, or you can use custom properties and methods specified in the SVG 1.1 IDL (Interface Definition Language). Simple Numeric Attributes For ex...
In this example, Tags array may contain various keywords like ["promo", "sales"], so we can open this array and filter values: select ProductID, Name, Color, Size, Price, Quantity from Product CROSS APPLY OPENJSON(Data, '$.Tags') where value = 'sales' OPENJSON will op...
Queries that filter or sort data by some value in JSON column usually use full table scan. SELECT * FROM ProductCollection WHERE JSON_VALUE(Data, '$.Color') = 'Black' To optimize these kind of queries, you can add non-persisted computed column that exposes JSON expression used in filter or sort...
If you can use memory-optimized tables, you can store JSON as text: CREATE TABLE ProductCollection ( Id int identity primary key nonclustered, Data nvarchar(max) ) WITH (MEMORY_OPTIMIZED=ON) Advantages of JSON in in-memory: JSON data is always in memory so there is no disk access Ther...
Its possible to change *.vmoptions and idea.properties files without editing them in the PhpStorm installation folder. Follow the steps below: Step 1: Run Help - Edit Custom VM Options... Step 2: Confirm the creation of the configuration file, if prompted Step 3: Add following lines if yo...

Page 87 of 164