code-rag-bench/online-tutorials huggingface dataset:
Angular CLI - ng add Command

This chapter explains the syntax, argument and options of ng add command along with an example.
The syntax for ng add command is as follows −
ng add <collection> [options]

ng add a npm package to workspace.
The argument for ng add command is as follows −
Options are optional parameters.
Shows a help message for this command in the console.
Default: false
Display additional details about internal operations during execution.
Default: false
First move to an angular project updated using ng build command,which is available at https://www.tutorialspoint.com/angular_cli/angular_cli_ng_build.htm.
Now run the add command.
An example for ng add command is given below −
\>Node\>TutorialsPoint> ng add @angular/pwa
Installing packages for tooling via npm.
Installed packages for tooling via npm.
CREATE ngsw-config.json (620 bytes)
CREATE src/manifest.webmanifest (1352 bytes)
CREATE src/assets/icons/icon-128x128.png (1253 bytes)
CREATE src/assets/icons/icon-144x144.png (1394 bytes)
CREATE src/assets/icons/icon-152x152.png (1427 bytes)
CREATE src/assets/icons/icon-192x192.png (1790 bytes)
CREATE src/assets/icons/icon-384x384.png (3557 bytes)
CREATE src/assets/icons/icon-512x512.png (5008 bytes)
CREATE src/assets/icons/icon-72x72.png (792 bytes)
CREATE src/assets/icons/icon-96x96.png (958 bytes)
UPDATE angular.json (3803 bytes)
UPDATE package.json (1332 bytes)
UPDATE src/app/app.module.ts (682 bytes)
UPDATE src/index.html (482 bytes)
√ Packages installed successfully.


    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Find a specific column in all the tables in a database?

For this, use COLUMN_NAME and set LIKE with that specific column name. Let us find a specific column in an unknown table in a database −
mysql> SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT
   -> FROM INFORMATION_SCHEMA.COLUMNS
   -> WHERE column_name LIKE '%StudentName%'
   -> AND table_schema = 'web';
This will produce the following output −
+-------------------+-------------+-----------+-------------+----------------+
| TABLE_NAME        | COLUMN_NAME | DATA_TYPE | IS_NULLABLE |COLUMN_DEFAULT  |
+-------------------+-------------+-----------+-------------+----------------+
| demotable215      | StudentName | varchar   | YES         | NULL           |
| demotable221      | StudentName | varchar   | YES         | NULL           |
| demotable224      | StudentName | varchar   | YES         | NULL           |
| demotable234      | StudentName | varchar   | YES         | NULL           |
| demotable269      | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | NO          | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | json      | YES         | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | NO          | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| DemoTable         | StudentName | varchar   | YES         | NULL           |
| view_DemoTable    | StudentName | varchar   | YES         | NULL           |
+-------------------+-------------+-----------+-------------+----------------+
19 rows in set (0.07 sec)
Above displays all the tables with a specific column “StudentName”.
How to get and store Device ID in Android?

This example demonstrates how do I get and store Device ID in android.
Step 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 res/layout/activity_main.xml.
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   TextView textView;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      textView = findViewById(R.id.textView);
      String ID = Settings.Secure.getString(getContentResolver(),
      Settings.Secure.ANDROID_ID);
      textView.setText("Device ID: "+ ID);
   }
}
Step 3 − Add the following code to src/MainActivity.java
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
   <TextView
      android:id="@+id/textView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true"
      android:textSize="24sp"
      android:textStyle="bold"/>
</RelativeLayout>
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
   xmlns:android="http://schemas.android.com/apk/res/android"
   package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action
               android:name="android.intent.action.MAIN" />
            <category
               android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
JavaScript - Math floor Method

This method returns the largest integer less than or equal to a number.
Its syntax is as follows −
Math.floor( x ) ;

x  − A numbers.
Returns the largest integer less than or equal to a number x.
Try the following example program.
<html>   
   <head>
      <title>JavaScript Math floor() Method</title>
   </head>
   
   <body>      
      <script type = "text/javascript">
         var value = Math.floor(10.3);
         document.write("First Test Value : " + value );
         
         var value = Math.floor(30.9);
         document.write("<br />Second Test Value : " + value ); 
         
         var value = Math.floor(-2.9);
         document.write("<br />Third Test Value : " + value ); 
         
         var value = Math.floor(-2.2);
         document.write("<br />Fourth Test Value : " + value ); 
      </script>      
   </body>
</html>
First Test Value : 10
Second Test Value : 30
Third Test Value : -3
Fourth Test Value : -3 


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
JavaScript Date constructor Property

Javascript date constructor property returns a reference to the array function that created the instance's prototype.
Its syntax is as follows −
date.constructor

