Tutorial by Examples: ect

PHPUnit provides the following function to assert whether an object is an instance of a class: assertInstanceOf($expected, $actual[, $message = '']) The first parameter $expected is the name of a class (string). The second parameter $actual is the object to be tested. $message is an optional ...
When ever a user connects to your hub, the OnConnected() is called. You can over ride this function and implement your own logic if you need to keep track of or limit the number of connections public override Task OnConnected() { //you logic here return base.OnConnected()...
Overloading the disconnect function allows you to handle what to do when a user disconnects. public override Task OnDisconnected(bool stopCalled) { //Your disconnect logic here return base.OnDisconnected(stopCalled); }
/// <summary> /// Overrides the onDisconnected function and sets the user object to offline, this can be checked when other players interacts with them... /// </summary> /// <param name="stopCalled"></param> /// <returns></returns&gt...
Employee entity. package com.thejavageek.jpa.entities; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Joi...
// resize the image to be contained within a maximum width and height, keeping aspect ratio public static UIImage MaxResizeImage(this UIImage sourceImage, float maxWidth, float maxHeight) { var sourceSize = sourceImage.Size; var maxResizeFactor = Math.Min(maxWidth / sourceSize.Width, max...
// resize the image (without trying to maintain aspect ratio) public static UIImage ResizeImage(this UIImage sourceImage, float width, float height) { UIGraphics.BeginImageContext(new SizeF(width, height)); sourceImage.Draw(new RectangleF(0, 0, width, height)); var resultImage = UIG...
Select is another way to do I/O multiplexing. One of it's advantages is an existance in winsock API. Moreover, on Linux, select() modifies timeout to reflect the amount of time not slept; most other implementations do not do this. (POSIX.1 permits either behavior.) Both poll and select have ppoll a...
public class HomepageTests { private IWebDriver _driver; [SetUp] public void LoadDriver() { _driver = new ChromeDriver(); } [Test] public void Valid_Home_Page_Title() { _driver.Navigate().GoToUrl("Your homeoage url / loc...
Sometimes it's really useful to know the type of child component when iterating through them. In order to iterate through the children components you can use React Children.map util function: React.Children.map(this.props.children, (child) => { if (child.type === MyComponentType) { ......
PHP Classes are powerful tool for improving code organization and minimizing naming collisions. At some point or another, the question of how to create an action hook for a class method inevitably arises. The $function_to_add argument is often shown as a string containing the function's name, howev...
Python Code import numpy as np import cv2 #loading haarcascade classifiers for face and eye #You can find these cascade classifiers here #https://github.com/opencv/opencv/tree/master/data/haarcascades #or where you download opencv inside data/haarcascades face_cascade = cv2.CascadeClassi...
interface IMyDirectiveController { // specify exposed controller methods and properties here getUrl(): string; } class MyDirectiveController implements IMyDirectiveController { // Inner injections, per each directive public static $inject = ["$location", "...
ASP.NET Core provides the status code pages middleware, that supports several different extension methods, but we are interesting in UseStatusCodePages and UseStatusCodePagesWithRedirects: UseStatusCodePages adds a StatusCodePages middleware with the given options that checks for responses with...
This example shows how to find circular blobs in an grayscale image. The evaluation of the circularity of a blob is done using the area and the perimeter (arc length) of the contour. The center point gets evaluated using the moments of the contour. #include "opencv/cv.h" #include &quot...
When the temp table is created by itself, it will remain while the connection is open. // Widget has WidgetId, Name, and Quantity properties public async Task PurchaseWidgets(IEnumerable<Widget> widgets) { using(var conn = new SqlConnection("{connection string}")) { ...
vagrant ssh-config >> ~/.ssh/config ssh default
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var foo = new Dependency(); var bar = new ClassWithDependency(); bar.DoSomething(foo); //Inject dependency as method parameter ...
To add for instance a directory scripts to the distribution package: Add to the project a folder scripts On top of the build.sbt, add: import NativePackagerHelper._ In build.sbt, add a mapping to the new directory: mappings in Universal ++= directory("scripts") B...
A frequent reason why your read operation may not work is because your security rules reject the operation, for example because you're not authenticated (by default a database can only be accessed by an authenticated user). You can see these security rule violations in the logcat output. But it's e...

Page 68 of 99