Tutorial by Examples: ai

In the process of handling an exception, you may want to raise another exception. For example, if you get an IOError while reading from a file, you may want to raise an application-specific error to present to the users of your library, instead. Python 3.x3.0 You can chain exceptions to show how t...
Inspecting system resource usage is an efficient way to narrow down a problem on a live running application. This example is an equivalent of the traditional ps command for containers. docker top 7786807d8084 To filter of format the output, add ps options on the command line: docker top 7786807...
'Attaching to a container' is the act of starting a terminal session within the context that the container (and any programs therein) is running. This is primarily used for debugging purposes, but may also be needed if specific data needs to be passed to programs running within the container. The a...
When the last parameter of a function is a closure func loadData(id: String, completion:(result: String) -> ()) { // ... completion(result:"This is the result data") } the function can be invoked using the Trailing Closure Syntax loadData("123") { result in ...
Trailing spaces \s*$: This will match any (*) whitespace (\s) at the end ($) of the text Leading spaces ^\s*: This will match any (*) whitespace (\s) at the beginning (^) of the text Remarks \s is a common metacharacter for several RegExp engines, and is meant to capture whitespace characters (...
Pass data in native Python form, for example list, dict, str, None, bool, etc. IceCream.objects.create(metadata={ 'date': '1/1/2016', 'ordered by': 'Jon Skeet', 'buyer': { 'favorite flavor': 'vanilla', 'known for': ['his rep on SO', 'writing a book'] }, ...
Python 2.x2.7 "1deadbeef3".decode('hex') # Out: '\x1d\xea\xdb\xee\xf3' '\x1d\xea\xdb\xee\xf3'.encode('hex') # Out: 1deadbeef3 Python 3.x3.0 "1deadbeef3".decode('hex') # Traceback (most recent call last): # File "<stdin>", line 1, in <module> ...
Let's say you have a vector like so: (def my-vec [1 2 3 4 5 6]) And you want to extract the first 3 elements and get the remaining elements as a sequence. This can be done as follows: (let [[x y z & remaining] my-vec] (println "first:" x ", second:" y "third:&quot...
If the values in a container have certain operators already overloaded, std::sort can be used with specialized functors to sort in either ascending or descending order: C++11 #include <vector> #include <algorithm> #include <functional> std::vector<int> v = {5,1,2,4,3};...
Managed resources are resources that the runtime's garbage collector is aware and under control of. There are many classes available in the BCL, for example, such as a SqlConnection that is a wrapper class for an unmanaged resource. These classes already implement the IDisposable interface -- it's u...
This design pattern is useful for generating a sequence of asynchronous actions from a list of elements. There are two variants : the "then" reduction, which builds a chain that continues as long as the chain experiences success. the "catch" reduction, which builds a chain t...
There is also a way to have a single method accept a covariant argument, instead of having the whole trait covariant. This may be necessary because you would like to use T in a contravariant position, but still have it covariant. trait LocalVariance[T]{ /// ??? throws a NotImplementedError de...
If no ordering function is passed, std::sort will order the elements by calling operator< on pairs of elements, which must return a type contextually convertible to bool (or just bool). Basic types (integers, floats, pointers etc) have already build in comparison operators. We can overload this ...
// Include sequence containers #include <vector> #include <deque> #include <list> // Insert sorting algorithm #include <algorithm> class Base { public: // Constructor that set variable to the value of v Base(int v): variable(v) { } i...
C++11 // Include sequence containers #include <vector> #include <deque> #include <list> #include <array> #include <forward_list> // Include sorting algorithm #include <algorithm> class Base { public: // Constructor that set variable to the va...
Alamofire.request(.GET, "https://httpbin.org/get") .validate() .responseString { response in print("Response String: \(response.result.value)") } .responseJSON { response in print("Response JSON: \(response.result.value)") ...
The await keyword was added as part of C# 5.0 release which is supported from Visual Studio 2012 onwards. It leverages Task Parallel Library (TPL) which made the multi-threading relatively easier. The async and await keywords are used in pair in the same function as shown below. The await keyword is...
You need to find out the IP address of the container running in the host so you can, for example, connect to the web server running in it. docker-machine is what is used on MacOSX and Windows. Firstly, list your machines: $ docker-machine ls NAME ACTIVE DRIVER STATE URL ...
When Flash makes a request for data from an external source, that operation is asynchronous. The most basic explanation of what this means is that the data loads "in the background" and triggers the event handler you allocate to Event.COMPLETE when it is received. This can happen at any po...
Flash will not load data from a domain other than the one your application is running on unless that domain has an XML crossdomain policy either in the root of the domain (e.g. http://somedomain.com/crossdomain.xml) or somewhere that you can target with Security.loadPolicyFile(). The crossdomain.xml...

Page 8 of 47