code-rag-bench/online-tutorials huggingface dataset:
SQLite - UPDATE Query

SQLite UPDATE Query is used to modify the existing records in a table. You can use WHERE clause with UPDATE query to update selected rows, otherwise all the rows would be updated.
Following is the basic syntax of UPDATE query with WHERE clause.
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];

You can combine N number of conditions using AND or OR operators.
Consider COMPANY table with the following records −
ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0
2           Allen       25          Texas       15000.0
3           Teddy       23          Norway      20000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0
6           Kim         22          South-Hall  45000.0
7           James       24          Houston     10000.0
Following is an example, which will update ADDRESS for a customer whose ID is 6.
sqlite> UPDATE COMPANY SET ADDRESS = 'Texas' WHERE ID = 6;
Now, COMPANY table will have the following records.
ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0
2           Allen       25          Texas       15000.0
3           Teddy       23          Norway      20000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0
6           Kim         22          Texas       45000.0
7           James       24          Houston     10000.0
If you want to modify all ADDRESS and SALARY column values in COMPANY table, you do not need to use WHERE clause and UPDATE query will be as follows −
sqlite> UPDATE COMPANY SET ADDRESS = 'Texas', SALARY = 20000.00;
Now, COMPANY table will have the following records −
ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          Texas       20000.0
2           Allen       25          Texas       20000.0
3           Teddy       23          Texas       20000.0
4           Mark        25          Texas       20000.0
5           David       27          Texas       20000.0
6           Kim         22          Texas       20000.0
7           James       24          Texas       20000.0
PostgreSQL – Variables

28 Aug, 2020
In PostgreSQL, a variable is a meaningful name for a memory location. A variable holds a value that can be changed through the block or function. A variable is always associated with a particular data type. Before using a variable, you must declare it in the declaration section of the PostgreSQL Block. The following illustrates the syntax of declaring a variable.
Syntax: variable_name data_type [:= expression];


Let’s analyze the above syntax:
First, specify the name of the variable. It is a good practice to assign a meaningful name to a variable. For example, instead of naming a variable “i“ one should use index or counter.
Second, associate a specific data type with the variable. The data type can be any valid PostgreSQL data type such as INTEGER, NUMERIC, VARCHAR, and CHAR.
Third, optionally assign a default value to a variable. If you don’t, the initial value of the variable is initialized to NULL.
Example 1:
DO $$ 
DECLARE
   counter    INTEGER := 1;
   first_name VARCHAR(50) := 'John';
   last_name  VARCHAR(50) := 'Doe';
   payment    NUMERIC(11,2) := 20.5;
BEGIN 
   RAISE NOTICE '% % % has been paid % USD', counter, first_name, last_name, payment;
END $$;


Output:
Example 2:
DO $$ 
DECLARE
   created_at time := NOW();
BEGIN 
   RAISE NOTICE '%', created_at;
   PERFORM pg_sleep(10);
   RAISE NOTICE '%', created_at;
END $$;


Output:
postgreSQL-basics
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - Psql commands
PostgreSQL - Change Column Type
PostgreSQL - For Loops
PostgreSQL - LIMIT with OFFSET clause
PostgreSQL - Function Returning A Table
PostgreSQL - ARRAY_AGG() Function
PostgreSQL - DROP INDEX
PostgreSQL - Create Auto-increment Column using SERIAL
PostgreSQL - Copy Table
PostgreSQL - ROW_NUMBER Function
HTML | <hr> noshade Attribute

28 May, 2019
The HTML <hr> noshade Attribute is the boolean value and used to specify the solid horizontal line instead of shaded lines.
Syntax:
<hr noshade>
Note: The <hr> noshade Attribute is not supported by HTML 5.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML hr noshade Attribute    </title></head>  <body style="text-align:center;">    <h1>GeeksforGeeks</h1>    <hr width="500px;"        size="10">    <p>Computer science portal</p>    <hr width="70%"         size="20"         noshade></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <hr> noshade Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Angular File Upload
Form validation using jQuery
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Display Inline-Block Working with CSS

