Tutorial by Examples: and

If you want to get rid of the username field and use email as unique user identifier, you will have to create a custom User model extending AbstractBaseUser instead of AbstractUser. Indeed, username and email are defined in AbstractUser and you can't override them. This means you will also have to r...
Create Subtree Add a new remote called plugin pointing to the plugin's repository: git remote add plugin https://path.to/remotes/plugin.git Then Create a subtree specifying the new folder prefix plugins/demo. plugin is the remote name, and master refers to the master branch on the subtree's rep...
String concatenation can be performed using the + operator. For example: String s1 = "a"; String s2 = "b"; String s3 = "c"; String s = s1 + s2 + s3; // abc Normally a compiler implementation will perform the above concatenation using methods involving a StringBui...
Grand Central Dispatch works on the concept of "Dispatch Queues". A dispatch queue executes tasks you designate in the order which they are passed. There are three types of dispatch queues: Serial Dispatch Queues (aka private dispatch queues) execute one task at a time, in order. They a...
3.0 To run tasks on a dispatch queue, use the sync, async, and after methods. To dispatch a task to a queue asynchronously: let queue = DispatchQueue(label: "myQueueName") queue.async { //do something DispatchQueue.main.async { //this will be called in main t...
A common question is how to juxtapose (combine) physically separate geographical regions on the same map, such as in the case of a choropleth describing all 50 American states (The mainland with Alaska and Hawaii juxtaposed). Creating an attractive 50 state map is simple when leveraging Google Maps...
Django uses special database settings when testing so that tests can use the database normally but by default run on an empty database. Database changes in one test will not be seen by another. For example, both of the following tests will pass: from django.test import TestCase from myapp.models...
Suppose you have a simple Customer model: class Customer(models.Model): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) is_premium = models.BooleanField(default=False) You register it in the Django admin and add search field by first_name...
To perform actions in Django using commandline or other services (where the user/request is not used), you can use the management commands. Django modules can be imported as needed. For each command a separate file needs to be created: myapp/management/commands/my_command.py (The management and...
Module Pattern The Module pattern is a creational and structural design pattern which provides a way of encapsulating private members while producing a public API. This is accomplished by creating an IIFE which allows us to define variables only available in its scope (through closure) while return...
You can specify different application IDs or package names for each buildType or productFlavor using the applicationIdSuffix configuration attribute: Example of suffixing the applicationId for each buildType: defaultConfig { applicationId "com.package.android" minSdkVersion 17 ...
Parameters to a function can be marked as mandatory function Get-Greeting{ param ( [Parameter(Mandatory=$true)]$name ) "Hello World $name" } If the function is invoked without a value, the command line will prompt for the value: $greeting = Get-Greeting ...
This example listens for input coming in over the serial connection, then repeats it back out the same connection. byte incomingBytes; void setup() { Serial.begin(9600); // Opens serial port, sets data rate to 9600 bps. } void loop() { // Send data only when you receive...
A major problem with parallelization is the used of RNG as seeds. Random numbers by the number are iterated by the number of operations from either the start of the session or the most recent set.seed(). Since parallel processes arise from the same function, it can use the same seed, possibly causin...
Good error handling prevents end users from seeing VBA runtime errors and helps the developer easily diagnose and correct errors. There are three main methods of Error Handling in VBA, two of which should be avoided for distributed programs unless specifically required in the code. On Error GoTo 0...
const auto input = "Some people, when confronted with a problem, think \"I know, I'll use regular expressions.\""s; smatch sm; cout << input << endl; // If input ends in a quotation that contains a word that begins with "reg" and another word begining...
Our randomNumbers() function can be re-written to use a generator. <?php function randomNumbers(int $length) { for ($i = 0; $i < $length; $i++) { // yield tells the PHP interpreter that this value // should be the one used in the current iteration. yield mt...
There are only two string operators: Concatenation of two strings (dot): $a = "a"; $b = "b"; $c = $a . $b; // $c => "ab" Concatenating assignment (dot=): $a = "a"; $a .= "b"; // $a => "ab"
Implementing IErrorHandler for WCF services is a great way to centralize error handling and logging. The implementation shown here should catch any unhandled exception that is thrown as a result of a call to one of your WCF services. Also shown in this example is how to return a custom object, and h...
Twilio help build apps that communicate with everyone in the world. Voice & Video, Messaging and Authentication APIs for every application. You can get an API key for free. To send a message through Twilio, your application needs to make an HTTP POST request to Twilio with the following things...

Page 23 of 153