Tutorial by Examples

Trying to use several traits into one class could result in issues involving conflicting methods. You need to resolve such conflicts manually. For example, let's create this hierarchy: trait MeowTrait { public function say() { print "Meow \n"; } } trait WoofTrait {...
Note: it's strongly advised to use Composer. The instruction below is basically what Composer does for you. Download archive extension file of needed version from Github Open composer.json Find PSR-4 autoload section and remember it for e.g. kmit/select2 Extract files to corresponding fold...
() is a Monoid. Since there is only one value of type (), there's only one thing mempty and mappend could do: instance Monoid () where mempty = () () `mappend` () = ()
To create the classic "Hello, world" printing program, create a file called hello.d with a text editor containing the following code : import std.stdio; void main() { writeln("Hello, World!"); //writeln() automatically adds a newline (\n) to the output } Explanati...
SharedPreferences allows you to store primitive data types only (boolean, float, long, int, String, and string set). You cannot store more complex objects in SharedPreferences, and as such is really meant to be a place to store user settings or similar, it's not meant to be a database to keep user d...
public class Customer { public void SendEmail() { // Sending email code here } } List<Customer> customers = new List<Customer>(); customers.Add(new Customer()); customers.Add(new Customer()); customers.ForEach(c => c.SendEmail());
ForEach() is defined on the List<T> class, but not on IQueryable<T> or IEnumerable<T>. You have two choices in those cases: ToList first The enumeration (or query) will be evaluated, copying the results into a new list or calling the database. The method is then called on each it...
Install Codeception: composer global status composer global require "codeception/codeception=~2.0.0" "codeception/specify=*" "codeception/verify=*" Install Faker: cd /var/www/yii // Path to your application composer require --de...
If you need to count distinct characters then, for the reasons explained in Remarks section, you can't simply use Length property because it's the length of the array of System.Char which are not characters but code-units (not Unicode code-points nor graphemes). If, for example, you simply write tex...
If you need to count characters then, for the reasons explained in Remarks section, you can't simply use Length property because it's the length of the array of System.Char which are not characters but code-units (not Unicode code-points nor graphemes). Correct code is then: int length = text.Enume...
Because of the reasons explained in Remarks section you can't simply do this (unless you want to count occurrences of a specific code-unit): int count = text.Count(x => x == ch); You need a more complex function: public static int CountOccurrencesOf(this string text, string character) { ...
We cannot break a string into arbitrary points (because a System.Char may not be valid alone because it's a combining character or part of a surrogate) then code must take that into account (note that with length I mean the number of graphemes not the number of code-units): public static IEnumerabl...
.NET strings contain System.Char (UTF-16 code-units). If you want to save (or manage) text with another encoding you have to work with an array of System.Byte. Conversions are performed by classes derived from System.Text.Encoder and System.Text.Decoder which, together, can convert to/from another ...
There is no need to create the whole UI in a single FXML using a single controller. The <fx:include> tag can be used to include one fxml file into another. The controller of the included fxml can be injected into the controller of the including file just as any other object created by the FXM...
Sometimes a element needs to be created outside of the usual object structure in the fxml. This is where Define Blocks come into play: Contents inside a <fx:define> element are not added to the object created for the parent element. Every child element of the <fx:define> needs a fx:id...
If there are no specific needs, choose x86_64 system images with Google APIs to create the emulator. It works way faster than armeabi-v7a on intel x86 x64 based computers. There are some SDK libraries compiled and designed with ARM architecture. If you try to install them on Intel based emulators...
Table Item The following class contains 2 properties a name (String) and the size (double). Both properties are wrapped in JavaFX properties to allow the TableView to observe changes. import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.be...
PropertyValueFactory can be used as cellValueFactory in a TableColumn. It uses reflection to access methods that match a certain pattern to retrieve the data from a TableView item: Example TableColumn<Person, String> nameColumn = ... PropertyValueFactory<Person, String> valueFactory =...
The following example encrypts data by using a hybrid cryptosystem consisting of AES GCM and OAEP, using their default parameter sizes and an AES key size of 128 bits. OAEP is less vulnerable to padding oracle attacks than PKCS#1 v1.5 padding. GCM is also protected against padding oracle attacks. ...
Long-running operations must not be run on the JavaFX application thread, since this prevents JavaFX from updating the UI, resulting in a frozen UI. Furthermore any change to a Node that is part of a "live" scene graph must happen on the JavaFX application thread. Platform.runLater can be...

Page 274 of 1336