Returns the function that created this object's instance.
Try the following example.
<html>
   <head>
      <title>JavaScript Date constructor Property</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var dt = new Date();
         document.write("dt.constructor is : " + dt.constructor); 
      </script>      
   </body>
</html>
dt.constructor is: function Date() { [native code] } 


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Python | fmod() function - GeeksforGeeks

21 Sep, 2018
fmod() function is one of the Standard math library function in Python, which is used to calculate the Module of the specified given arguments.
Syntax: math.fmod( x, y )
Parameters:x any valid number (positive or negative).y any valid number(positive or negative).
Returns: Return a floating point number value after calculating module of given parameters x and y.
Example #1:
# Python3 program to demonstrate fmod() function  import math  # Tuple DeclarationTup = (15, 22, -2, -40 )  # List DeclarationLis = [-89, 38, -39, 16]   # modulus of +ve integer numberprint(math.fmod(4, 5))print(math.fmod(43.50, 4.5))  # modulus of -ve integer numberprint(math.fmod(-17, 5))print('%.2f' %math.fmod(-10, 4.78))  # modulus of tuple itemprint("\nModulus of tuple items:")print(math.fmod(Tup[2], 5))print(math.fmod(Tup[2], -6))  # modulus of list itemprint("\nModulus of list items:")print(math.fmod(Lis[3], 4))print(math.fmod(Lis[0], -15))
Output:
4.0
3.0
-2.0
-0.44

Modulus of tuple items:
-2.0
-2.0

Modulus of list items:
0.0
-14.0

 Example #2: ValueError and TypeError
If both the x and y arguments are Zero, fmod() function will return the output as ValueError.
If y argument (second argument) is Zero, fmod() function will return the output as ValueError.
If the x value or y value is not a number, fmod() function will return TypeError.
# Python3 program to demonstrate # errors in fmod() function  import math  # will give ValueErrorprint(math.fmod(0, 0))print(math.fmod(2, 0))  # it will give TypeErrorprint(math.fmod('2', 3))
Output:
ValueError: math domain error
ValueError: math domain error
TypeError: a float is required

Python math-library
Python math-library-functions
Python-Built-in-functions
Python-Library
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
How to find Nth smallest value in vector in R ? - GeeksforGeeks

07 Apr, 2021
In this article, we will discuss how to find the Nth smallest in vector in the R programming language.
Create vector
Take input from the user using the function readline().
Convert data from string to int using the function as.integer().
In this step, we are finding nth largest number using
Syntax:
sort(vector name ) [n value])
Parameter:
Vector name is the vector which we created.
N value is which largest number you want to print.
Example 1:
R
a<- c(1,3,4)  x = readline();x = as.integer(x);  print(sort(a)[x])
Output:
[1] 1
Example 2:
R
a<- c(3453,39898,-997784)  x = readline();x = as.integer(x);  print(sort(a)[x])
Output:
[1] 39898
R Vector-Programs
R-Vectors
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Convert Matrix to Dataframe in R
Subsets II in C++

Suppose we have a set of numbers; we have to generate all possible subsets of that set. This is also known as power set. We have to keep in mind that the elements may be duplicate. So if the set is like [1,2,2], then the power set will be [[], [1], [2], [1,2], [2,2], [1,2,2]]
Let us see the steps −
Define one array res and another set called x
We will solve this using recursive approach. So if the recursive method name is called solve(), and this takes index, one temporary array, and the array of numbers (nums)
The solve() function will work like below −
if index = size of v, thenif temp is not present in x, then insert temp into res and also insert temp into xreturn
if temp is not present in x, then insert temp into res and also insert temp into x
return
call solve(index + 1, temp, v)
insert v[index] into temp
call solve(index + 1, temp, v)
remove last element from temp
The main function will be like below −
clear the res and x, and sort the given array, define an array temp
call solve(0, temp, array)
sort the res array and return res
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
void print_vector(vector<vector<int> > v){
      cout << "[";
      for(int i = 0; i<v.size(); i++){
         cout << "[";
      for(int j = 0; j <v[i].size(); j++){
         cout << v[i][j] << ", ";
      }
      cout << "],";
   }
   cout << "]"<<endl;
}
class Solution {
   public:
   vector < vector <int> > res;
   set < vector <int> > x;
   static bool cmp(vector <int> a, vector <int> b){
      return a < b;
   }
   void solve(int idx, vector <int> temp, vector <int> &v){
      if(idx == v.size()){
         if(x.find(temp) == x.end()){
            res.push_back(temp);
            x.insert(temp);
         }
         return;
      }
      solve(idx+1, temp, v);
      temp.push_back(v[idx]);
      solve(idx+1, temp, v);
      temp.pop_back();
   }
   vector<vector<int> > subsetsWithDup(vector<int> &a) {
      res.clear();
      x.clear();
      sort(a.begin(), a.end());
      vector <int> temp;
      solve(0, temp, a);
      sort(res.begin(), res.end(), cmp);
      return res;
   }
};
main(){
   Solution ob;
   vector<int> v = {1,2,2};
   print_vector(ob.subsetsWithDup(v));
}
[1,2,2]
[[],[1, ],[1, 2, ],[1, 2, 2, ],[2, ],[2, 2, ],]
Java final Keyword

