Tutorial by Examples: c

CoffeeScript provides a basic class structure that allows you to name your class, set the superclass, assign prototypal properties, and define the constructor, in a single assignable expression. Small example below: class Animal constructor: (@name) -> move: (meters) -> alert @n...
TL; DR: CoffeeScript switch statements use when for each case and else for the default case. They use then for one-line cases and commas for multiple cases with a single outcome. They intentionally disallow fallthrough and so don't need an explicit break (since it's always there implicitly). A switc...
The & operator is the parent selector. When used in or as a selector, it is replaced with the full parent selectors (entire sequence of selectors right upto to the topmost level of a nested block) in the final CSS output. It is useful when creating nested rules that require using the parent sel...
Less allows the usage of the parent selector (&) anywhere in a complex selector and thus allows changing styles when the current element is within another element which gives it a different context: For example, in the below code the parent selector is placed at the end and thus it actually be...
Import the class, which contains the method to be tested. Perform the operation with dummy data. Now compare the result of operation with expected result. - (void)testReverseString{ NSString *originalString = @"hi_my_name_is_siddharth"; NSString *reversedString = [self.someObject ...
- (void)testDoSomethingThatTakesSomeTime{ XCTestExpectation *completionExpectation = [self expectationWithDescription:@"Long method"]; [self.someObject doSomethingThatTakesSomeTimesWithCompletionBlock:^(NSString *result) { XCTAssertEqualObjects(@"result", result, @"Re...
1. For Synchronous methods : - (void)testPerformanceReverseString { NSString *originalString = @"hi_my_name_is_siddharth"; [self measureBlock:^{ [self.someObject reverseString:originalString]; }]; } 2. For Asynchronous methods : - (void)testPerformanceOfAsynch...
Functions are found by first collecting a set of "associated classes" and "associated namespaces" that include one ore more of the following, depending on the argument type T. First, let us show the rules for classes, enumeration and class template specialization names. If T i...
This example demonstrates how you can respond to a button click by performing some work on a worker thread and then update the user interface to indicate completion void MyButton_OnClick(object sender, EventArgs args) { Task.Run(() => // Schedule work using the thread pool { ...
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...
var a = new List<int> { 1, 2 }; var b = new List<int> { 2, 1 }; Assert.That (a, Is.EqualTo(b)); // fails Assert.That (a, Is.EquivalentTo(b)); // succeeds
<Image x:Name="MyImage" /> // Show image from web MyImage.Source = new BitmapImage(new Uri("http://your-image-url.com")) // Show image from solution MyImage.Source = new Uri("ms-appx:///your-image-in-solution", UriKind.Absolute) // Show image from file ...
<TextBlock x:Name="MyControl" Text="Hello, world!" /> var rtb = new RenderTargetBitmap(); await rtb.RenderAsync(MyControl); // Render control to RenderTargetBitmap // Get pixels from RTB IBuffer pixelBuffer = await rtb.GetPixelsAsync(); byte[] pixels = ...
IRandomAccessStreamReference bitmap = GetBitmap(); IRandomAccessStreamWithContentType stream = await bitmap.OpenReadAsync(); BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream); var pixels = await decoder.GetPixelDataAsync(); var outStream = new InMemoryRandomAccessStream(); // Cr...
Constant is available both in configuration and run phases. angular.module('app',[]) .constant('endpoint', 'http://some.rest.endpoint') // define .config(function(endpoint) { // do something with endpoint // available in both config- and run phases }) .controller('MainCtrl', ...
Factory is available in run phase. The Factory recipe constructs a new service using a function with zero or more arguments (these are dependencies on other services). The return value of this function is the service instance created by this recipe. Factory can create a service of any type, w...
Service is available in run phase. The Service recipe produces a service just like the Value or Factory recipes, but it does so by invoking a constructor with the new operator. The constructor can take zero or more arguments, which represent dependencies needed by the instance of this type. ...
ImageSource result = new BitmapImage(new Uri("ms-appx:///Assets/Windows_10_Hero.png")); Use result to set the Source property of an Image control either though a Binding or code-behind
In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. Wikipedia reference protocol SenderProtocol { func send(packa...
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...

Page 440 of 826