The CSS Display property with value inline-block renders an element according to content’s width or provided width whichever is greater, it does not force a line break until parent element’s width is fully utilized.
Following is the syntax of CSS display inline-block −
Selector {
   display: inline-block;
}
Let’s see an example of CSS display inline-block −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<title>CSS Display Inline-Block</title>
<style>
form {
   width:70%;
   margin: 0 auto;
   text-align: center;
}
* {
   padding: 2px;
   margin:5px;
   box-sizing: border-box;
}
input[type="button"] {
   border-radius: 10px;
}
.child{
   display: inline-block;
   height: 40px;
   width: 40px;
   color: white;
   border: 4px solid black;
}
.child:nth-of-type(1){
   background-color: #FF8A00;
}
.child:nth-of-type(2){
   background-color: #F44336;
}
.child:nth-of-type(3){
   background-color: #C303C3;
}
.child:nth-of-type(4){
   background-color: #4CAF50;
}
.child:nth-of-type(5){
   background-color: #03A9F4;
}
.child:nth-of-type(6){
   background-color: #FEDC11;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>CSS-Display-Inline-Block</legend>
<div id="container">
<div class="child"></div><div class="child"></div><div class="child"></div><div class="child"></div><div class="child"></div><div class="child"></div>
</div><br>
</body>
</html>
This will produce the following output −
Let’s see another example of CSS Display inline-block −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
#flex {
   display: flex;
}
#none {
   display: none;
}
.inline-block {
   display: inline-block;
   background-color: mintcream;
}
.grid {
   display: grid;
   background-color: cornflowerblue;
}
div {
   margin: 30px;
   padding: 5px;
   height: 10px;
   line-height: 5px;
   text-align: center;
   background-color: lightblue;
   border: 2px solid black;
}
div > div {
   background-color: lightpink;
   border: 2px solid green;
}
div > div > div {
   background-color: sandybrown;
   border: 2px solid darkred;
}
</style>
</head>
<body>
<div><span id="flex">One</span>
<div><span id="none">Two</span>
<div>
<span class="inline-block">Three</span>
<span class="inline-block">Four</span>
<div>
<span class="grid">Five</span>
<span class="grid">Six</span>
</div>
</div>
</div>
</div>
</body>
</html>
This will produce the following output −
GATE | GATE-CS-2016 (Set 2) | Question 41 - GeeksforGeeks

21 Nov, 2019
Consider a processor with 64 registers and an instruction set of size twelve. Each instruction has five distinct fields, namely, opcode, two source register identifiers, one destination register identifier, and a twelve-bit immediate value. Each instruction must be stored in memory in a byte-aligned fashion. If a program has 100 instructions, the amount of memory (in bytes) consumed by the program text is ____________
[Note that this was originally a Fill-in-the-Blanks question](A) 100(B) 200(C) 400(D) 500Answer: (D)Explanation: One instruction is divided into five parts,
(1): The opcode- As we have instruction set of size 12, an instruction opcode can be identified by 4 bits, as 2^4=16 and we cannot go any less.
(2) & (3): Two source register identifiers- As there are total 64 registers, they can be identified by 6 bits. As they are two i.e. 6 bit + 6 bit.
(4): One destination register identifier- Again it will be 6 bits.
(5): A twelve bit immediate value- 12 bit.
Adding them all we get,
= 4 + 6 + 6 + 6 + 12 
= 34 bit 
= 34/8 byte 
= 4.25 byte 
As given Each instruction must be stored in memory in a byte-aligned fashion,4.25 is not byte alignment, memory address should be 0,1,2,3,4,5,6,7........ so it should be 5 bytes.
As there are 100 instructions, we have a size of 5*100= 500 bytes.
Hence (D) 500 is the answer.Quiz of this Question
singhramesh56
GATE-CS-2016 (Set 2)
GATE-GATE-CS-2016 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-1) | Question 65
GATE | GATE-CS-2015 (Set 1) | Question 42
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2004 | Question 3
Named function expression in JavaScript

Following is the code to implement named function expression in JavaScript.
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 20px;
      font-weight: 500;
      color: blueviolet;
   }
</style>
</head>
<body>
<h1>Named function expression in JavaScript.</h1>
<div class="result"></div>
<br />
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to call the fact function expression of obj object</h3>
<script>
   let resEle = document.querySelector(".result");
   let BtnEle = document.querySelector(".Btn");
   let obj = {
      fact: function factorial(n) {
         if (n <= 1) {
            return 1;
         }
         return n * factorial(n - 1);
      },
   };
   BtnEle.addEventListener("click", () => {
      resEle.innerHTML = obj.fact(5);
   });
</script>
</body>
</html>
On clicking the ‘CLICK HERE’ button −
Lodash - difference method

_.difference(array, [values])

Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons. The order and references of result values are determined by the first array.
array (Array) − The array to inspect.
array (Array) − The array to inspect.
[values] (...Array) − The values to exclude.
[values] (...Array) − The values to exclude.
(Array) − Returns the new array of filtered values.
(Array) − Returns the new array of filtered values.
var _ = require('lodash');
var numbers = [1, 2, 3, 4];
var listOfNumbers = '';

listOfNumbers = _.difference(numbers, [2]);
console.log(listOfNumbers);
Save the above program in tester.js. Run the following command to execute this program.
\>node tester.js

[ 1, 3, 4 ]

 Print
 Add Notes
 Bookmark this page
Matplotlib.figure.Figure.set_tight_layout() in Python - GeeksforGeeks

