Tutorial by Examples

You can list existing git aliases using --get-regexp: $ git config --get-regexp '^alias\.' Searching aliases To search aliases, add the following to your .gitconfig under [alias]: aliases = !git config --list | grep ^alias\\. | cut -c 7- | grep -Ei --color \"$1\" "#" The...
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: ...
dict have no builtin method for searching a value or key because dictionaries are unordered. You can create a function that gets the key (or keys) for a specified value: def getKeysForValue(dictionary, value): foundkeys = [] for keys in dictionary: if dictionary[key] == value: ...
Sorted sequences allow the use of faster searching algorithms: bisect.bisect_left()1: import bisect def index_sorted(sorted_seq, value): """Locate the leftmost value exactly equal to x or raise a ValueError""" i = bisect.bisect_left(sorted_seq, value) ...
Searching in nested sequences like a list of tuple requires an approach like searching the keys for values in dict but needs customized functions. The index of the outermost sequence if the value was found in the sequence: def outer_index(nested_sequence, value): return next(index for index, ...
Let's say we have a query of the remaining horsemen that needs to populate a Person class. NameBornResidenceDaniel Dennett1942United States of AmericaSam Harris1967United States of AmericaRichard Dawkins1941United Kingdom public class Person { public string Name { get; set; } public int...
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...
If the query column names do not match your classes you can setup mappings for types. This example demonstrates mapping using System.Data.Linq.Mapping.ColumnAttributeas well as a custom mapping. The mappings only need to be setup once per type so set them on application startup or somewhere else ...
First, install a version of Microsoft Visual Studio, including the free Community edition. Then, create a Visual Basic Console Application project of type Console Application, and the following code will print the string 'Hello World' to the Console: Module Module1 Sub Main() Consol...
CSS enclosed in <style></style> tags within an HTML document functions like an external stylesheet, except that it lives in the HTML document it styles instead of in a separate file, and therefore can only be applied to the document in which it lives. Note that this element must be insid...
Use inline styles to apply styling to a specific element. Note that this is not optimal. Placing style rules in a <style> tag or external CSS file is encouraged in order to maintain a distinction between content and presentation. Inline styles override any CSS in a <style> tag or extern...
To check the equality of Date values: var date1 = new Date(); var date2 = new Date(date1.valueOf() + 10); console.log(date1.valueOf() === date2.valueOf()); Sample output: false Note that you must use valueOf() or getTime() to compare the values of Date objects because the equality operato...
Using the Cars Table, we will calculate the total, max, min and average amount of money each costumer spent and haw many times (COUNT) she brought a car for repairing. Id CustomerId MechanicId Model Status Total Cost SELECT CustomerId, SUM(TotalCost) OVER(PARTITION BY Cust...
Using the Item Sales Table, we will try to find out how the sales of our items are increasing through dates. To do so we will calculate the Cumulative Sum of total sales per Item order by the sale date. SELECT item_id, sale_Date SUM(quantity * price) OVER(PARTITION BY item_id ORDER BY sale...
When the Repeater is Bound, for each item in the data, a new table row will be added. <asp:Repeater ID="repeaterID" runat="server" OnItemDataBound="repeaterID_ItemDataBound"> <HeaderTemplate> <table> <thead> ...
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...
ALTER TABLE Employees ADD StartingDate date NOT NULL DEFAULT GetDate(), DateOfBirth date NULL The above statement would add columns named StartingDate which cannot be NULL with default value as current date and DateOfBirth which can be NULL in Employees table.

Page 44 of 1336