❮ Java Keywords

Set a variable to final, to prevent it from being overridden/modified:
public class Main {
  final int x = 10;

  public static void main(String[] args) {
    Main myObj = new Main();
    myObj.x = 25; // will generate an error: cannot assign a value to a final variable
    System.out.println(myObj.x);
  }
}


Try it Yourself »

The final keyword is a non-access modifier used for classes, attributes and methods, which makes them non-changeable (impossible to inherit or override).
The final keyword is useful when you want a variable to always store the same value, like PI (3.14159...).
The final keyword is called a "modifier". You will learn more about these in the Java Modifiers Chapter.
Read more about attributes our Java Class Attributes Tutorial.

❮ Java Keywords

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Matlab-Matrix - Trace

Trace helps you to calculate the sum of diagonal elements in a given matrix.
Consider the given 3x3 matrix. Let us find out the sum of diagonal elements as shown below −
a = [ 1 2 3; 2 3 4; 1 2 5];
test = trace(a)
The execution in MATLAB is as follows −
>> a = [ 1 2 3; 2 3 4; 1 2 5]
test = trace(a)

a =

   1  2  3
   2  3  4
   1  2  5
 
test =

   9
   
>>


    30 Lectures 
     4 hours 

 Nouman Azam

    127 Lectures 
     12 hours 

 Nouman Azam

    17 Lectures 
     3 hours 

 Sanjeev

    37 Lectures 
     5 hours 

 TELCOMA Global

    22 Lectures 
     4 hours 

 TELCOMA Global

    18 Lectures 
     3 hours 

 Phinite Academy
 Print
 Add Notes
 Bookmark this page
Get max and min values of an array in Arduino

In order to get the max/ min values of an array in Arduino, we can run a simple for loop. Two implementations are shown below. One uses the max() and min() functions of Arduino, and the other uses the > and < operators.
The max and min functions have the following syntax: max(a,b) and min(a,b), and they return the max and min values out of a and b respectively.
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();
   int myArray[6] = {1, 5, -6, 4, -2, 7};

   int maxVal = myArray[0];
   int minVal = myArray[0];
   Serial.print("Size of myArray is: "); Serial.println(sizeof(myArray));

   for (int i = 0; i < (sizeof(myArray) / sizeof(myArray[0])); i++) {
      if (myArray[i] > maxVal) {
         maxVal = myArray[i];
      }
      if (myArray[i] < minVal) {
         minVal = myArray[i];
      }
   }
   Serial.print("The maximum value of the array is: "); Serial.println(maxVal);
   Serial.print("The minimum value of the array is: "); Serial.println(minVal);
}

void loop() {
   // put your main code here, to run repeatedly:
}
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();
   int myArray[6] = {1, 5, -6, 4, -2, 7};

   int maxVal = myArray[0];
   int minVal = myArray[0];
   Serial.print("Size of myArray is: "); Serial.println(sizeof(myArray));

   for (int i = 0; i < (sizeof(myArray) / sizeof(myArray[0])); i++) {
      maxVal = max(myArray[i],maxVal);
      minVal = min(myArray[i],minVal);
   }

   Serial.print("The maximum value of the array is: ");
Serial.println(maxVal);
   Serial.print("The minimum value of the array is: ");
Serial.println(minVal);
}

void loop() {
   // put your main code here, to run repeatedly:
}
The Serial Monitor output in both the cases is −
As you can see, the sizeof() function is returning the total number of bytes and not the number of elements in the array (I’m using a board which stores int in 4 bytes). Therefore, within the for loop, the condition has been kept as −
i < (sizeof(myArray) / sizeof(myArray[0]))
CouchDB - Deleting a Document

You can delete a document in CouchDB by sending an HTTP request to the server using DELETE method through cURL utility. Following is the syntax to delete a document.
curl -X DELETE http : // 127.0.0.1:5984 / database name/database id?_rev id
Using −X, we can specify a custom request method of HTTP we are using, while communicating with the HTTP server. In this case, we are using Delete method. To delete a database /database_name/database_id/ is not enough. You have to pass the recent revision id through the url. To mention attributes of any data structure "?" is used.
Suppose there is a document in database named my_database with document id 001. To delete this document, you have to get the rev id of the document. Get the document data as shown below.
$ curl -X GET http://127.0.0.1:5984/my_database/001
{
   " _id " : " 001 ",
   " _rev " : " 2-04d8eac1680d237ca25b68b36b8899d3 " ,
   " age " : " 23 "
}
Now specify the revision id of the document to be deleted, id of the document, and database name the document belongs to, as shown below −
$ curl -X DELETE http://127.0.0.1:5984/my_database/001?rev=1-
3fcc78daac7a90803f0a5e383f4f1e1e

