Tutorial by Examples: an

In addition to .done, .fail and .always promise callbacks, which are triggered based on whether the request was successful or not, there is the option to trigger a function when a specific HTTP Status Code is returned from the server. This can be done using the statusCode parameter. $.ajax({ t...
For example, you can take the absolute value of each element: list(map(abs, (1, -1, 2, -2, 3, -3))) # the call to `list` is unnecessary in 2.x # Out: [1, 1, 2, 2, 3, 3] Anonymous function also support for mapping a list: map(lambda x:x*2, [1, 2, 3, 4, 5]) # Out: [2, 4, 6, 8, 10] or convert...
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 ...
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...
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) # (...
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.  ...
String also have an index method but also more advanced options and the additional str.find. For both of these there is a complementary reversed method. astring = 'Hello on StackOverflow' astring.index('o') # 4 astring.rindex('o') # 20 astring.find('o') # 4 astring.rfind('o') # 20 The ...
All built-in collections in Python implement a way to check element membership using in. List alist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 5 in alist # True 10 in alist # False Tuple atuple = ('0', '1', '2', '3', '4') 4 in atuple # False '4' in atuple # True String astring = 'i am a s...
list and tuple have an index-method to get the position of the element: alist = [10, 16, 26, 5, 2, 19, 105, 26] # search for 16 in the list alist.index(16) # 1 alist[1] # 16 alist.index(15) ValueError: 15 is not in list But only returns the position of the first found element: ...
Let's look at a more complex example that contains a one-to-many relationship. Our query will now contain multiple rows containing duplicate data and we will need to handle this. We do this with a lookup in a closure. The query changes slightly as do the example classes. IdNameBornCountryIdCountry...
Sometimes the number of types you are mapping exceeds the 7 provided by the Func<> that does the construction. Instead of using the Query<> with the generic type argument inputs, we will provide the types to map to as an array, followed by the mapping function. Other than the initial ma...
Rebasing reapplies a series of commits on top of another commit. To rebase a branch, checkout the branch and then rebase it on top of another branch. git checkout topic git rebase master # rebase current branch onto master branch This would cause: A---B---C topic / D---E---F---G...
from itertools import imap from future_builtins import map as fmap # Different name to highlight differences image = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] list(map(None, *image)) # Out: [(1, 4, 7), (2, 5, 8), (3, 6, 9)] list(fmap(None, *image)) # Out: [(1, 4, 7), (2, 5, 8),...
Abbreviated from https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/: Step 1: Begin authorization Send the user to this web page, with your values filled in: https://www.dropbox.com/oauth2/authorize?client_id=<app key>&response_type=code&redirect_uri=<...
R has several built-in functions that can be used to print or display information, but print and cat are the most basic. As R is an interpreted language, you can try these out directly in the R console: print("Hello World") #[1] "Hello World" cat("Hello World\n") #H...
A submodule is always checked out at a specific commit SHA1 (the "gitlink", special entry in the index of the parent repo) But one can request to update that submodule to the latest commit of a branch of the submodule remote repo. Rather than going in each submodule, doing a git checkout...
You can use the trap command to "trap" signals; this is the shell equivalent of the signal() or sigaction() call in C and most other programming languages to catch signals. One of the most common uses of trap is to clean up temporary files on both an expected and unexpected exit. Unfortu...

Page 11 of 307