03 May, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot elements.
The set_tight_layout() method figure module of matplotlib library is used to set whether and how tight_layout is called when drawing.
Syntax: set_tight_layout(self, tight)
Parameters: This method accept the following parameters that are discussed below:
tight : This parameters contains the boolean value or dict with keys “pad”, “w_pad”, “h_pad”, “rect” or None.
Returns: This method does not returns any value.
Below examples illustrate the matplotlib.figure.Figure.set_tight_layout() function in matplotlib.figure:
Example 1:
# Implementation of matplotlib function import numpy as npimport matplotlib.pyplot as plt           x = np.arange(-5, 5, 0.01)y1 = -3*x*x + 10*x + 10y2 = 3*x*x + x     fig, ax = plt.subplots()fig.tight_layout()ax.plot(x, y1, x, y2, color='black')  ax.fill_between(x, y1, y2,                 where = y2 >y1,                facecolor = 'green',                alpha = 0.8)  ax.fill_between(x, y1, y2,                 where = y2 <= y1,                facecolor = 'black',                alpha = 0.8)    fig.set_tight_layout(True)        fig.canvas.draw()  fig.suptitle("""matplotlib.figure.Figure.set_tight_layout()function Example\n\n""",fontweight="bold")   plt.show() 
Output:
Example 2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport matplotlib.tri as mtriimport numpy as np            # Create triangulation.x = np.asarray([0, 1, 2, 3,                0.5, 1.5,                2.5, 1, 2,                1.5])  y = np.asarray([0, 0, 0, 0,                1.0, 1.0, 1.0,                2, 2, 3.0])  triangles = [[0, 1, 4], [1, 5, 4],             [2, 6, 5], [4, 5, 7],             [5, 6, 8], [5, 8, 7],              [7, 8, 9], [1, 2, 5],              [2, 3, 6]]  triang = mtri.Triangulation(x, y, triangles)z = np.cos(1.5 * x) * np.cos(1.5 * y)      fig, axs = plt.subplots()  axs.tricontourf(triang, z)axs.triplot(triang, 'go-', color ='white')fig.tight_layout(rect =(0.1, 0.1, 0.95, 0.95))   fig.set_tight_layout(False)       fig.canvas.draw()  fig.suptitle("""matplotlib.figure.Figure.set_tight_layout()function Example\n\n""", fontweight ="bold")   plt.show() 
Output:
Matplotlib figure-class
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Defaultdict in Python
Python OOPs Concepts
Python | os.path.join() method
Python | Pandas dataframe.groupby()
DAX Filter - ALLNOBLANKROW function

Returns all rows but the blank row, or all distinct values of a column but the blank row from the parent table of a relationship and disregards any context filters that might exist.
ALLNOBLANKROW (<table>|<column>) 

table
The table over which all context filters are removed.
column
The column over which all context filters are removed.
ALLNOBLANKROW takes only one argument, either table or column.
A table, when the argument is a table.
A column of values, when the argument is a column.
ALLNOBLANKROW function does not consider truly blank rows in a table, but only handles the blank row that is a special case generated in a parent table, when one or more of the child tables in the relationship contain non-matching values or blank values.
= COUNTROWS (ALLNOBLANKROW (Salesperson)) 
This DAX formula returns 7, if the number of rows in the parent Salesperson table is 7. However, there are entries in the Sales table for an unaccounted salesperson (i.e. the salesperson is not present in the Salesperson table).
= COUNTROWS (ALL (Salesperson))
This DAX formula returns 8 though the number of rows in the parent Salesperson table is 7, as there are entries in the Sales table for an unaccounted salesperson (i.e. the salesperson is not present in the Salesperson table).

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Decidability Table in Theory of Computation

28 Oct, 2020
Prerequisite – Undecidability, Decidable and undecidable problems Identifying languages (or problems*) as decidable, undecidable or partially decidable is a very common question in GATE. With correct knowledge and ample experience, this question becomes very easy to solve. 
A language is undecidable if it is not decidable. An undecidable language maybe a partially decidable language or something else but not decidable. If a language is not even partially decidable , then there exists no Turing machine for that language. 
In this topic you will see Decidability table and shortcut to learn them. 
Intersection of 2 recursively enumerable languages is recursively enumerable, so it is decidable.
 
In the above table,  
'RL' implies Regular language.
'CFL' implies Context free language.
'DCFL' implies deterministic context free language.
'CSL' implies Context sensitive language.
'REC.L' implies Recursive language.
'REL' implies Recursive enumerable language.
'D' implies that the problem is decidable.
'UD' implies that the problem is undecidable.


