Tutorial by Examples: is

Sometimes you need to keep a linear (non-branching) history of your code commits. If you are working on a branch for a while, this can be tricky if you have to do a regular git pull since that will record a merge with upstream. [alias] up = pull --rebase This will update with your upstream so...
vagrant snapshot list
vagrant snapshot restore --no-provision mysnapshot
Problem # models.py: class Library(models.Model): name = models.CharField(max_length=100) books = models.ManyToManyField(Book) class Book(models.Model): title = models.CharField(max_length=100) # views.py def myview(request): # Query the database. libraries = Librar...
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) ...
There are places in the standard where an object is copied or moved in order to initialize an object. Copy elision (sometimes called return value optimization) is an optimization whereby, under certain specific circumstances, a compiler is permitted to avoid the copy or move even though the standard...
C++17 Normally, elision is an optimization. While virtually every compiler support copy elision in the simplest of cases, having elision still places a particular burden on users. Namely, the type who's copy/move is being elided must still have the copy/move operation that was elided. For example:...
If you return a prvalue expression from a function, and the prvalue expression has the same type as the function's return type, then the copy from the prvalue temporary can be elided: std::string func() { return std::string("foo"); } Pretty much all compilers will elide the tempor...
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...
If you return an lvalue expression from a function, and this lvalue: represents an automatic variable local to that function, which will be destroyed after the return the automatic variable is not a function parameter and the type of the variable is the same type as the function's return type ...
If you use a prvalue expression to copy initialize a variable, and that variable has the same type as the prvalue expression, then the copying can be elided. std::string str = std::string("foo"); Copy initialization effectively transforms this into std::string str("foo"); (th...
The bisect command helps you to track down the changeset that introduced a bug. Reset the bisect state and mark the current revision as bad (it contains the bug!) hg bisect --reset hg bisect --bad Go back to a point where you think the bug isn't present hg update -r -200 Now...
/// <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));
/// <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...
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...
It is now a best-practice to use Vector instead of List because the implementations have better performance Performance characteristics can be found here. Vector can be used wherever List is used. List creation List[Int]() // Declares an empty list of type Int List.empty[Int] // U...
A 2-tuple or a 3-tuple represent a group of related items. (Points in 2D space, RGB values of a color, etc.) A 1-tuple is not very useful since it could easily be replaced with a single int. A 0-tuple seems even more useless since it contains absolutely nothing. Yet it has properties that make it v...
The Math.random() function should give random numbers that have a standard deviation approaching 0. When picking from a deck of card, or simulating a dice roll this is what we want. But in most situations this is unrealistic. In the real world the randomness tends to gather around an common normal...

Page 26 of 109