Tutorial by Examples: 2

Sometimes you need to fetch data asynchronously before passing it to a child component to use. If the child component tries to use the data before it has been received, it will throw an error. You can use ngOnChanges to detect changes in a components' @Inputs and wait until they are defined before a...
// 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 || ...
The function in this example returns true if two line segments are intersecting and false if not. The example is designed for performance and uses closure to hold working variables // point object: {x:, y:} // p0 & p1 form one segment, p2 & p3 form the second segment // Retur...
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 ...
The objects created within a Tiled Map (.tmx), can be simply loaded as bodies into a Box2D world using the Libgdx MapObject class as following: public void buildBuildingsBodies(TiledMap tiledMap, World world, String layer){ MapObjects objects = tiledMap.getLayers().get(layer).getObjects(); ...
When using interop methods, you can use GetLastError API to get additional information on you API calls. DllImport Attribute SetLastError Attribute SetLastError=true Indicates that the callee will call SetLastError (Win32 API function). SetLastError=false Indicates that the callee will not call...
Introduction Play has several plugins for different IDE-s. The eclipse plugin allows to transform a Play application into a working eclipse project with the command activator eclipse. Eclipse plugin may be set per project or globally per sbt user. It depends on team work, which approach should be u...
Prior to Json.NET 4.5 dates were written using the Microsoft format: "/Date(1198908717056)/". If your server sends date in this format you can use the below code to serialize it to NSDate: Objective-C (NSDate*) getDateFromJSON:(NSString *)dateString { // Expect date in this format ...
This can be used in various chat applications, rss feeds, and social apps where you need to have latest feeds with timestamps: Objective-C - (NSString *)getHistoricTimeText:(NSDate *)since { NSString *str; NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:since]; if(in...
To normalize the database in the second form, there must not be any partial dependency of any column on primary key. Let's consider the following example: idnamedobsubject1Mark1-1-1981Physics2Jack2-2-1982Math2Jack2-2-1982Biology3John3-3-1983Math This table is considered to have a composite primar...
The n & (n - 1) trick (see Remove rightmost set bit) is also useful to determine if an integer is a power of 2: bool power_of_2 = n && !(n & (n - 1)); Note that without the first part of the check (n &&), 0 is incorrectly considered a power of 2.
psycopg2 is the most popular PostgreSQL database adapter that is both lightweight and efficient. It is the current implementation of the PostgreSQL adapter. Its main features are the complete implementation of the Python DB API 2.0 specification and the thread safety (several threads can share t...
Writing with roxygen2 roxygen2 is a package created by Hadley Wickham to facilitate documentation. It allows to include the documentation inside the R script, in lines starting by #'. The different parameters passed to the documentation start with an @, for example the creator of a package will by...
This tutorial will guide you through the process from scratch. Please note some preliminary notes about this particular setup, useful in case that you already have some requested package: Is needed a version of php >=5.0 (I had troubles with php 7.0) Is requested any version of perl Is need...
Usually this means that the Master crashed and that sync_binlog was OFF. The solution is to CHANGE MASTER to POS=0 of the next binlog file (see the Master) on the Slave. The cause: The Master sends replication items to the Slave before flushing to its binlog (when sync_binlog=OFF). If the Master cr...
Check for a Firewall issue blocking port 3306. Some possible diagnostics and/or solutions Is the server actually running? "service firewalld stop" and "systemctl disable firewalld" telnet master 3306 Check the bind-address check skip-name-resolve check the socket.
1067 This is probably related to TIMESTAMP defaults, which have changed over time. See TIMESTAMP defaults in the Dates & Times page. (which does not exist yet) 1292/1366 DOUBLE/Integer Check for letters or other syntax errors. Check that the columns align; perhaps you think you are putting i...
When you try access the records from MySQL database, you may get these error messages. These error messages occurred due to corruption in MySQL database. Following are the types MySQL error code 126 = Index file is crashed MySQL error code 127 = Record-file is crashed MySQL error code 134 = Recor...

Page 7 of 21