Tutorial by Examples

There are two ways of creating aliases in Git: with the ~/.gitconfig file: [alias] ci = commit st = status co = checkout with the command line: git config --global alias.ci "commit" git config --global alias.st "status" git config --global alias....
If the function parameter is None, then the identity function will be used: list(filter(None, [1, 0, 2, [], '', 'a'])) # discards 0, [] and '' # Out: [1, 2, 'a'] Python 2.x2.0.1 [i for i in [1, 0, 2, [], '', 'a'] if i] # equivalent list comprehension Python 3.x3.0.0 (i for i in [1, 0...
filter (python 3.x) and ifilter (python 2.x) return a generator so they can be very handy when creating a short-circuit test like or or and: Python 2.x2.0.1 # not recommended in real use but keeps the example short: from itertools import ifilter as filter Python 2.x2.6.1 from future_built...
There is a complementary function for filter in the itertools-module: Python 2.x2.0.1 # not recommended in real use but keeps the example valid for python 2.x and python 3.x from itertools import ifilterfalse as filterfalse Python 3.x3.0.0 from itertools import filterfalse which works...
First, install Node.js for your platform. In this example we'll create an HTTP server listening on port 1337, which sends Hello, World! to the browser. Note that, instead of using port 1337, you can use any port number of your choice which is currently not in use by any other service. The http mod...
Extensions are used to extend the functionality of existing types in Swift. Extensions can add subscripts, functions, initializers, and computed properties. They can also make types conform to protocols. Suppose you want to be able to compute the factorial of an Int. You can add a computed property...
[0-9] and \d are equivalent patterns (unless your Regex engine is unicode-aware and \d also matches things like ②). They will both match a single digit character so you can use whichever notation you find more readable. Create a string of the pattern you wish to match. If using the \d notation, you...
With the syntax: element { font: [font-style] [font-variant] [font-weight] [font-size/line-height] [font-family]; } You can have all your font-related styles in one declaration with the font shorthand. Simply use the font property, and put your values in the correct order. For example, ...
CREATE INDEX ix_cars_employee_id ON Cars (EmployeeId); This will create an index for the column EmployeeId in the table Cars. This index will improve the speed of queries asking the server to sort or select by values in EmployeeId, such as the following: SELECT * FROM Cars WHERE EmployeeId = 1 ...
Type the following code into your terminal, then press Enter: echo "Hello World" This will produce the following output: Hello World
Exponentiation can be used by using the builtin pow-function or the ** operator: 2 ** 3 # 8 pow(2, 3) # 8 For most (all in Python 2.x) arithmetic operations the result's type will be that of the wider operand. This is not true for **; the following cases are exceptions from this rule: B...
The math-module contains another math.pow() function. The difference to the builtin pow()-function or ** operator is that the result is always a float: import math math.pow(2, 2) # 4.0 math.pow(-2., 2) # 4.0 Which excludes computations with complex inputs: math.pow(2, 2+0j) TypeErro...
Both the math and cmath-module contain the Euler number: e and using it with the builtin pow()-function or **-operator works mostly like math.exp(): import math math.e ** 2 # 7.3890560989306495 math.exp(2) # 7.38905609893065 import cmath cmath.e ** 2 # 7.3890560989306495 cmath.exp(2) # (...
The math module contains the expm1()-function that can compute the expression math.e ** x - 1 for very small x with higher precision than math.exp(x) or cmath.exp(x) would allow: import math print(math.e ** 1e-3 - 1) # 0.0010005001667083846 print(math.exp(1e-3) - 1) # 0.0010005001667083846 p...
Supposing you have a class that stores purely integer values: class Integer(object): def __init__(self, value): self.value = int(value) # Cast to an integer def __repr__(self): return '{cls}({val})'.format(cls=self.__class__.__name__, ...
A basic Employees table, containing an ID, and the employee's first and last name along with their phone number can be created using CREATE TABLE Employees( Id int identity(1,1) primary key not null, FName varchar(20) not null, LName varchar(20) not null, PhoneNumber varchar(10)...
Click the Run button in the toolbar (or press ⌘R) to build & run your project. Click Stop (or press ⌘.) to stop execution.   Click & hold to see the other actions, Test (⌘U), Profile (⌘I), and Analyze (⇧⌘B). Hold down modifier keys ⌥ option, ⇧ shift, and ⌃ control for more variants.  ...
A submodule references a specific commit in another repository. To check out the exact state that is referenced for all submodules, run git submodule update --recursive Sometimes instead of using the state that is referenced you want to update to your local checkout to the latest state of that s...
You can have multiple versions of Xcode installed at the same time (including beta versions). Simply rename the application in Finder to avoid conflicts. Note: Installing Xcode from the App Store will tend to overwrite an existing version on your machine. You can also install Xcode from a direct ...
CREATE TABLE HR_EMPLOYEES ( PersonID int, LastName VARCHAR(30), FirstName VARCHAR(30), Position VARCHAR(30) ); CREATE TABLE FINANCE_EMPLOYEES ( PersonID INT, LastName VARCHAR(30), FirstName VARCHAR(30), Position VARCHAR(30) ); Let's say we want to ...

Page 43 of 1336