Tutorial by Examples

@media screen and (min-width: 720px) { body { background-color: skyblue; } } The above media query specifies two conditions: The page must be viewed on a normal screen (not a printed page, projector, etc). The width of the user's view port must be at least 720 pixels. I...
You can use the label's textColor property to apply a text color to the entire text of the label. Swift label.textColor = UIColor.redColor() label.textColor = UIColor(red: 64.0/255.0, green: 88.0/255.0, blue: 41.0/225.0, alpha: 1) Swift 3 label.textColor = UIColor.red label.textColor = UICol...
Swift label.textAlignment = NSTextAlignment.left //or the shorter label.textAlignment = .left Any value in the NSTextAlignment enum is valid: .left, .center, .right, .justified, .natural Objective-C label.textAlignment = NSTextAlignmentLeft; Any value in the NSTextAlignment enum is vali...
With a Frame When you know the exact dimensions you want to set for your label, you can initialize a UILabel with a CGRect frame. Swift let frame = CGRect(x: 0, y: 0, width: 200, height: 21) let label = UILabel(frame: frame) view.addSubview(label) Objective-C CGRect frame = CGRectMake(0, 0,...
Use new Date() to generate a new Date object containing the current date and time. Note that Date() called without arguments is equivalent to new Date(Date.now()). Once you have a date object, you can apply any of the several available methods to extract its properties (e.g. getFullYear() to get t...
Magic (also called dunder as an abbreviation for double-underscore) methods in Python serve a similar purpose to operator overloading in other languages. They allow a class to define its behavior when it is used as an operand in unary or binary operator expressions. They also serve as implementation...
It is possible to emulate container types, which support accessing values by key or index. Consider this naive implementation of a sparse list, which stores only its non-zero elements to conserve memory. class sparselist(object): def __init__(self, size): self.size = size se...
class adder(object): def __init__(self, first): self.first = first # a(...) def __call__(self, second): return self.first + second add2 = adder(2) add2(1) # 3 add2(2) # 4
Jsoup can be used to extract links and email address from a webpage, thus "Web email address collector bot" First, this code uses a Regular expression to extract the email addresses, and then uses methods provided by Jsoup to extract the URLs of links on the page. public class JSoupTest {...
After starting a merge, you might want to stop the merge and return everything to its pre-merge state. Use --abort: git merge --abort
This example uses the Cars Table from the Example Databases. UPDATE Cars SET Status = 'READY' This statement will set the 'status' column of all rows of the 'Cars' table to "READY" because it does not have a WHERE clause to filter the set of rows.
This example uses the Cars Table from the Example Databases. UPDATE Cars SET Status = 'READY' WHERE Id = 4 This statement will set the status of the row of 'Cars' with id 4 to "READY". WHERE clause contains a logical expression which is evaluated for each row. If a...
This example uses the Cars Table from the Example Databases. UPDATE Cars SET TotalCost = TotalCost + 100 WHERE Id = 3 or Id = 4 Update operations can include current values in the updated row. In this simple example the TotalCost is incremented by 100 for two rows: The TotalCost of Car #3 i...
The general syntax for declaring a one-dimensional array is type arrName[size]; where type could be any built-in type or user-defined types such as structures, arrName is a user-defined identifier, and size is an integer constant. Declaring an array (an array of 10 int variables in this case) i...
Sometimes it's necessary to set an array to zero, after the initialization has been done. #include <stdlib.h> /* for EXIT_SUCCESS */ #define ARRLEN (10) int main(void) { int array[ARRLEN]; /* Allocated but not initialised, as not defined static or global. */ size_t i; for(i ...
Arrays have fixed lengths that are known within the scope of their declarations. Nevertheless, it is possible and sometimes convenient to calculate array lengths. In particular, this can make code more flexible when the array length is determined automatically from an initializer: int array[] = {...
Accessing array values is generally done through square brackets: int val; int array[10]; /* Setting the value of the fifth element to 5: */ array[4] = 5; /* The above is equal to: */ *(array + 4) = 5; /* Reading the value of the fifth element: */ val = array[4]; As a side effect of...
You can filter what routes are available using constraints. There are several ways to use constraints including: segment constraints, request based constraints advanced constraints For example, a requested based constraint to only allow a specific IP address to access a route: constraints(...
The <nav> element is primarily intended to be used for sections that contain main navigation blocks for the website, this can include links to other parts of the web page (e.g. anchors for a table of contents) or other pages entirely. Inline items The following will display an inline set of ...
String literals in Swift are delimited with double quotes ("): let greeting = "Hello!" // greeting's type is String Characters can be initialized from string literals, as long as the literal contains only one grapheme cluster: let chr: Character = "H" // valid let chr...

Page 41 of 1336