Note:  
Regular language: It Decidable for all problems.CFL: It is decidable for emptiness problem, finiteness problem, and membership problem.CSL and REC.L: Both are decidable for membership problem, Is compliment of ‘L’ a language of same type or not?, and (Is intersection of two languages of same type or not?.REC: It is decidable for (Is intersection of two languages of same type or not?)DCFL It is decidable for everything decidable in CFL plus (Is compliment of ‘L’ a language of same type or not?), (Is ‘L’ regular language?).
Regular language: It Decidable for all problems.
CFL: It is decidable for emptiness problem, finiteness problem, and membership problem.
CSL and REC.L: Both are decidable for membership problem, Is compliment of ‘L’ a language of same type or not?, and (Is intersection of two languages of same type or not?.
REC: It is decidable for (Is intersection of two languages of same type or not?)
DCFL It is decidable for everything decidable in CFL plus (Is compliment of ‘L’ a language of same type or not?), (Is ‘L’ regular language?).
 
absh2702
manojmaurya007
DileepNagendra
rakshitshandilya
GATE CS
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Clustered and Non-clustered index
Three address code in Compiler
Differences between IPv4 and IPv6
Introduction of Process Synchronization
Phases of a Compiler
Introduction of Finite Automata
Difference between DFA and NFA
Turing Machine in TOC
Chomsky Hierarchy in Theory of Computation
Boyer-Moore Majority Voting Algorithm
Angular Material 7 - Expansion Panel

The <mat-expansion-panel>, an Angular Directive, is used to create an expandable detail v/s summary view.
<mat-expansion-panel-header> − Represents the header section. Contains summary of panel and acts as control to expand or collapse the panel.
<mat-expansion-panel-header> − Represents the header section. Contains summary of panel and acts as control to expand or collapse the panel.
<mat-panel-title> − Represents the panel title.
<mat-panel-title> − Represents the panel title.
<mat-panel-description> − Represents the panel summary.
<mat-panel-description> − Represents the panel summary.
<mat-action-row> − Represents the actions panel at the bottom.
<mat-action-row> − Represents the actions panel at the bottom.
In this chapter, we will showcase the configuration required to draw a expansion control using Angular Material.
Follow the following steps to update the Angular application we created in Angular 6 - Project Setup chapter −
Following is the content of the modified module descriptor app.module.ts.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MatExpansionModule, MatInputModule} from '@angular/material'
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
@NgModule({
   declarations: [
      AppComponent
   ],
   imports: [
      BrowserModule,
      BrowserAnimationsModule,
      MatExpansionModule, MatInputModule,
      FormsModule,
      ReactiveFormsModule
   ],
   providers: [],
   bootstrap: [AppComponent]
})
export class AppModule { }
Following is the content of the modified HTML host file app.component.html.
<mat-expansion-panel>
   <mat-expansion-panel-header>
      <mat-panel-title>
         Personal data
      </mat-panel-title>
      <mat-panel-description>
         Type name and age
      </mat-panel-description>
   </mat-expansion-panel-header>
   <mat-form-field>
      <input matInput placeholder="Name">
   </mat-form-field>
   <mat-form-field>
      <input matInput placeholder="Age">
   </mat-form-field>
</mat-expansion-panel>
Verify the result.
As first, we've created expansion panel using mat-expansion-panel.
Then, we've added title, subtitle and content to it.

    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
How to display length of filtered ng-repeat data in AngularJS ? - GeeksforGeeks

30 Nov, 2019
The task is to Display the length of filtered ng-repeat data. Here we are going to use alias expression to solve this problem.
Approach: To display the length of filtered ng-repeat data we use an alias expression. We create an alias for the variable used to filter the ng-repeat data and display the length of the alias at each moment.
Syntax:
<element ng-repeat="expression | filter: search as result"> Content... </element>
<p> {{ result.length }} <p>

Example:
<!DOCTYPE html><html>      <head>    <title>        Angular JS Filtered data length    </title>          <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">    </script></head>      <body >     <h1 style = "color:green; text-align:center;" >         GeeksForGeeks     </h1>           <div ng-app = "mainApp" ng-controller = "studentController">        <input type = "text" ng-model = "searchName">            <br/>                  <ul>            <li ng-repeat =                 "student in students | filter: searchName as result">                {{ student.name + ', marks:' + student.marks }}            </li>        </ul>        <p>length of filtered data:- {{ result.length }}</p>    </div>          <script>        var mainApp = angular.module("mainApp", []);                  mainApp.controller('studentController', function($scope) {            $scope.students = [                {name:'Aman', marks:70},                {name:'Aditya', marks:80},                {name:'Pratyush', marks:92},                {name:'Prakhar', marks:95},                {name:'Pranjal', marks:75},                {name:'Sunny', marks:69}            ];        });    </script></body>  </html>
Explanation:Here, we are displaying the details of students and there is a search box to search by name of student. Now, we bind the input of that search box in AngularJS searchName variable. SearchName variable is used to filter, we create an alias of it which is result here and then we display the result.length. So as the length of filtered ng-repeat data change, length of result also change.
Output:Initial screen would be:Then after the search, filtered ng-repeat data length change:
AngularJS-Misc
Picked
AngularJS
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Angular Libraries For Web Developers
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular 10 (focus) Event
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
RxJava - NewThread Scheduler

Schedulers.newThread() method creates and returns a Scheduler that creates a new Thread for each unit of work.
Create the following Java program using any editor of your choice in, say, C:\> RxJava.
import java.util.Random;

import io.reactivex.Observable;
import io.reactivex.schedulers.Schedulers;

public class ObservableTester  {
   public static void main(String[] args) throws InterruptedException {
      Observable.just("A", "AB", "ABC")
         .flatMap(v -> getLengthWithDelay(v)
         .doOnNext(s -> System.out.println("Processing Thread " 
            + Thread.currentThread().getName()))
         .subscribeOn(Schedulers.newThread()))
         .subscribe(length -> System.out.println("Receiver Thread " 
            + Thread.currentThread().getName() 
            + ", Item length " + length));

         Thread.sleep(10000);
   }
   protected static Observable<Integer> getLengthWithDelay(String v) {
      Random random = new Random();
      try {
         Thread.sleep(random.nextInt(3) * 1000);
         return Observable.just(v.length());
      } catch (InterruptedException e) {
         e.printStackTrace();
      }
      return null;
   }
}
Compile the class using javac compiler as follows −
C:\RxJava>javac ObservableTester.java

Now run the ObservableTester as follows −
C:\RxJava>java ObservableTester

It should produce the following output −
Processing Thread RxNewThreadScheduler-1
Receiver Thread RxNewThreadScheduler-1, Item length 1
Processing Thread RxNewThreadScheduler-2
Receiver Thread RxNewThreadScheduler-2, Item length 2
Processing Thread RxNewThreadScheduler-3
Receiver Thread RxNewThreadScheduler-3, Item length 3

 Print
 Add Notes
 Bookmark this page
C/C++ Preprocessor Directives

In C or C++, we have find different lines stared with (#) symbol. These are called the preprocessing directives. These lines are processed in the preprocessing phase before compiling the code. Here we will see three different types of preprocessing directives. These are −
Conditional Compilation
Line control
Error Directive
Sometimes we define some macros in our program. Using conditional compilation directives. we can check whether the macro is defined or not. We can also control them. So if one macro is defined, then do some task, otherwise do some other task like that.
The conditional compilation directives are like #ifdef-#elif-#else-#endif. Every #ifdef block must be ended with #endif. The #elif or #else are optional.
#include <iostream>
#define MY_MACRO 10
using namespace std;
int main() {
   #ifdef MACRO
   cout << "MACRO is defined" << endl;
   #elif MY_MACRO
   cout << "MY_MACRO is defined, value is: " << MY_MACRO;
   #endif
}
MY_MACRO is defined, value is: 10
The line control directive is used by typing #line. Sometimes we get some error with preferred line number. We can update the line number using this directive. If we place this and change the current line as 200, then after that the lines will move from 201 onwards.
#include <iostream>
using namespace std;
int main() {
   cout<< "Current line is: " << __LINE__ << endl;
   #line 200
   cout << "Hello" << endl;
   cout << "World" << endl;
   cout<< "Current line is: " << __LINE__ << endl;
}
Current line is: 5
Hello
World
Current line is: 202
The error directive is used to show an error before compiling. Suppose one macro should be defined but if that is not defined, we can show an error message. This can be done using #error.
#include <iostream>
using namespace std;
int main() {
   #ifdef MY_MACRO
   cout << "MY_MACRO is defined, value is: " << MY_MACRO;
   #else
   #error MY_MACRO should be defined
   #endif
}
#error MY_MACRO should be defined
Introduction of Single Accumulator based CPU organization

13 Jan, 2022
The computers, present in the early days of computer history, had accumulator-based CPUs. In this type of CPU organization, the accumulator register is used implicitly for processing all instructions of a program and storing the results into the accumulator. The instruction format that is used by this CPU Organisation is the One address field. Due to this, the CPU is known as One Address Machine. 
The main points about Single Accumulator based CPU Organisation are: 
In this CPU Organization, the first ALU operand is always stored into the Accumulator and the second operand is present either in Registers or in the Memory. Accumulator is the default address thus after data manipulation the results are stored into the accumulator. One address instruction is used in this type of organization. 
In this CPU Organization, the first ALU operand is always stored into the Accumulator and the second operand is present either in Registers or in the Memory. 
Accumulator is the default address thus after data manipulation the results are stored into the accumulator. 
One address instruction is used in this type of organization. 
The format of instruction is: Opcode + Address
Opcode indicates the type of operation to be performed. Mainly two types of operation are performed in a single accumulator based CPU organization:  
1. Data transfer operation – In this type of operation, the data is transferred from a source to a destination. 
For ex: LOAD X, STORE Y 
Here LOAD is a memory read operation that is data is transferred from memory to accumulator and STORE is a memory write operation that is data is transferred from the accumulator to memory. 
2. ALU operation – In this type of operation, arithmetic operations are performed on the data. 
For ex: MULT X 
where X is the address of the operand. The MULT instruction in this example performs the operation, 
AC <-- AC * M[X] 
AC is the Accumulator and M[X] is the memory word located at location X. 
This type of CPU organization is first used in PDP-8 processors and is used for process control and laboratory applications. It has been totally replaced by the introduction of the new general register-based CPU. 
Advantages –  
One of the operands is always held by the accumulator register. This results in short instructions and less memory space. 
The instruction cycle takes less time because it saves time in instruction fetching from memory. 
Disadvantages – 
When complex expressions are computed, program size increases due to the usage of many short instructions to execute it. Thus memory size increases. 
As the number of instructions increases for a program, the execution time increases.  
 
tanwarsinghvaibhav
microprocessor
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream flatMapToInt() in Java with examples

06 Dec, 2018
Stream flatMapToInt(Function mapper) returns an IntStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Stream flatMapToInt(Function mapper) is an intermediate operation. These operations are always lazy. Intermediate operations are invoked on a Stream instance and after they finish their processing, they give a Stream instance as output.
Note : Each mapped stream is closed after its contents have been placed into this stream. If a mapped stream is null, an empty stream is used, instead.Syntax :
IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper)

Where, IntStream is a sequence of primitive 
int-valued elements and T is the type 
of stream elements. mapper is a stateless function 
which is applied to each element and the function
returns the new stream.

Example 1 : flatMapToInt() function with operation of parsing string to Integer.
// Java code for Stream flatMapToInt// (Function mapper) to get an IntStream// consisting of the results of replacing// each element of this stream with the// contents of a mapped stream.import java.util.*;import java.util.stream.IntStream;  class GFG {      // Driver code    public static void main(String[] args)    {          // Creating a list of Strings        List<String> list = Arrays.asList("1", "2", "3",                                          "4", "5");          // Using Stream flatMapToInt(Function mapper)        list.stream().flatMapToInt(num -> IntStream.of(Integer.parseInt(num))).        forEach(System.out::println);    }}
Output :
1
2
3
4
5

Example 2 : flatMapToInt() function with operation of mapping string with their length.
// Java code for Stream flatMapToInt// (Function mapper) to get an IntStream// consisting of the results of replacing// each element of this stream with the// contents of a mapped stream.import java.util.*;import java.util.stream.IntStream;  class GFG {      // Driver code    public static void main(String[] args)    {          // Creating a List of Strings        List<String> list = Arrays.asList("Geeks", "GFG",                                          "GeeksforGeeks", "gfg");          // Using Stream flatMapToInt(Function mapper)        // to get length of all strings present in list        list.stream().flatMapToInt(str -> IntStream.of(str.length())).        forEach(System.out::println);    }}
Output :
5
3
13
3

Java - util package
Java-Functions
java-stream
Java-Stream interface
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to check if a column exist in a MySQL table?

To understand whether a column exist or not, we have the following approaches −
With the help of DESC command
Using SHOW command
Firstly, we will create a table with columns −
mysql> CREATE table ColumnExistDemo
-> (
-> UniqueId int,
-> UniqueName varchar(200),
-> UniqueAddress varchar(200)
-> );
Query OK, 0 rows affected (0.57 sec)
In the first approach, we will get the entire column name with meaningful information. The syntax is as follows −
DESC yourTableName;

Let us apply the above query to check whether the column name exists or not. However, this approach is not good since it display all the columns.
mysql> DESC ColumnExistDemo;
The following is the output
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| UniqueId      | int(11)      | YES  |     | NULL    |       |
| UniqueName    | varchar(200) | YES  |     | NULL    |       | 
| UniqueAddress | varchar(200) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
The second approach is better, since we can check for a single column. The syntax is as
follows −
SHOW COLUMNS from `yourTableName` LIKE 'yourColumnName';

Now, I am applying the above query to check whether colum exist or not. The query is as
follows −
mysql> SHOW COLUMNS from `ColumnExistDemo` LIKE 'UniqueName';
The following is the output
+------------+--------------+------+-----+---------+-------+
| Field      | Type         | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| UniqueName | varchar(200) | YES  |     | NULL    |       |
+------------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)
MySQL INSERT INTO Statement

