Tutorial by Examples

Using the dateutil library as in the previous example on parsing timezone-aware timestamps, it is also possible to parse timestamps with a specified "short" time zone name. For dates formatted with short time zone names or abbreviations, which are generally ambiguous (e.g. CST, which coul...
By default all datetime objects are naive. To make them timezone-aware, you must attach a tzinfo object, which provides the UTC offset and timezone abbreviation as a function of date and time. Fixed Offset Time Zones For time zones that are a fixed offset from UTC, in Python 3.2+, the datetime mod...
It is often helpful to have MATLAB print the 1st line of a function, as this usually contains the function signature, including inputs and outputs: dbtype <functionName> 1 Example: >> dbtype fit 1 1 function [fitobj,goodness,output,warnstr,errstr,convmsg] = fit(xdatain,ydatain,f...
You can commit changes made to specific files and skip staging them using git add: git commit file1.c file2.h Or you can first stage the files: git add file1.c file2.h and commit them later: git commit
The boolean type cannot be cast to/from any other primitive type. A char can be cast to/from any numeric type by using the code-point mappings specified by Unicode. A char is represented in memory as an unsigned 16-bit integer value (2 bytes), so casting to byte (1 byte) will drop 8 of those bits (...
Numeric primitives can be cast in two ways. Implicit casting happens when the source type has smaller range than the target type. //Implicit casting byte byteVar = 42; short shortVar = byteVar; int intVar = shortVar; long longVar = intvar; float floatVar = longVar; double doubleVar = floatVar...
As with primitives, objects can be cast both explicitly and implicitly. Implicit casting happens when the source type extends or implements the target type (casting to a superclass or interface). Explicit casting has to be done when the source type is extended or implemented by the target type (ca...
Note: you need to install Boot before trying this example out. See the Installation and Setup section if you haven't installed it yet. Boot allows making executable Clojure files using shebang (#!) line. Place the following text into a file of your choice (this example assumes it's in the "cur...
In the material design, a Floating action button represents the primary action in an Activity. They are distinguished by a circled icon floating above the UI and have motion behaviors that include morphing, launching, and a transferring anchor point. Make sure the following dependency is added to ...
The simplest use case is using the subprocess.call function. It accepts a list as the first argument. The first item in the list should be the external application you want to call. The other items in the list are arguments that will be passed to that application. subprocess.call([r'C:\path\to\a...
In Angular $scope is the glue between the Controller and the View that helps with all of our data binding needs. Controller As is another way of binding controller and view and is mostly recommended to use. Basically these are the two controller constructs in Angular (i.e $scope and Controller As). ...
For cases when we don't want to write special classes to handle some resource, we may write a generic class: template<typename Function> class Finally final { public: explicit Finally(Function f) : f(std::move(f)) {} ~Finally() { f(); } // (1) See below Finally(const Final...
It is possible to extract a date out of a text using the dateutil parser in a "fuzzy" mode, where components of the string not recognized as being part of a date are ignored. from dateutil.parser import parse dt = parse("Today is January 1, 2047 at 8:21:00AM", fuzzy=True) pr...
A tbl_df (pronounced tibble diff) is a variation of a data frame that is often used in tidyverse packages. It is implemented in the tibble package. Use the as_data_frame function to turn a data frame into a tbl_df: library(tibble) mtcars_tbl <- as_data_frame(mtcars) One of the most notable ...
Although it is possible to create a fragment constructor with parameters, Android internally calls the zero-argument constructor when recreating fragments (for example, if they are being restored after being killed for Android's own reasons). For this reason, it is not advisable to rely on a constru...
C++11 inline namespace includes the content of the inlined namespace in the enclosing namespace, so namespace Outer { inline namespace Inner { void foo(); } } is mostly equivalent to namespace Outer { namespace Inner { void foo(); } u...
let string1 = "Hello" //simple string let string2 = "Line\nNewLine" //string with newline escape sequence let string3 = @"Line\nSameLine" //use @ to create a verbatim string literal let string4 = @"Line""with""quoutes inside" //dou...
When trying to select from a table called order like this select * from order the error rises: Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order' at line 1 Reserved keywords in MySQ...
Each enum class contains an implicit static method named values(). This method returns an array containing all values of that enum. You can use this method to iterate over the values. It is important to note however that this method returns a new array every time it is called. public enum Day { ...
Lambda expressions can be used to handle events, which is useful when: The handler is short. The handler never needs to be unsubscribed. A good situation in which a lambda event handler might be used is given below: smtpClient.SendCompleted += (sender, args) => Console.WriteLine("Ema...

Page 172 of 1336