Tutorial by Examples

aiohttp.ClientSession may be used as a parent for a custom WebSocket class. Python 3.x3.5 import asyncio from aiohttp import ClientSession class EchoWebSocket(ClientSession): URL = "wss://echo.websocket.org" def __init__(self): super().__init__() self....
6 In ECMAScript 6, when using the module syntax (import/export), each file becomes its own module with a private namespace. Top-level functions and variables do not pollute the global namespace. To expose functions, classes, and variables for other modules to import, you can use the export keyword....
The C++11 standard is a major extension to the C++ standard. Below you can find an overview of the changes as they have been grouped on the isocpp FAQ with links to more detailed documentation. Language Extensions General Features auto decltype Range-for statement Initializer lists Uniform ...
Apart from types as a template parameter we are allowed to declare values of constant expressions meeting one of the following criteria: integral or enumeration type, pointer to object or pointer to function, lvalue reference to object or lvalue reference to function, pointer to member, st...
can either pass string of the json, or a filepath to a file with valid json In [99]: pd.read_json('[{"A": 1, "B": 2}, {"A": 3, "B": 4}]') Out[99]: A B 0 1 2 1 3 4 Alternatively to conserve memory: with open('test.json') as f: data = pd.Da...
def to_flare_json(df, filename): """Convert dataframe into nested JSON as in flare files used for D3.js""" flare = dict() d = {"name":"flare", "children": []} for index, row in df.iterrows(): parent = row[...
By default, npm installs the latest available version of modules according to each dependencies' semantic version. This can be problematic if a module author doesn't adhere to semver and introduces breaking changes in a module update, for example. To lock down each dependencies' version (and the ve...
There are two ways to create object mocked by Mockito: via annotation via mock function Via annotation: With a JUnit test runner: @RunWith(MockitoJUnitRunner.class) public class FooTest { @Mock private Bar barMock; // ... } You can also use Mockito's JUnit @Rule, which...
Mockito.when(mock.returnSomething()).thenReturn("my val"); mock.returnSomething(); // returns "my val" mock.returnSomething(); // returns "my val" again mock.returnSomething(); // returns "my val" again and again and again... If you want different valu...
There have been many releases of Java since the original Java 1.0 release in 1995. (Refer to Java version history for a summary.) However most releases have passed their official End Of Life dates. This means that the vendor (typically Oracle now) has ceased new development for the release, and n...
One method for creating recursive lambda functions involves assigning the function to a variable and then referencing that variable within the function itself. A common example of this is the recursive calculation of the factorial of a number - such as shown in the following code: lambda_factorial ...
Firstly you have to add Xamarin.Android.Support.V7.AppCompat library for NuGet: https://www.nuget.org/packages/Xamarin.Android.Support.v7.AppCompat/ In the "values" folder under "Resources" add new xml file called "styles.xml": "styles.xml" file should co...
Input record separator can be specified with -0 switch (zero, not capital O). It takes an octal or hexadecimal number as value. Any value 0400 or above will cause Perl to slurp files, but by convention, the value used for this purpose is 0777. perl -0777 -e 'my $file = <>; print length($file)...
In order to start using Sequelize, you must first install the Sequelize package using the Node Package Manager (npm). Install sequelize module Add --save option to store module in package.json npm install sequelize Next, depending on which database system you wish to use with Sequelize, instal...
%paste This is the primary Magic Method for pasting. It directly pastes text from the system clipboard, intelligently handling common issues with newlines and indentation. %cpaste If you are using IPython via SSH, use %cpaste instead, as it does not need to access the remote system clipbo...
Sometimes it's useful to check if a field is present or absent on your JSON to avoid some JSONException on your code. To achieve that, use the JSONObject#has(String) or the method, like on the following example: Sample JSON { "name":"James" } Java code String jsonStr...
Java release naming is a little confusing. There are actually two systems of naming and numbering, as shown in this table: JDK versionMarketing namejdk-1.0JDK 1.0jdk-1.1JDK 1.1jdk-1.2J2SE 1.2......jdk-1.5J2SE 1.5 rebranded Java SE 5jdk-1.6Java SE 6jdk-1.7Java SE 7jdk-1.8Java SE 8jdk-91Java SE 9 (n...
Bootstrap provides multiple classes for styling buttons and making them stand out. Bootstrap buttons can be created by adding the .btn class to an element. Bootstrap ClassRole (color).btn-defaultStandard button (white).btn-primaryProvides extra visual weight and identifies the primary action (blue...
I won't explain what Any and FirstOrDefault does because there are already two good example about them. See Any and First, FirstOrDefault, Last, LastOrDefault, Single, and SingleOrDefault for more information. A pattern I often see in code which should be avoided is if (myEnumerable.Any(t=>t.Fo...
public string GetCustomerNamesCsv() { List<CustomerData> customerDataRecords = GetCustomerData(); // Returns a large number of records, say, 10000+ StringBuilder customerNamesCsv = new StringBuilder(); foreach (CustomerData record in customerDataRecords) { custom...

Page 648 of 1336