The INSERT INTO statement is used to insert new records in a table.
It is possible to write the INSERT INTO 
statement in two ways:
1. Specify both the column names and the values to be inserted:
2. If you are adding values for all the columns of the table, you do not need to 
specify the column names in the SQL query. However, make sure the order of the 
values is in the same order as the columns in the table. Here, the 
INSERT INTO syntax 
would be as follows:
Below is a selection from the "Customers" table in the Northwind 
sample database:
The following SQL statement inserts a new record in the "Customers" table:
The selection from the "Customers" table will now look like this:
Did you notice that we did not insert any number into the CustomerID 
field?The CustomerID column is 
an auto-increment field and will be 
generated automatically when a new record is inserted into the table.
It is also possible to only insert data in specific columns.
The following SQL statement will insert a new record, but only insert data in the "CustomerName", 
"City", and "Country" columns (CustomerID will 
be updated automatically):
The selection from the "Customers" table will now look like this:
Insert a new record in the Customers table.
 Customers 
CustomerName, 
Address, 
City, 
PostalCode,
Country
 
'Hekkan Burger',
'Gateveien 15',
'Sandnes',
'4306',
'Norway';

Start the Exercise
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.
Ansible - Advanced Execution

In this chapter, we will learn what is advanced execution with Ansible.
This is a very important execution strategy where one needs to execute only one execution and not the entire playbook. For example, suppose you only want to stop a server (in case a production issue comes) and then post applying a patch you would like to only start the server.
Here in original playbook stop and start were a part of different roles in the same playbook but this can be handled with the usage of tags. We can provide different tags to different roles (which in turn will have tasks) and hence based on the tags provided by the executor only that specified role/task gets executed. So for the above example provided, we can add tags like the following −
- {role: start-tomcat, tags: ['install']}} 

