Tutorial by Examples: e

db.collection.createIndex( { "user_id": 1 }, { unique: true } ) enforce uniqueness on the defined index (either single or compound). Building the index will fail if the collection already contains duplicate values; the indexing will fail also with multiple entries missing the field (sin...
This solution uses the ora:tokenize XQuery function that is available from Oracle 11. 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 ...
Useful information The very beginning of the text field text: let startPosition: UITextPosition = textField.beginningOfDocument The very end of the text field text: let endPosition: UITextPosition = textField.endOfDocument The currently selected range: let selectedRange: UITextRange? = tex...
Edit /etc/init/docker.conf and update the DOCKER_OPTS variable to the following: DOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock' Restart Docker deamon service docker restart Verify if Remote API is working curl -X GET http://localhost:4243/images/json
The system_clock can be used to measure the time elapsed during some part of a program's execution. c++11 #include <iostream> #include <chrono> #include <thread> int main() { auto start = std::chrono::system_clock::now(); // This and "end"'s type is std::chron...
This example shows how a function can accept pipelined input, and iterate efficiently. Note, that the begin and end structures of the function are optional when pipelining, but that process is required when using ValueFromPipeline or ValueFromPipelineByPropertyName. function Write-FromPipeline{ ...
This is an example of a function with the simplest possible support for pipelining. Any function with pipeline support must have at least one parameter with the ParameterAttribute ValueFromPipeline or ValueFromPipelineByPropertyName set, as shown below. function Write-FromPipeline { param( ...
Prevent access to your .htaccess file <Files .htaccess> order allow,deny deny from all </Files> # Rename the file AccessFileName thehtfile.ess Prevent URL attacks # Enable rewrites RewriteEngine On # Block <script> tags from executing in the URL RewriteCond %{QUE...
This is a simple example to display read-only data that is tabular in nature using Qt's Model/View Framework. Specifically, the Qt Objects QAbstractTableModel (sub-classed in this example) and QTableView are used. Implementations of the methods rowCount(), columnCount(), data() and headerData() are...
With generics, it's possible to return whatever the caller expects: private Map<String, Object> data; public <T> T get(String key) { return (T) data.get(key); } The method will compile with a warning. The code is actually more safe than it looks because the Java runtime will d...
Use case scenario: A table view consists of different columns with different data format that needs to be transformed with different pipes. table.component.ts ... import { DYNAMIC_PIPES } from '../pipes/dynamic.pipe.ts'; @Component({ ... pipes: [DYNAMIC_PIPES] }) export class Tabl...
Assuming we have a TravelReview table with City names as column "title" Criteria criteria = session.createCriteria(TravelReview.class); List review = criteria.add(Restrictions.eq("title", "Mumbai")).list(); System.out.println("Using equals: "...
Should we wish to retrieve only a few columns, we can use the Projections class to do so. For example, the following code retrieves the title column // Selecting all title columns List review = session.createCriteria(TravelReview.class) .setProjection(Projections.property("titl...
Destructuring allows you to extract data from various objects into distinct variables. In each example below, each variable is assigned to its own string (a="a", b="b", &c.) TypeExampleValue of data / commentvec(let [[a b c] data ...)["a" "b" "c&quot...
Rust tuples, as in most other languages, are fixed-size lists whose elements can all be of different types. // Tuples in Rust are comma-separated values or types enclosed in parentheses. let _ = ("hello", 42, true); // The type of a tuple value is a type tuple with the same number of el...
Rust programs use pattern matching extensively to deconstruct values, whether using match, if let, or deconstructing let patterns. Tuples can be deconstructed as you might expect using match fn foo(x: (&str, isize, bool)) { match x { (_, 42, _) => println!("it's 42"),...
To access elements of a tuple directly, you can use the format .n to access the n-th element let x = ("hello", 42, true); assert_eq!(x.0, "hello"); assert_eq!(x.1, 42); assert_eq!(x.2, true); You can also partially move out of a tuple let x = (String::from("hello&quo...
Storing Properties in a XML File The way you store properties files as XML files is very similar to the way you would store them as .properties files. Just instead of using the store() you would use storeToXML(). public void saveProperties(String location) throws IOException{ // make new inst...
This example discusses extending the below type class. trait Show[A] { def show: String } To make a class you control (and is written in Scala) extend the type class, add an implicit to its companion object. Let us show how we can get the Person class from this example to extend Show: class...
If we just try the following: import json from datetime import datetime data = {'datetime': datetime(2016, 9, 26, 4, 44, 0)} print(json.dumps(data)) we get an error saying TypeError: datetime.datetime(2016, 9, 26, 4, 44) is not JSON serializable. To be able to serialize the datetime object p...

Page 467 of 1191