How to implement MongoDB $or operator

Smita Kapse
Updated on 30-Jul-2019 22:30:26

98 Views

Evaluate one or more expressions using the $or operator in MongoDB. Following is the syntax −db.yourCollectionName.find({ $or: [{ "yourFieldName": yourValue1 }, { "yourFieldName": yourValue2} ] } ).pretty();Let us first create a collection with documents −> db.orOperatorDemo.insertOne({"StudentNames":["John", "Carol", "Sam"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6b80a6d78f205348bc61b") } > db.orOperatorDemo.insertOne({"StudentNames":["Robert", "Chris", "David"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6b8266d78f205348bc61c") } > db.orOperatorDemo.insertOne({"StudentNames":["John"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6b8346d78f205348bc61d") }Following is the query to display all documents from a collection with the help of find() method −> db.orOperatorDemo.find().pretty();This will produce the following output −{    "_id" ... Read More

HTML alt Attribute

Chandu yadav
Updated on 30-Jul-2019 22:30:26

179 Views

The alt attribute of element is used to set an alternate text for an area. This alternate text i.e. alt is visible when the image isn’t displayed for reasons like internet, loading issues, errors, etc.Following is the syntax −Here, text is the alt text to be set.Let us now see an example to implement the alt attribute of the element −Example Live Demo Learning Learn these technologies with ease.... OutputIn the above example, we have set the map on the following ... Read More

How To Do Math With Lists in python ?

Sri
Sri
Updated on 30-Jul-2019 22:30:26

7K+ Views

We  not only use lists to store a collection of values, but we also use it to perform some mathematical calculations or operations to do.Example 1import math data = 21.6 print('The floor of 21.6 is:', math.floor(data))OutputThe floor of 21.6 is: 21How To Calculate the Weighted Average of a ListExample 2cost = [0.424, 0.4221, 0.4185, 0.4132, 0.413] cases = [10, 20, 30, 40, 50] cost = [23, 10, 5, 32, 41] weight= [10, 20, 30, 40, 50] for i in range(len(cost)): cost[c] = (cost[i] * weight[i] / sum(weight)) cost = sum(cost) print(cost)Output72.84444444444445Example 3import math degree = 180 radian = math.radians(degree) ... Read More

How to add shadow on text swift?

Sharon Christine
Updated on 30-Jul-2019 22:30:26

566 Views

If you’re developing a game or a kids application or an application where you want to make attractive user interface you must know how to add shadow on text. This will not only makes the text attractive but also it will also enhance the user experience.Here we will see how we can add shadow on text.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “ShadowText”Step 2 − Add label in Main.storyboard and create @IBOutlet of the label and name it lblHelloWorld.Step 3 − Add the below code in your ViewController.swift, add the complete ... Read More

HTML DOM li value Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

84 Views

The Li value property returns/sets the value of the value attribute of a element.SyntaxFollowing is the syntax −Returning value of the value attributeliObject.valueValue of the attribute value setliObject.value = ‘string’Let us see an example for Li value property −Example Live Demo HTML DOM value    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    }    ol{       width: 30%;   ... Read More

C++11 reverse range-based for-loop

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

484 Views

To get the reversed range-based for loop, we have used boost library. This boost library is vepy popular and it has some strong functionalities.Here we can use some array or containers, then by using boost::adaptors::reverse() we can use the range base for loop in reverse order.Example#include #include #include using namespace std; int main() {    std::list x {11, 44, 77, 55, 44, 22, 33, 30, 88, 99, 55, 44};    cout >> "Normal Loop" >> endl;    for (auto i : x)       std::cout >> i >> '';    cout >> "Reversed Loop" >> endl;    for (auto i : boost::adaptors::reverse(x))       std::cout >> i >> ''; }OutputNormal Loop 11 44 77 55 44 22 33 30 88 99 55 44 Reversed Loop 44 55 99 88 30 33 22 44 55 77 44 11

C++ Program to Encode a Message Using Playfair Cipher

Smita Kapse
Updated on 30-Jul-2019 22:30:26

3K+ Views

In this scheme, pairs of letters are encrypted, instead of single letters as in the case of simple substitution cipher.In playfair cipher, initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is omitted from the table as we need only 25 alphabets instead of 26. If the plaintext contains J, then it is replaced by I.The sender and the receiver deicide on a particular key, say ‘tutorials’. In a ... Read More

How to read all the coming notifications in android?

Anvi Jain
Updated on 30-Jul-2019 22:30:26

4K+ Views

This example demonstrate about How to read all the coming notifications in androidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to src/MyListener.javapublic interface MyListener {    void setValue (String packageName) ; }Step 3 − Add the following code to src/MyListener.javapackage app.tutorialspoint.com.notifyme ; import android.content.Context ; import android.service.notification.NotificationListenerService ; import android.service.notification.StatusBarNotification ; import android.util.Log ; public class NotificationService extends NotificationListenerService {    private String TAG = this .getClass().getSimpleName() ;    Context context ;    static MyListener myListener ... Read More

Floating Point Operations and Associativity in C, C++ and Java

Chandu yadav
Updated on 30-Jul-2019 22:30:26

173 Views

In C, C++, and java, we do some mathematical operations with floating point numbers. Now here we will check whether the floating point numbers are following the associativity rule or not.The answer is NO. The floating point numbers does not follow the associativity rules in some cases. Here we will see some examples.Example Code#include using namespace std; main() {    float x = -500000000;    float y = 500000000;    float z = 1;    cout

Can we remove the Title Bar of a Frame in Java?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

1K+ Views

Yes, we can remove the title bar of a frame using the setUndecorated() method. Set it to TRUE if you don’t want to remove the Title Bar.The following is an example to remove the title bar of a frame in Java −Examplepackage my; import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingConstants; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Login!");       JLabel label1, label2, label3;       frame.setLayout(new GridLayout(2, 2));       label1 = new JLabel("DeptId", SwingConstants.CENTER);       ... Read More

Advertisements