The following command helps in using tags −
ansible-playbook -i hosts <your yaml> --tags "install" -vvv

With the above command, only the start-tomcat role will be called. The tag provided is case-sensitive. Ensure exact match is being passed to the command.
There are two ways to achieve the execution of specific steps on specific hosts. For a specific role, one defines the hosts - as to which specific hosts that specific role should be run.
- hosts: <A> 
   environment: "{{your env}}" 
   pre_tasks: 
      - debug: msg = "Started deployment. 
      Current time is {{ansible_date_time.date}} {{ansible_date_time.time}} " 
     
   roles: 
      - {role: <your role>, tags: ['<respective tag>']} 
   post_tasks: 
      - debug: msg = "Completed deployment. 
      Current time is {{ansible_date_time.date}} {{ansible_date_time.time}}" 
 
- hosts: <B> 
   pre_tasks: 
      - debug: msg = "started.... 
      Current time is {{ansible_date_time.date}} {{ansible_date_time.time}} " 
        
   roles: 
      - {role: <your role>, tags: ['<respective tag>']} 
   post_tasks: 
      - debug: msg = "Completed the task.. 
      Current time is {{ansible_date_time.date}} {{ansible_date_time.time}}" 
As per the above example, depending on the hosts provided, the respective roles will only be called. Now my hosts A and B are defined in the hosts (inventory file).
A different solution might be defining the playbook's hosts using a variable, then passing in a specific host address via --extra-vars −
# file: user.yml  (playbook) 
--- 
- hosts: '{{ target }}' 
   user: ... 
