Tutorial by Examples: c

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` () = ()
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());
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...
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. ...
Simple struct C++ signature: typedef struct _PERSON { int age; char name[32]; } PERSON, *LP_PERSON; void GetSpouse(PERSON person, LP_PERSON spouse); C# definition [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct PERSON { public int age; [Ma...
vim is a modal editor. This means that at any time inside a vim session, the user is going to be in one of the modes of operation. Each one of offers a different set commands, operations, key bindings... Normal mode (or Command mode) The mode vim starts in. From other modes, usually accessible ...
The below examples use the new form API introduced in RC3. pw-change.template.html <form class="container" [formGroup]="pwChangeForm"> <label for="current">Current Password</label> <input id="current" formControlName="curr...
In Java, there is a built-in language-level locking mechanism: the synchronized block, which can use any Java object as an intrinsic lock (i.e. every Java object may have a monitor associated with it). Intrinsic locks provide atomicity to groups of statements. To understand what that means for us, ...
An atomic operation is an operation that is executed "all at once", without any chance of other threads observing or modifying state during the atomic operation's execution. Lets consider a BAD EXAMPLE. private static int t = 0; public static void main(String[] args) { ExecutorSe...

Page 169 of 826