{"ok":true,"id":"001","rev":"2-3a561d56de1ce3305d693bd15630bf96"}
To verify whether the document is deleted, try to fetch the document by using the GET method. Since you are fetching a deleted document, this will give you an error message as shown below −
$ curl -X GET http://127.0.0.1:5984/my_database/001
{"error":"not_found","reason":"deleted"}

First of all, verify the documents in the database. Following is the snapshot of the database named tutorials_point.
Here you can observe, the database consists of three documents. To delete any of the documents say 003, do the following −
Click on the document, you will get a page showing the contents of selected document in the form of field-value pairs.
Click on the document, you will get a page showing the contents of selected document in the form of field-value pairs.
This page also contains four options namely Save Document, Add Field, Upload Attachment, Delete Document.
This page also contains four options namely Save Document, Add Field, Upload Attachment, Delete Document.
Click on Delete Document option.
Click on Delete Document option.
You will get a dialog box saying "Are you sure you want to delete this document?" Click on delete, to delete the document.
You will get a dialog box saying "Are you sure you want to delete this document?" Click on delete, to delete the document.
 Print
 Add Notes
 Bookmark this page
How to connect Azure Account using PowerShell?

To connect the azure account with PowerShell, we can use the Connect-AZAccount command. If we check the command parameters from the below URL, there are multiple methods we can connect to the azure account but in this article, we will use the simple methods to connect.
Using the Interactive console to connect portal
Using the Interactive console to connect portal
Using DeviceLogin method.
Using DeviceLogin method.
Using Credentials method.
Using Credentials method.
When we use the Connect-AZAccount directly without any parameter, it will open a popup for the azure portal credential.
You need to enter your Azure credentials there.
In this method, Connect-AZAccount uses the parameter -DeviceLogin. Once you run the command, it will show the code on the console window and that code we need to enter on the website,
Connect-AzAccount -DeviceCode
WARNING: To sign in, use a web browser to open the page
https://microsoft.com/devicelogin and enter the code SAYX4512 to authenticate.
As shown in the above output, you need to enter display code on the website,https://Microsoft.com/DeviceLogin and if you are not already authenticated you need to enter Azure credentials there.
You can direct provide Azure user credentials in the Get-Credentials command and use those credentials in Connect-AZAccount . 
$creds = Get-Credential
Connect-AZAccount -Credential $creds
Once you enter the correct credentials, your account will be connected. But if your organization has configured the multi-factor authentication this method won’t work and likely it will produce an error.
Count frequencies of all elements in array in Python using collections module - GeeksforGeeks

19 Feb, 2021
Given an unsorted array of n integers which can contains n integers. Count frequency of all elements that are present in array.Examples:
Input : arr[] = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 5]
Output : 1 -> 4
         2 -> 4
         3 -> 2
         4 -> 1
         5 -> 2

This problem can be solved in many ways, refer Count frequencies of all elements in array link. In Python, we can quickly solve this problem in using Collections module.
# Function to count frequency of each element import collections  # it returns a dictionary data structure whose # keys are array elements and values are their # corresponding frequencies {1: 4, 2: 4, 3: 2, # 5: 2, 4: 1}def CountFrequency(arr):    return collections.Counter(arr)    # Driver functionif __name__ == "__main__":      arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 5]    freq = CountFrequency(arr)      # iterate dictionary named as freq to print    # count of each element    for (key, value) in freq.items():        print (key, " -> ", value)
Output:
1 -> 4
2 -> 4
3 -> 2
4 -> 1
5 -> 2

YouTubeGeeksforGeeks502K subscribersCount frequencies of all elements in array in Python using collections module | GeeksforGeeksWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:000:00 / 5:12•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=NT8vn-c81E0" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
Related Article :Counting the frequencies in a list using dictionary in Python
This article is contributed by Shashank Mishra (Gullu). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
anandshaw0101
frequency-counting
Arrays
Python
Arrays
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stack Data Structure (Introduction and Program)
Top 50 Array Coding Problems for Interviews
Multidimensional Arrays in Java
Introduction to Arrays
Linear Search
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
C++ Library - <thread>