playbook contd.... 
ansible-playbook user.yml --extra-vars "target = "<your host variable>"

If {{ target }} isn't defined, the playbook does nothing. A group from the hosts file can also be passed through if need be. This does not harm if the extra vars is not provided.
$ ansible-playbook user.yml --extra-vars "target = <your hosts variable>" --listhosts 


    41 Lectures 
     5 hours 

 AR Shankar

    11 Lectures 
     58 mins

 Musab Zayadneh

    59 Lectures 
     15.5 hours 

 Narendra P

    11 Lectures 
     1 hours 

 Sagar Mehta

    39 Lectures 
     4 hours 

 Vikas Yadav

    4 Lectures 
     3.5 hours 

 GreyCampus Inc.
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: HTML subscripted text
Create multiple select list in Bootstrap

To create multiple select lists in Bootstrap, use multiple,
<select multiple class = "form-control">
You can try to run the following code to implement multiple select −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <form role = "form">
         <div class = "form-group">
            <label for = "name">Country</label>
            <select multiple class = "form-control">
               <option>India</option>
               <option>Australia</option>
               <option>US</option>
            </select>
         </div>
      </form>
   </body>
</html>
C# Program to write an array to a file

Use WriteAllLines method to write an array to a file.
Firstly, set a string array −
string[] stringArray = new string[] {
   "one",
   "two",
   "three"
};
Now, use the WriteAllLines method to add the above array to a file −
File.WriteAllLines("new.txt", stringArray);
Here is the complete code −
 Live Demo
using System.IO;
using System;
public class Program {
   public static void Main() {
      string[] stringArray = new string[] {
         "one",
         "two",
         "three"
      };
      File.WriteAllLines("new.txt", stringArray);
      using (StreamReader sr = new StreamReader("new.txt")) {
         string res = sr.ReadToEnd();
         Console.WriteLine(res);
      }
   }
}
one
two
three
LinkedHashSet clone() Method in Java with Examples - GeeksforGeeks

