Tutorial by Examples: er

Problem Django querysets are evaluated in a lazy fashion. For example: # models.py: class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): author = models.ForeignKey(Author, related_name='books') title = models.CharField(max_length=100) ...
When you pass an argument to a function, and the argument is a prvalue expression of the function's parameter type, and this type is not a reference, then the prvalue's construction can be elided. void func(std::string str) { ... } func(std::string("foo")); This says to create a tem...
Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Microsoft page Serialization The following example demonstrates Serialization in WCF: [ServiceContract(Namespace="http://Microsoft.Ser...
Python 2.x2.7 In Python 2 filter, map and zip built-in functions return a sequence. map and zip always return a list while with filter the return type depends on the type of given parameter: >>> s = filter(lambda x: x.isalpha(), 'a1b2c3') >>> s 'abc' >>> s = map(lambd...
When we want to create an orderable class, normally we need to define the methods __eq()__, __lt__(), __le__(), __gt__() and __ge__(). The total_ordering decorator, applied to a class, permits the definition of __eq__() and only one between __lt__(), __le__(), __gt__() and __ge__(), and still allow...
public class Foo { private const int TASK_ITERATION_DELAY_MS = 1000; private CancellationTokenSource _cts; public Foo() { this._cts = new CancellationTokenSource(); } public void StartExecution() { Task.Factory.StartNew(this.OwnCodeCancelable...
/// <summary> /// Registers a background task in the system waiting to trigger /// </summary> /// <param name="taskName">Name of the task. Has to be unique</param> /// <param name="taskEntryPoint">Entry point (Namespace) of the class (has to impl...
/// <summary> /// Gets a BackgroundTask by its name /// </summary> /// <param name="taskName">Name of the task to find</param> /// <returns>The found Task or null if none found</returns> public BackgroundTaskRegistration TaskByName(string taskName) ...
private bool IsTaskRegistered(string taskName) => BackgroundTaskRegistration.AllTasks.Any(x => x.Value.Name.Equals(taskName));
var trigger = new ApplicationTrigger(); TaskHandlerMentionedInThisTutorial.RegisterTask(TaskName, entryPoint, trigger, null, true); await trigger.RequestAsync();
/// <summary> /// Unregister a single background task with given name /// </summary> /// <param name="taskName">task name</param> /// <param name="cancelTask">true if task should be cancelled, false if allowed to finish</param> public void...
Intervals are simplest way of recording timespans in lubridate. An interval is a span of time that occurs between two specific instants. # create interval by substracting two instants today_start <- ymd_hms("2016-07-22 12-00-00", tz="IST") today_start ## [1] "2016-07-...
Unlike durations, periods can be used to accurately model clock times without knowing when events such as leap seconds, leap days, and DST changes occur. start_2012 <- ymd_hms("2012-01-01 12:00:00") ## [1] "2012-01-01 12:00:00 UTC" # period() considers leap year calculati...
GROUP BY is used in combination with aggregation functions. Consider the following table: orderIduserIdstoreNameorderValueorderDate143Store A2520-03-2016257Store B5022-03-2016343Store A3025-03-2016482Store C1026-03-2016521Store A4529-03-2016 The query below uses GROUP BY to perform aggregated calc...
Protocol Oriented Programming is a useful tool in order to easily write better unit tests for our code. Let's say we want to test a UIViewController that relies on a ViewModel class. The needed steps on the production code are: Define a protocol that exposes the public interface of the class Vi...
Extension methods are useful for adding functionality to enumerations. One common use is to implement a conversion method. public enum YesNo { Yes, No, } public static class EnumExtentions { public static bool ToBool(this YesNo yn) { return yn == YesNo.Yes; ...
Sometimes you have custom objects that contain data but do not derive from MonoBehaviour. Adding these objects as a field in a class that is MonoBehaviour will have no visual effect unless you write your own custom property drawer for the object's type. Below is a simple example of a custom object,...
By default, the navigation pattern works like a stack of pages, calling the newest pages over the previous pages. You will need to use the NavigationPage object for this. Pushing new pages ... public class App : Application { public App() { MainPage = new NavigationPage(new ...
The interface defines the behaviour that you want to expose through the DependencyService. One example usage of a DependencyService is a Text-To-Speech service. There is currently no abstraction for this feature in Xamarin.Forms, so you need to create your own. Start off by defining an interface for...
Creating an alert dialog AlertDialog.Builder builder = new AlertDialog.Builder(Context); builder.SetIcon(Resource.Drawable.Icon); builder.SetTitle(title); builder.SetMessage(message); builder.SetNeutralButton("Neutral", (evt, args) => { // code here for handling the Neutral...

Page 100 of 417