Thread is a sequence of instructions that can be executed concurrently with other such sequences in multithreading environments, while sharing a same address spac.
It is a thread id.
It is a native handle type.
It is used to construct thread.
It is used to destructor thread.
It is a move-assign thread.
It is used to get thread id.
It is used to check if joinable.
It is used to join thread.
It is used to detach thread.
It is used to swap threads.
It is used to get native handle.
It is used to detect hardware concurrency.
It is used to swap threads.
In below example for std::thread.
#include <iostream>
#include <thread>

void foo() {
   std::cout << " foo is executing concurrently...\n";
}

void bar(int x) {
   std::cout << " bar is executing concurrently...\n";
}

int main() {
   std::thread first (foo);
   std::thread second (bar,0);

   std::cout << "main, foo and bar now execute concurrently...\n";

   first.join();
   second.join();

   std::cout << "foo and bar completed.\n";

   return 0;
}
The output should be like this −
main, foo and bar now execute concurrently...
 bar is executing concurrently...
 foo is executing concurrently...
foo and bar completed.

 Print
 Add Notes
 Bookmark this page
How to print object array in JavaScript?

To print object array in JavaScript, use JSON.stringify() method.
You can try to run the following code to display object array −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <pre id="test"></pre>
      <script>
         var data = [{
            date: new Date(2017, 11, 25),
            value: 10
         }, {
            date: new Date(2017, 11, 30),
            value: 20
         }];
         document.getElementById('test').innerHTML = JSON.stringify(data, null, 4);
      </script>
   </body>
</html>
[    
   {        
      "date": "2017-12-24T18:30:00.000Z",
      "value": 10
   },    
   {        
       "date": "2017-12-29T18:30:00.000Z",  
       "value": 20  
   }
]
How to check if a variable is boolean in JavaScript?

To check if a variable is Boolean in JavaScript, use the typeof operator.
You can try to run the following code to check for a Boolean variable −
Live Demo
<html>
   <head>
      <title>JavaScript Boolean</title>
   </head>

   <body>
      <script>
         var answer = true;
         if(typeof(answer) === "boolean") {
            alert("Boolean");
         } else {
            alert("Not a Boolean");
         }
      </script>
   </body>
</html>
How to remove leading and trailing whitespace in a MySQL field?

To remove leading and trailing space, we can use the trim() in MySQL. Firstly, we will create a
table with the help of CREATE command.
Creating a table −
mysql> CREATE table TrailingANdLeadingDemo
-> (
-> SpaceTrailLead varchar(100)
-> );
Query OK, 0 rows affected (0.57 sec)
After creating a table, we will insert a record with the help of INSERT command. Let us insert a
record with leading and trailing space −
mysql> INSERT into TrailingANdLeadingDemo values(' john ');
Query OK, 1 row affected (0.12 sec)
We can display all the records with the help of SELECT command
mysql> SELECT * from TrailingANdLeadingDemo;

The following is the output
+----------------+
| SpaceTrailLead |
+----------------+
| john           |
+----------------+
1 row in set (0.00 sec)
Now, record has been inserted with some space. The syntax to remove leading and trailing space with the help of trim() function is as follows −
UPDATE yourTableName set column_name=trim(column_name);

