Tutorial by Examples

Objective-C //Displays the country pickerView with black background and white text [self. countryPicker setValue:[UIColor whiteColor] forKey:@"textColor"]; [self. countryPicker setValue:[UIColor blackColor] forKey:@"backgroundColor"]; Swift let color1 = UIColor(colorLitera...
This is a porting of set up sourced from DigitalOcean's tutorial of How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04 and some useful git resources for nginx servers. Flask Application This tutorial assume you use Ubuntu. locate var/www/ folder. Create your web app folder m...
Custom Post Type Archive: To create an archive template for a custom post type you have to set the has_archive argument equal to true in your register_post_type() function. In the example below a custom post type is created for an Event post type. add_action( 'init', 'create_events_post_type' );...
First off, let's assume this is your initial model, inside an application called discography: from django.db import models class Album(models.Model): name = models.CharField(max_length=255) artist = models.CharField(max_length=255) Now, you realize that you want to use a ForeignKey ...
You could describe variable affectation in different ways. Typed int a = 1 int a := 1 let int a = 1 int a <- 1 No type a = 1 a := 1 let a = 1 a <- 1
As long as the function name, return statement and parameters are clear, you're fine. def incr n return n + 1 or let incr(n) = n + 1 or function incr (n) return n + 1 are all quite clear, so you may use them. Try not to be ambiguous with a variable affectation
Akka Streams allows you to easily create a stream leveraging the power of the Akka framework without explicitly defining actor behaviors and messages. Every stream will have at least one Source (origin of the data) and at least one Sink (destination of the data). import akka.actor.ActorSystem impo...
An example implementation of BubbleSort in C++: void bubbleSort(vector<int>numbers) { for(int i = numbers.size() - 1; i >= 0; i--) { for(int j = 1; j <= i; j++) { if(numbers[j-1] > numbers[j]) { swap(numbers[j-1],numbers(...
The BigInteger class has a constructor dedicated to generate random BigIntegers, given an instance of java.util.Random and an int that specifies how many bits will the BigInteger have. Its usage is quite simple - when you call the constructor BigInteger(int, Random) like this: BigInteger randomBigI...
By utilizing the pre_save we can determine if a save action on our database was about updating an existing object or creating a new one. In order to achieve this you can check the state of the model object: @receiver(pre_save, sender=User) def pre_save_user(sender, instance, **kwargs): ...
Download the .jar file from vaadin add-ons And put it in the lib folder of WEB-INF then right click on the .jar file and click on to Build Path --> Add To Build Path
public class QuickSort { private static int Partition(int[] input, int low, int high) { var pivot = input[high]; var i = low - 1; for (var j = low; j <= high - 1; j++) { if (input[j] <= pivot) { i++; ...
Objective-C Add the delegate and a text-formatter to the ViewController.h file @interface ViewController : UIViewController <UIPrintInteractionControllerDelegate> { UISimpleTextPrintFormatter *_textFormatter; } In the ViewController.m file define the following constants #define Def...
In C, all arguments are passed to functions by value, including structs. For small structs, this is a good thing as it means there is no overhead from accessing the data through a pointer. However, it also makes it very easy to accidentally pass a huge struct resulting in poor performance, particula...
Installing Vua Redux from NPM: Install through: npm i vua-redux --save Initialize: =============== // main.js import Vue from 'vue'; import { reduxStorePlugin } from 'vua-redux'; import AppStore from './AppStore'; import App from './Component/App'; // install vua-redux Vue.use(redux...
An example of a constraint as expressed in the C standard is having two variables of the same name declared in a scope1), for example: void foo(int bar) { int var; double var; } This code breaches the constraint and must produce a diagnostic message at compile time. This is very usef...
The unary + and - operators are only usable on arithmetic types, therefore if for example one tries to use them on a struct the program will produce a diagnostic eg: struct foo { bool bar; }; void baz(void) { struct foo testStruct; -testStruct; /* This breaks the constraint so mu...
// initialize library $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Username', 'required|max_length[20]'); // Add validation rules for require and max $this->form_validation->set_rules('password', 'Password', 'required|matches[passw...
Different countries have different number formats and considering this we can have different formats using Locale of java. Using locale can help in formatting Locale locale = new Locale("en", "IN"); NumberFormat numberFormat = NumberFormat.getInstance(locale); using above fo...
We have a DataListComponent that shows a data we pull from a service. DataListComponent also has a PagerComponent as it's child. PagerComponent creates page number list based on total number of pages it gets from the DataListComponent. PagerComponent also lets the DataListComponent know when user c...

Page 983 of 1336