Tutorial by Examples: ee

With this declaration: fun Temporal.toIsoString(): String = DateTimeFormatter.ISO_INSTANT.format(this) You can now simply: val dateAsString = someInstant.toIsoString()
Sample Data: CREATE TABLE table_name ( id, list ) AS SELECT 1, 'a,b,c,d' FROM DUAL UNION ALL -- Multiple items in the list SELECT 2, 'e' FROM DUAL UNION ALL -- Single item in the list SELECT 3, NULL FROM DUAL UNION ALL -- NULL list SELECT 4, 'f,,g' FROM DUAL; -- NULL item...
Common table expressions support extracting portions of larger queries. For example: WITH sales AS ( SELECT orders.ordered_at, orders.user_id, SUM(orders.amount) AS total FROM orders GROUP BY orders.ordered_at, orders.user_id ) SELECT sales.ordered_at, sales.total,...
Two Random class created at the same time will have the same seed value. Using System.Guid.NewGuid().GetHashCode() can get a different seed even in the same time. Random rnd1 = new Random(); Random rnd2 = new Random(); Console.WriteLine("First 5 random number in rnd1"); for (int i = 0...
An enumeration is a user-defined data type consists of integral constants and each integral constant is given a name. Keyword enum is used to define enumerated data type. If you use enum instead of int or string/ char*, you increase compile-time checking and avoid errors from passing in invalid con...
A common usage scenario that this feature really helps with is when you are looking for an object in a collection and need to create a new one if it does not already exist. IEnumerable<MyClass> myList = GetMyList(); var item = myList.SingleOrDefault(x => x.Id == 2) ?? new MyClass { Id = 2...
Defining a method in Ruby 2.x returns a symbol representing the name: class Example puts def hello end end #=> :hello This allows for interesting metaprogramming techniques. For instance, methods can be wrapped by other methods: class Class def logged(name) original_method...
Using random.seed: np.random.seed(0) np.random.rand(5) # Out: array([ 0.5488135 , 0.71518937, 0.60276338, 0.54488318, 0.4236548 ]) By creating a random number generator object: prng = np.random.RandomState(0) prng.rand(5) # Out: array([ 0.5488135 , 0.71518937, 0.60276338, 0.54488318,...
1) BASIC SIMPLE WAY Database-driven applications often need data pre-seeded into the system for testing and demo purposes. To make such data, first create the seeder class ProductTableSeeder use Faker\Factory as Faker; use App\Product; class ProductTableSeeder extends DatabaseSeeder { pub...
The RewriteEngine module within Apache is used to dynamically rewrite URLs and paths depending on various expressions provided: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
sqldf() from the package sqldf allows the use of SQLite queries to select and manipulate data in R. SQL queries are entered as character strings. To select the first 10 rows of the "diamonds" dataset from the package ggplot2, for example: data("diamonds") head(diamonds) #...
Say we have the following tree: root - A - AA - AB - B - BA - BB - BBA Now, if we wish to list all the names of the elements, we could do this with a simple for-loop. We assume there is a function get_name() to return a string of the name of a node, a function get_children() t...
Number of unique elements in a series: In [1]: id_numbers = pd.Series([111, 112, 112, 114, 115, 118, 114, 118, 112]) In [2]: id_numbers.nunique() Out[2]: 5 Get unique elements in a series: In [3]: id_numbers.unique() Out[3]: array([111, 112, 114, 115, 118], dtype=int64) In [4]: df = pd.Da...
Who says you cannot throw multiple exceptions in one method. If you are not used to playing around with AggregateExceptions you may be tempted to create your own data-structure to represent many things going wrong. There are of course were another data-structure that is not an exception would be mor...
In the app folder find package.json and modify the following line to include the latest version, save the file and close. "react-native": "0.32.0" In terminal: $ npm install Followed by $ react-native upgrade
From ES5.1 onwards, you can use the native method Array.prototype.filter to loop through an array and leave only entries that pass a given callback function. In the following example, our callback checks if the given value occurs in the array. If it does, it is a duplicate and will not be copied to...
/** * The buildscript {} block is where you configure the repositories and * dependencies for Gradle itself--meaning, you should not include dependencies * for your modules here. For example, this block includes the Android plugin for * Gradle as a dependency because it provides the addition...
/** * The first line in the build configuration applies the Android plugin for * Gradle to this build and makes the android {} block available to specify * Android-specific build options. */ apply plugin: 'com.android.application' /** * The android {} block is where you configure all...
In Python you can compare a single element using two binary operators--one on either side: if 3.14 < x < 3.142: print("x is near pi") In many (most?) programming languages, this would be evaluated in a way contrary to regular math: (3.14 < x) < 3.142, but in Python it ...
Factories can be used in conjunction with Inversion of Control (IoC) libraries too. The typical use case for such a factory is when we want to create an object based on parameters that are not known until run-time (such as the current User). In these cases it can be sometimes be difficult (if no...

Page 9 of 54