Now, I am applying the above query to remove trailing and leading space −
mysql> UPDATE TrailingANdLeadingDemo set SpaceTrailLead=trim(SpaceTrailLead);
Query OK, 1 row affected (0.17 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Now, we can check whether the space is removed or not. Use SELECT statement to display the
records −
mysql> SELECT * from TrailingANdLeadingDemo;

The following is the output
+----------------+
| SpaceTrailLead |
+----------------+
| john           |
+----------------+
1 row in set (0.00 sec)
Look at the above output, the spaces have been removed clearly from the column.
Create two unequal columns with Bootstrap Grid Layout

To create two unequal columns with Bootstrap Grid Layout, you can try to run the following code
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container-fluid">
         <h2>Bootstrap Grid Unequal Columns</h2>
         <div class = "row">
            <div class = "col-sm-9" style = "background-color:blue; color: white;">Column One</div>
            <div class = "col-sm-3" style = "background-color:red; color: white;">Column Two</div>
         </div>
      </div>
   </body>
</html>
Java - Bitwise Operators Example

The following program is a simple example that demonstrates the bitwise operators. Copy and paste the following Java program in Test.java file and compile and run this program −
public class Test {

   public static void main(String args[]) {
      int a = 60;	/* 60 = 0011 1100 */
      int b = 13;	/* 13 = 0000 1101 */
      int c = 0;

      c = a & b;        /* 12 = 0000 1100 */
      System.out.println("a & b = " + c );

      c = a | b;        /* 61 = 0011 1101 */
      System.out.println("a | b = " + c );

      c = a ^ b;        /* 49 = 0011 0001 */
      System.out.println("a ^ b = " + c );

      c = ~a;           /*-61 = 1100 0011 */
      System.out.println("~a = " + c );

      c = a << 2;       /* 240 = 1111 0000 */
      System.out.println("a << 2 = " + c );

      c = a >> 2;       /* 15 = 1111 */
      System.out.println("a >> 2  = " + c );

      c = a >>> 2;      /* 15 = 0000 1111 */
      System.out.println("a >>> 2 = " + c );
   }
}
This will produce the following result −
a & b = 12
a | b = 61
a ^ b = 49
~a = -61
a << 2 = 240
a >> 2  = 15
a >>> 2 = 15


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Job Sequencing Problem with Deadlines

In this problem, there is a list of jobs given. In the list, the deadline and the profits are also given for each job. Every job will take a single unit of time, so the minimum deadline for a job is 1. If only one job can be scheduled at a time, then maximize the profit.
To solve this problem, all subset of the set of jobs are generated to check whether the individual subset is feasible or not. Also, keep track on maximum profit for all feasible subset that has generated.
The time complexity of this algorithm is O(n^2)
Input:
A list of jobs with job id, deadline and profit. And the number of jobs n.
{('a', 2, 100), ('b', 1, 19), ('c', 2, 27), ('d', 1, 25), ('e', 3, 15)}
n = 5
Output:
Following is maximum profit sequence of job sequence: c a e
jobSequence(jobList, n)
Input − The list of jobs and the number of jobs present in the list.
Output − The sequence, how jobs are taken.
Begin
   sort the jobs in jobList according to their profit create a list of job sequence and slot to track free time slots
   initially make all slots are free
   for all given jobs i do
      for all jobs in the list from ending of the list do
         if slot[j] is free then
            jobSequence[j] := i
            make slot[j] := fill
            break the loop
      done
   done

   for all slots when it is not free do
      print id of job using jobList[jobSequence[i]]
   done
End
#include<iostream>
#include<algorithm>
using namespace std;

struct Job {
   char id;
   int deadLine;
   int profit;
};

bool comp(Job j1, Job j2) {
   return (j1.profit > j2.profit);    //compare jobs based on profit
}

int min(int a, int b) {
   return (a<b)?a:b;
}

void jobSequence(Job jobList[], int n) {
   sort(jobList, jobList+n, comp);    //sort jobList on profit

   int jobSeq[n];     // To store result (Sequence of jobs)
   bool slot[n];      // To keep track of free time slots

   for (int i=0; i<n; i++)
      slot[i] = false; //initially all slots are free

   for (int i=0; i<n; i++) {    //for all given jobs
      for (int j=min(n, jobList[i].deadLine)-1; j>=0; j--) {   //search from last free slot
         if (slot[j]==false) {
            jobSeq[j] = i;   // Add this job to job sequence
            slot[j] = true;  // mark this slot as occupied
            break;
         }
      }
   }

   for (int i=0; i<n; i++)
      if (slot[i])
         cout << jobList[jobSeq[i]].id << " ";    //display the sequence
}

int main() {
   Job jobList[] = {{'a',2,100}, {'b',1,19}, {'c',2,27},{'d',1,25},{'e',3,15}};
   int n = 5;
   cout << "Following is maximum profit sequence of job sequence: ";
   jobSequence(jobList, n);
}
Following is maximum profit sequence of job sequence: c a e
Cryptography with Python - ROT13 Algorithm

Till now, you have learnt about reverse cipher and Caesar cipher algorithms. Now, let us discuss the ROT13 algorithm and its implementation.
ROT13 cipher refers to the abbreviated form Rotate by 13 places. It is a special case of Caesar Cipher in which shift is always 13. Every letter is shifted by 13 places to encrypt or decrypt the message.
The following diagram explains the ROT13 algorithm process pictorially −
The program implementation of ROT13 algorithm is as follows −
from string import maketrans

rot13trans = maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 
   'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm')

# Function to translate plain text
def rot13(text):
   return text.translate(rot13trans)
def main():
   txt = "ROT13 Algorithm"
   print rot13(txt)
	
if __name__ == "__main__":
   main()
You can see the ROT13 output as shown in the following image −
The ROT13 algorithm uses 13 shifts. Therefore, it is very easy to shift the characters in the reverse manner to decrypt the cipher text.
ROT13 cipher algorithm is considered as special case of Caesar Cipher. It is not a very secure algorithm and can be broken easily with frequency analysis or by just trying possible 25 keys whereas ROT13 can be broken by shifting 13 places. Therefore, it does not include any practical use.

    10 Lectures 
     2 hours 

 Total Seminars

    10 Lectures 
     2 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
CSS - text-indent

The  text-indent property defines an indentation distance for the first line of text in a block-level element.
length − Any length value. Negative lengths are permitted for the property, and will produce a "hanging indent" effect.
length − Any length value. Negative lengths are permitted for the property, and will produce a "hanging indent" effect.
percentage − The first line of text is indented by a distance relative to the width of the element's containing block.
percentage − The first line of text is indented by a distance relative to the width of the element's containing block.
All the block-level elements.
object.style.textIndent = "20px";

