Tutorial by Examples: v

@Test public void testUpNavigation() { intending(hasComponent(ParentActivity.class.getName())).respondWith(new Instrumentation.ActivityResult(0, null)); onView(withContentDescription("Navigate up")).perform(click()); intended(hasComponent(ParentActivity.class.getName())...
A variable declared constexpr is implicitly const and its value may be used as a constant expression. Comparison with #define A constexpr is type-safe replacement for #define based compile-time expressions. With constexpr the compile-time evaluated expression is replaced with the result. For examp...
class (Functor t, Foldable t) => Traversable t where {-# MINIMAL traverse | sequenceA #-} traverse :: Applicative f => (a -> f b) -> t a -> f (t b) traverse f = sequenceA . fmap f sequenceA :: Applicative f => t (f a) -> f (t a) sequenceA = t...
To calculate moving average of salary of the employers based on their role: val movAvg = sampleData.withColumn("movingAverage", avg(sampleData("Salary")) .over( Window.partitionBy("Role").rowsBetween(-1,1)) ) withColumn() creates a new column named m...
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://sche...
By default the Custom Tool property for a VB resource file is VbMyResourcesResXFileCodeGenerator. However, with this code generator the view (XAML) will not be able to access the resources. To solve this problem add Public before the Custom Tool property value. To select the Resources.resx file in ...
Computed observables are functions that can "watch" or "react" to other observables on the view model. The following example shows how you would display the total number of users and the average age. Note: The example below can also make use of pureComputed() (introduced in v3....
Conversion SpecifierType of ArgumentDescriptioni, dintprints decimaluunsigned intprints decimalounsigned intprints octalxunsigned intprints hexadecimal, lower-caseXunsigned intprints hexadecimal, upper-casefdoubleprints float with a default precision of 6, if no precision is given (lower-case used f...
// long form String sayHello(String name){ "Hello, ${name ? name : 'stranger'}." } // elvis String sayHello(String name){ "Hello, ${name ?: 'stranger'}." } Notice that the "elvis" format omits the "true" term because the original comparison...
Test methods often need data to be tested with. To test some methods completely you need to provide different data sets for every possible test condition. Of course, you can do it manually using loops, like this: ... public function testSomething() { $data = [...]; foreach($data as $dat...
Below is an example of a pure Xamarin Forms custom control. No custom rendering is being done for this but could easily be implemented, in fact, in my own code, I use this very same control along with a custom renderer for both the Label and Entry. The custom control is a ContentView with a Label, ...
EntryPage.xaml: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:vm="clr-namespace:MyAssembly.ViewModel;a...
Redis keys are binary-safe, so literally anything can be used as a key. The only limitations are that they must be less than 512MB. Examples of valid keys: 7 ++++ `~!@#$%^&*()-_=+ user:10134 search/9947372/?query=this%20is%20a%28test%29%20query <div id="div64"> Any othe...
IPython has two parts to it: A command line interface that replaces the default python REPL and a way to run Python through the web browser as a graphical user interface. With the latest developments the browser part has been split into the Jupyter project that enables multiple programming language...
The System.String.Trim method can be used to remove all leading and trailing white-space characters from a string: string s = " String with spaces at both ends "; s = s.Trim(); // s = "String with spaces at both ends" In addition: To remove white-space only fro...
In some cases we need to apply functions to a set of ND-arrays. Let's look at this simple example. A(:,:,1) = [1 2; 4 5]; A(:,:,2) = [11 22; 44 55]; B(:,:,1) = [7 8; 1 2]; B(:,:,2) = [77 88; 11 22]; A = ans(:,:,1) = 1 2 4 5 ans(:,:,2) = 11 22 44 55 >&...
Add the required network permissions to the application manifest file: <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android....
The %s conversion of printf states that the corresponding argument a pointer to the initial element of an array of character type. A null pointer does not point to the initial element of any array of character type, and thus the behavior of the following is undefined: char *foo = NULL; printf(&quo...
Read a file all at once (not recommended for large files): (slurp "./small_file.txt") Write data to a file all at once: (spit "./file.txt" "Ocelots are Awesome!") ; overwrite existing content (spit "./log.txt" "2016-07-26 New entry." :append...
Define Interface public interface ClickHandler { public void onButtonClick(User user); } Create Model class public class User { private String name; public User(String name) { this.name = name; } public String getName() { return name; } ...

Page 110 of 296