18 Nov, 2021
The clone() method of LinkedHashSet class is used to return a shallow copy of the mentioned hash set. It just creates a copy of the set.
--> java.util Package
     --> LinkedHashSet Class
         --> clone() Method   
Syntax: 
linked_hash_set.clone()
Parameters: The method does not take any parameters.
Return Type: The method just returns a copy of the LinkedHashSet.
Example:
Java
// Java Program to illustrate clone() Method// of LinkedHashSet Class  // Importing required classesimport java.io.*;import java.util.LinkedHashSet;  // Main classpublic class GFG {      // Main driver method    public static void main(String args[])    {        // Creating an empty LinkedHashSet        LinkedHashSet<String> set            = new LinkedHashSet<String>();          // Adding elements into the Set        // using add() method        set.add("Welcome");        set.add("To");        set.add("Geeks");        set.add("4");        set.add("Geeks");          // Displaying the LinkedHashSet        System.out.println("LinkedHashSet: " + set);          // Creating a new cloned Set        LinkedHashSet cloned_set = new LinkedHashSet();          // Cloning the above Set        // using clone() method        cloned_set = (LinkedHashSet)set.clone();          // Displaying the new Set after Cloning        System.out.println("The new set: " + cloned_set);    }}
LinkedHashSet: [Welcome, To, Geeks, 4]
The new set: [Welcome, To, Geeks, 4]
 
solankimayank
Java-Functions
java-LinkedHashSet
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional Interfaces in Java
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Generics in Java
Comparator Interface in Java with Examples
Strings in Java
How to remove an element from ArrayList in Java?
Difference between Abstract Class and Interface in Java
GATE | GATE-CS-2015 (Set 1) | Question 65 - GeeksforGeeks

28 Jun, 2021
Match the following
       List-I                            List-II
A. Condition coverage                 1. Black-box testing
B. Equivalence class partitioning     2. System testing
C. Volume testing                     3. White-box testing
D. Alpha testing                      4. Performance testing

Codes:
   A B C D
(a) 2 3 1 4
(b) 3 4 2 1
(c) 3 1 4 2
(d) 3 1 2 4
(A) a(B) b(C) c(D) dAnswer: (C)Explanation: White Box Testing tests internal structures or workings of an application. It covers followingControl flow testingData flow testingBranch testingStatement coverageDecision coverageModified condition/decision coveragePrime path testingPath testingSo conditional coverage must be in White-Box Testing.Black-box testing is a method of software testing that examines the functionality of an application without peering into its internal structures or workings. Typical black-box test design techniques include:Decision table testingAll-pairs testingEquivalence partitioningBoundary value analysisCause–effect graphError guessingVolume Testing Does performance testing for specific size.
Alpha testing is system testing by potential users/customers or an independent test team at the developers’ site.Quiz of this Question
GATE-CS-2015 (Set 1)
GATE-GATE-CS-2015 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2019 | Question 27
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2000 | Question 43
GATE | GATE-CS-2017 (Set 2) | Question 42
GATE | Gate IT 2007 | Question 30
GATE | GATE CS 2021 | Set 1 | Question 47
GATE | GATE MOCK 2017 | Question 19
HTML5 - Entities Reference

Some characters are reserved in HTML5. For example, you cannot use the greater than and less than signs or angle brackets within your text because the browser could mistake them for markup.
HTML5 processors must support the five special characters listed in the table that follows.
To write an element and attribute into your page so that the code is shown to the user rather than being processed by the browser (for example as <div id="character">) you would write −
&div id="character"&gt;

There is also a long list of special characters that HTML5 aware processors should support. In order for these to appear in your document, you can use either the numerical code or the entity name. For example, to insert a copyright symbol you could use either of the following −
&copy; 2007
 
or
 
&#169; 2007

ISO 8859-1 Character set is the most widly used character set. A complete reference of ISO 885901 character set is gievn below.

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Different ways to overload a method in Java

Method overloading can be achieved in following three ways −
By changing the number of parameters in the method.
By changing the order of parameter types
By changing the data types of the parameters.
See the example below−
 Live Demo
public class Tester {
   public static void main(String args[]) {
      Tester tester = new Tester();
      System.out.println(tester.add(1, 2));
      System.out.println(tester.add(1, 2,3));
      System.out.println(tester.add(1.0f, 2,3));
      System.out.println(tester.add(1, 2.0f,3));
   }
   public int add(int a, int b) {
      return a + b;
   }
   public int add(int a, int b, int c) {
      return a + b + c;
   }
   public float add(float a, int b, int c) {
      return a + b + c;
   }
   public float add(int a, float b, int c) {
      return a + b + c;
   }
}
3
6
6.0
6.0