Following is the example which demonstrates how to indent the first line of a paragraph −
<html>
   <head>
   </head>

   <body>
      <p style = "text-indent:1cm;">
         This text will have first line indented by 1cm 
      </p>
      
      <p style = "text-indent:1cm;">
         this line will remain at its actual position this is done by 
         CSS text-indent property.
      </p>
   </body>
</html> 
This will produce following result −

   This text will have first line indented by 1cm


this line will remain at its actual position this is done by CSS text-indent property.


    33 Lectures 
     2.5 hours 

 Anadi Sharma

    26 Lectures 
     2.5 hours 

 Frahaan Hussain

    44 Lectures 
     4.5 hours 

 DigiFisk (Programming Is Fun)

    21 Lectures 
     2.5 hours 

 DigiFisk (Programming Is Fun)

    51 Lectures 
     7.5 hours 

 DigiFisk (Programming Is Fun)

    52 Lectures 
     4 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Calculate Running Total in SQL - GeeksforGeeks

27 Apr, 2021
Structured Query Language or SQL is a standard Database language that is used to create, maintain and retrieve the data from relational databases like MySQL, Oracle, etc. In this article, we will be using the Microsoft SQL Server.Here we are going to see how to get the running salary total of each department. Here, we will first create a database named “geeks” then we will create a table “department” in that database. After, that we will execute our query on that table.
Creating Database:
CREATE geeks;
To use this database:
USE geeks;
This is our table in the geek’s database:
CREATE TABLE department(
ID int,
SALARY int,
NAME Varchar(20),
DEPT_ID Varchar(255));
Output:Command(s) completed successfully.
Add value into the table:
INSERT INTO department 
VALUES (1, 34000, 'ANURAG', 'UI DEVELOPERS');

INSERT INTO department 
VALUES (2, 33000, 'harsh', 'BACKEND DEVELOPERS');

INSERT INTO department 
VALUES (3, 36000, 'SUMIT', 'BACKEND DEVELOPERS');

INSERT INTO department 
VALUES (4, 36000, 'RUHI', 'UI DEVELOPERS');

INSERT INTO department 
VALUES (5, 37000, 'KAE', 'UI DEVELOPERS');
Output:(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)
Select in SQL Server Management Studio:
This is our data inside the table:
SELECT * FROM department;
Select in SQL Server Management Studio:
Example 1:Query to Calculate Running Total in SQL Server
SELECT * ,(
SELECT SUM(T2.[SALARY])  
 FROM [department] AS T2
       WHERE T2.[ID] <= T1.[ID]
) AS [Running Total]
FROM [department] AS T1
Output: 
Select in SQL Server Management Studio:
Example 2In this SQL Server example, we’ll use the SUM Function and OVER to find the Running Total.Query to Calculate Running Total in SQL Server
SELECT *
    ,SUM([SALARY]) OVER (
           ORDER BY  [ID]
  ) AS [Running Total]
FROM department
Output:
Select in SQL Server Management Studio:
Example 3:In this SQL Server example,  we will use PARTITION BY with OVER to find the Running Total.Query to Calculate Running Total in SQL Server
SELECT *
   ,SUM([SALARY]) OVER  (
PARTITION BY DEPT_ID  ORDER BY Id
) AS [Running Total]
FROM department
Output: 
Select in SQL Server Management Studio:
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL | Subquery
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
True, False, and Nil In Ruby - GeeksforGeeks

02 Sep, 2021
Ruby is an open-sourced object-oriented programming language developed by Yukihiro Matsumoto. In Ruby, everything is treated as an object. true, false and nil are built-in data types of Ruby. Note: Always remember in Ruby true, false, and nil are objects, not numbers. Whenever Ruby requires a Boolean value, then nil behaves like false and values other than nil or false behave like true. 
In Ruby, true and false are boolean values that represent yes and no. true is an object of TrueClass and false is an object of FalseClass. Note: Ruby does not contain Boolean class. Let’s see a few examples of true and false in Ruby. Example 1:  
Ruby
# Ruby program to illustrate the use# of true and falsea = 4b = 4 if a == b         # If Condition is true    puts "True! a and b are equal"     else         # If Condition is false    puts "False! a and b are not equal"     end
Output:  
True! a and b are equal
Example 2:  
Ruby
# Ruby program to illustrate the use# of true and falsea1 = "GeeksforGeeks"b1 = "GeeksforGeeks"result1 = a1 == b1 puts result1 a2 = "GeeksforGeeks"b2 = "geeks"result2 = a2 == b2 puts result2
Output:  
true
false
Example 3:  
Ruby
# Ruby program to illustrate the use# of true and false # If condition is trueif 55 == 55   puts "GeeksforGeeks !" # If Condition is falseelse    puts " A Computer Science Portal for Geeks!"  end
Output:  
GeeksforGeeks !
 
