Tutorial by Examples: er

Using an incorrect format specifier in the first argument to printf invokes undefined behavior. For example, the code below invokes undefined behavior: long z = 'B'; printf("%c\n", z); Here is another example printf("%f\n",0); Above line of code is undefined behavior. %...
In the following examples, we'll be using the following samples: List<Product> Products = new List<Product>() { new Product() { ProductId = 1, Name = "Book nr 1", Price = 25 }, new Product() { ProductId = 2, Name = "Book nr 2&quot...
By default, user input history in IEx do not persist across different sessions. erlang-history adds history support to both the Erlang shell and IEx: git clone [email protected]:ferd/erlang-history.git cd erlang-history sudo make install You can now access your previous inputs using the up and d...
Numbers are monoidal in two ways: addition with 0 as the unit, and multiplication with 1 as the unit. Both are equally valid and useful in different circumstances. So rather than choose a preferred instance for numbers, there are two newtypes, Sum and Product to tag them for the different functional...
Find single record based on id. $model = User::findOne($id); Select single column based on id. $model = User::findOne($id)->name; Retrieve the single record from the database based on condition. $model = User::find()->one(); // give first record $model = User::find()->where(['i...
Implementing the IEnumerable interface allows classes to be enumerated in the same way as BCL collections. This requires extending the Enumerator class which tracks the state of the enumeration. Other than iterating over a standard collection, examples include: Using ranges of numbers based on a...
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...
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...
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...
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) { ...
.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...
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 =...
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...
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...
Press Ctrl + v to enter into visual block mode. Use ↑ / ↓ / j / k to select multiple lines. Press Shift + i and start typing what you want. After you press Esc, the text will be inserted into all the lines you selected. Remember that Ctrl+c is not 100% equivalent to Esc and will not work in this...
Characteristics of properties : Properties that can be retrieved from an object could have the following characteristics, Enumerable Non - Enumerable own While creating the properties using Object.defineProperty(ies), we could set its characteristics except "own". Properties which...

Page 88 of 417