Rebuilding Indexes in MongoDB

AmitDiwan
Updated on 03-Apr-2020 12:18:08

624 Views

To rebuild indexes, use reIndex(). Let us first create an index. Following is the query −> db.demo42.createIndex({"StudentFirstName":1});This will produce the following output −{    "createdCollectionAutomatically" : true,    "numIndexesBefore" : 1,    "numIndexesAfter" : 2,    "ok" : 1 }Following is the query to rebuild index in MongoDB −> db.demo42.reIndex({"StudentFirstName":1});This will produce the following output −{    "nIndexesWas" : 2,    "nIndexes" : 2,    "indexes" : [       {          "v" : 2,          "key" : {             "_id" : 1          },          "name" : "_id_",          "ns" : "web.demo42"       },       {          "v" : 2,          "key" : {             "StudentFirstName" : 1          },          "name" : "StudentFirstName_1",          "ns" : "web.demo42"       }   ],    "ok" : 1 }

Create Navigation Bar with Equal Width Links using CSS

AmitDiwan
Updated on 03-Apr-2020 10:47:08

1K+ Views

Following is the code to create a navigation bar with equal-width navigation links.−Example Live Demo Document body{    margin:0px;    margin-top:60px;    padding: 0px; } *,*::before,*::after{    box-sizing: border-box; } nav{    position: fixed;    top: 0;    width: 100%;    background-color: rgb(39, 39, 39);    overflow: auto;    height: auto; } .links {    width: 20vw;    padding: 17px;    display: inline-block;    text-align: center;    color: rgb(178, 137, 253);    text-decoration: none;    font-size: 17px; } .links:hover {    background-color: rgb(100, 100, 100); } .selected{    background-color: rgb(0, 18, 43); } Home Login Register Contact Us More Info Equal width navigation menu OutputThe above code will produce the following output −

Create Navigation Bar with Centre Link and Logo using CSS

AmitDiwan
Updated on 03-Apr-2020 10:43:53

409 Views

Following is the code to produce a navigation bar with a centered link/logo −Example Live Demo Document body{    margin:0px;    margin-top:60px;    padding: 0px; } nav{    position: fixed;    top:0;    width: 100%;    background-color: rgb(251, 255, 196);    overflow: auto;    height: auto; } .left-links{    display: inline-block;    position: absolute;    left: 0; } .right-links{    display: inline-block;    position: absolute;    right: 0; } .center-links{    display: inline-block;    margin-left: 50%; } .links {    display: inline-block;    text-align: center;    padding: 14px;    color: rgb(0, 0, 0);    text-decoration: none;    font-size: 17px;    font-weight: bolder; } .links:hover {    border-bottom: 2px solid purple; } .selected{    border-bottom: 2px solid purple; } Login Register Home Contact Us More Info Hover on the above links OutputThe above code will produce the following output−

Read in a File in C# with StreamReader

karthikeya Boyini
Updated on 03-Apr-2020 10:43:20

549 Views

To read text files, use StreamReader class in C#.Add the name of the file you want to read −StreamReader sr = new StreamReader("hello.txt");Use the ReadLine() method and get the content of the file in a string −using (StreamReader sr = new StreamReader("hello.txt")) {    str = sr.ReadLine(); } Console.WriteLine(str);Let us see the following code −Example Live Demousing System.IO; using System; public class Program {    public static void Main() {       string str;       using (StreamWriter sw = new StreamWriter("hello.txt")) {          sw.WriteLine("Hello");          sw.WriteLine("World");       }   ... Read More

StreamWriter in C#

Samual Sam
Updated on 03-Apr-2020 10:37:22

209 Views

Write characters to a stream with StreamWriter in C#.With StreamWriter, create a new file −StreamWriter sw = new StreamWriter("hello.txt"))Add text to the file −sw.WriteLine("Hello"); sw.WriteLine("World");The following is the code −Exampleusing System.IO; public class Program {    public static void Main() {       using (StreamWriter sw = new StreamWriter("hello.txt")) {          sw.WriteLine("Hello");          sw.WriteLine("World");       }    } }It creates the file “hello.text” and adds text to it −OutputThe following is the output.Hello World

Read Contents of a File into a String in C#

Samual Sam
Updated on 03-Apr-2020 10:36:03

290 Views

Use ReadToEnd() method to read the contents of a file in a string.Set it under StreamReader and read the file −using (StreamReader sr = new StreamReader("new.txt")){    string res = sr.ReadToEnd();    Console.WriteLine(res); }The following is the complete code −Example Live Demousing System.IO; using System; public class Demo {    public static void Main() {       using (StreamWriter sw = new StreamWriter("new.txt")) {          sw.WriteLine("One");          sw.WriteLine("Two");       }       using (StreamReader sr = new StreamReader("new.txt")) {          string res = sr.ReadToEnd();       ... Read More

Create Horizontal Scrollable Menu with CSS

AmitDiwan
Updated on 03-Apr-2020 09:19:49

710 Views

Following is the code to produce a horizontal scrollable menu with CSS −Example Live Demo Document body{    margin:0px;    margin-top:10px;    padding: 0px; } nav{    width: 100%;    background-color: rgb(39, 39, 39);    overflow: auto;    height: auto;    white-space: nowrap; } .links {    display: inline-block;    text-align: center;    padding: 14px;    color: rgb(178, 137, 253);    text-decoration: none;    font-size: 17px; } .links:hover {    background-color: rgb(100, 100, 100); } .selected{    background-color: rgb(0, 18, 43); } Home Login Register Contact Us More Info Our Social Links Visit Us OutputThe above code will produce the following output −On resizing the browser window horizontal scrolling will be seen −

Create Hoverable Sidenav with CSS

AmitDiwan
Updated on 03-Apr-2020 09:09:33

385 Views

Following is the code to create hoverable side navigation buttons with CSS.Example Live Demo Document nav a {    position: fixed;    left: -120px;    transition: 0.3s;    padding: 10px;    width: 140px;    text-decoration: none;    font-size: 20px;    color: black;    font-weight: bolder;    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } nav a:hover {    left: 0; } #Info{    top: 20px;    background-color: #6de2f7; } #Social{    top: 80px;    background-color: #71fc71; } #Address {    top: 140px;    background-color: #c4f553; } #Home {    top: 200px;    background-color: rgb(225, 115, 240); ... Read More

Access Array Elements Using a Pointer in C#

karthikeya Boyini
Updated on 03-Apr-2020 09:08:18

4K+ Views

In C#, an array name and a pointer to a data type same as the array data, are not the same variable type. For example, int *p and int[] p, are not the same type. You can increment the pointer variable p because it is not fixed in memory but an array address is fixed in memory, and you can't increment that.Here is an example −Exampleusing System; namespace UnsafeCodeApplication {    class TestPointer {       public unsafe static void Main() {          int[] list = {5, 25};          fixed(int *ptr = ... Read More

Create a Responsive Side Navigation Menu with CSS

AmitDiwan
Updated on 03-Apr-2020 08:51:56

814 Views

Following is the code to create a responsive side navigation menu with CSS −Example Live Demo body {    margin: 0;    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } nav {    margin: 0;    padding: 0;    width: 150px;    background-color: #2f77e4;    position: fixed;    height: 100%;    overflow: auto; } nav a {    display: block;    color: rgb(255, 255, 255);    font-weight: bolder;    font-size: 20px;    padding: 16px;    text-decoration: none; } nav a.selected {    background-color: rgb(15, 189, 20);    color: rgb(255, 255, 255); } nav a:hover:not(.selected) {    background-color: ... Read More

Advertisements