In Ruby, nil is a special value that denotes the absence of any value. Nil is an object of NilClass. nil is Ruby’s way of referring to nothing or void. Ruby also provide a nil? method to detect if any object is nil or not. Example 1:  
Ruby
# Checking for nil's classa = nil.classputs a
Output:  
 NilClass
Example 2:  
Ruby
# Ruby program to illustrate nil? method# Checking for Nilarray = [ 1, 2, 3, 4, 5 ] # Since array[5] does not exist so, it is nil.result1 = array[5].nil?puts result1 # Since array[2] exists so, it is not nil.result2 = array[2].nil?puts result2
Output:  
true
false
 
surindertarika1234
Picked
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Ruby | Types of Iterators
Ruby | Types of Variables
Ruby | String concat Method
Ruby | Array collect() operation
Ruby | Enumerator each_with_index function
Ruby | Class Method and Variables
Ruby | Array reverse() function
Ruby | Operators
Ruby | Module
Ruby on Rails Introduction
lsusb command in Linux with Examples

23 Apr, 2019
The lsusb command in Linux is used to display the information about USB buses and the devices connected to them. The properties displayed are speed, BUS, class, type details, etc.
Syntax:
lsusb [ options ]
Example:
Options:
-v : This option is used to display the output in verbose mode and also display detailed information about the devices connected.lsusb -v
lsusb -v
-s : This option is used to display the only device specified by the bus and/or device number.Example:lsusb -s 2:4
Example:
lsusb -s 2:4
-t : This option is used to dump the physical USB device hierarchy as a tree.Example:lsusb -t
Example:
lsusb -t
-D : This option is used to display information about the specified device file. The device file should be like /dev/usb/002/004.Example:lsusb -D /dev/bus/usb/002/004
Example:
lsusb -D /dev/bus/usb/002/004
linux-command
Linux-system-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
Docker - COPY Instruction
chown command in Linux with Examples
SED command in Linux | Set 2
nohup Command in Linux with Examples
chmod command in Linux with examples
Array Basics in Shell Scripting | Set 1
mv command in Linux with examples
Introduction to Linux Operating System
Basic Operators in Shell Scripting
How to find the age when date of birth is known? Using Java?

Java provides a class named Period in the java.time package. This is used to calculate the time period between two given dates as days, months and, years etc.
The between() method of this class accepts two LocalDate objects and finds out the period between the two given dates (number of years, months, and days) and returns as a period object.
From this, you can extract the number of days, months and, years of the period in between using the getDays(), getMonths() and, getYears() respectively.
If you already have the date of birth of a person, to find the age −
Get the date of birth from the user.
Convert it to LocalDate object.
Get the current date (as LocalDate object)
Find the period between these two dates using the between() method as −
Period period = Period.between(dateOfBirth, LocalDate.now());
Get the days, months, years from the Period object using the getDays(), getMonths() and, getYears() methods as −
Get the days, months, years from the Period object using the getDays(), getMonths() and, getYears() methods as −
period.getYears();
period.getMonths();
period.getDays();
Following example reads the name and date of birth from the user, converts it to LocalDate object, gets the current date, finds out the period between these two dates and prints it as days, months and years.
 Live Demo
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.Scanner;
public class CalculatingAge {
   public static Date StringToDate(String dob) throws ParseException{
      //Instantiating the SimpleDateFormat class
      SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
      //Parsing the given String to Date object
      Date date = formatter.parse(dob);
      System.out.println("Date object value: "+date);
      return date;
   }
   public static void main(String args[]) throws ParseException {
      //Reading name and date of birth from the user
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter your name: ");
      String name = sc.next();
      System.out.println("Enter your date of birth (dd-MM-yyyy): ");
      String dob = sc.next();
      //Converting String to Date
      SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
      Date date = formatter.parse(dob);
      //Converting obtained Date object to LocalDate object
      Instant instant = date.toInstant();
      ZonedDateTime zone = instant.atZone(ZoneId.systemDefault());
      LocalDate givenDate = zone.toLocalDate();
      //Calculating the difference between given date to current date.
      Period period = Period.between(givenDate, LocalDate.now());
      System.out.print("Hello "+name+" your current age is: ");
      System.out.print(period.getYears()+" years "+period.getMonths()+" and "+period.getDays()+" days");
   }
}
Enter your name:
Krishna
Enter your date of birth (dd-MM-yyyy):
26-07-1989
Hello Krishna your current age is: 29 years 10 and 5 days