Tutorial by Examples: ase

ConnectionMultiplexer conn = /* initialization */; var profiler = new ToyProfiler(); conn.RegisterProfiler(profiler); var threads = new List<Thread>(); var perThreadTimings = new ConcurrentDictionary<Thread, List<IProfiledCommand>>(); for (var i = 0; i < 16; i++) {...
To fetch multiple grids in a single query, the QueryMultiple method is used. This then allows you to retrieve each grid sequentially through successive calls against the GridReader returned. var sql = @"select * from Customers where CustomerId = @id select * from Orders where Cust...
A constructor of a base class is called before a constructor of a derived class is executed. For example, if Mammal extends Animal, then the code contained in the constructor of Animal is called first when creating an instance of a Mammal. If a derived class doesn't explicitly specify which constru...
To avoid duplicating code, define common methods and attributes in a general class as a base: public class Animal { public string Name { get; set; } // Methods and attributes common to all animals public void Eat(Object dinner) { // ... } public void Stare()...
SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine(); GrammarBuilder builder = new GrammarBuilder(); builder.Append(new Choices("I am", "You are", "He is", "She is", "We are", "They are")); builder.Append(new Choices...
Unlike interfaces, which can be described as contracts for implementation, abstract classes act as contracts for extension. An abstract class cannot be instantiated, it must be extended and the resulting class (or derived class) can then be instantiated. Abstract classes are used to provide generi...
var sequenceOfSequences = new [] { new [] { 1, 2, 3 }, new [] { 4, 5 }, new [] { 6 } }; var sequence = sequenceOfSequences.SelectMany(x => x); // returns { 1, 2, 3, 4, 5, 6 } Use SelectMany() if you have, or you are creating a sequence of sequences, but you want the result as one long sequen...
The String type provides two methods for converting strings between upper case and lower case: toUpperCase to convert all characters to upper case toLowerCase to convert all characters to lower case These methods both return the converted strings as new String instances: the original String o...
Starting a service is very easy, just call startService with an intent, from within an Activity: Intent intent = new Intent(this, MyService.class); //substitute MyService with the name of your service intent.putExtra(Intent.EXTRA_TEXT, "Some text"); //add any extra data to pass to the s...
One use of SharedPreferences is to implement a "Settings" screen in your app, where the user can set their preferences / options. Like this: A PreferenceScreen saves user preferences in SharedPreferences. To create a PreferenceScreen, you need a few things: An XML file to define the av...
Getting the minimum or maximum or using sorted depends on iterations over the object. In the case of dict, the iteration is only over the keys: adict = {'a': 3, 'b': 5, 'c': 1} min(adict) # Output: 'a' max(adict) # Output: 'c' sorted(adict) # Output: ['a', 'b', 'c'] To keep the dictionary ...
Getting the minimum of a sequence (iterable) is equivalent of accessing the first element of a sorted sequence: min([2, 7, 5]) # Output: 2 sorted([2, 7, 5])[0] # Output: 2 The maximum is a bit more complicated, because sorted keeps order and max returns the first encountered value. In case th...
str.split(sep=None, maxsplit=-1) str.split takes a string and returns a list of substrings of the original string. The behavior differs depending on whether the sep argument is provided or omitted. If sep isn't provided, or is None, then the splitting takes place wherever there is whitespace. Howe...
In the following example - Database for an auto shop business, we have a list of departments, employees, customers and customer cars. We are using foreign keys to create relationships between the various tables. Live example: SQL fiddle Relationships between tables Each Department may have 0 ...
# First falsy element or last element if all are truthy: reduce(lambda i, j: i and j, [100, [], 20, 10]) # = [] reduce(lambda i, j: i and j, [100, 50, 20, 10]) # = 10 # First truthy element or last element if all falsy: reduce(lambda i, j: i or j, [100, [], 20, 0]) # = 100 reduce(la...
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....
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...
alias -p will list all the current aliases.
Column aliases are used mainly to shorten code and make column names more readable. Code becomes shorter as long table names and unnecessary identification of columns (e.g., there may be 2 IDs in the table, but only one is used in the statement) can be avoided. Along with table aliases this allows ...
Dropbox.authorizedClient!.files.download(path: path, destination: destination).response { response, error in if let (metadata, url) = response { print("*** Download file ***") print("Downloaded file name: \(metadata.name)") print("Downloaded f...

Page 1 of 40