code-rag-bench/online-tutorials huggingface dataset:
BigIntegerField - Django Models - GeeksforGeeks

12 Feb, 2020
BigIntegerField is a 64-bit integer, much like an IntegerField except that it is guaranteed to fit numbers from -9223372036854775808 to 9223372036854775807. The default form widget for this field is a TextInput.
Syntax
field_name = models.BigIntegerField(**options)
Illustration of BigAutoField using an Example. Consider a project named geeksforgeeks having an app named geeks.
Refer to the following articles to check how to create a project and an app in Django.
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Enter the following code into models.py file of geeks app.
from django.db import modelsfrom django.db.models import Model# Create your models here.  class GeeksModel(Model):    geeks_field = models.BigIntegerField()
Add the geeks app to INSTALLED_APPS
# Application definition  INSTALLED_APPS = [    'django.contrib.admin',    'django.contrib.auth',    'django.contrib.contenttypes',    'django.contrib.sessions',    'django.contrib.messages',    'django.contrib.staticfiles',    'geeks',]
Now when we run makemigrations command from the terminal,
Python manage.py makemigrations
A new folder named migrations would be created in geeks directory with a file named 0001_initial.py
# Generated by Django 2.2.5 on 2019-09-25 06:00  from django.db import migrations, models  class Migration(migrations.Migration):      initial = True      dependencies = [    ]      operations = [        migrations.CreateModel(            name ='GeeksModel',            fields =[                ('big_id',                   models.BigAutoField(auto_created = True,                  primary_key = True,                  serialize = False,                   verbose_name ='ID'                )),                ('geeks_field', models.BigIntegerField()),            ],        ),    ]
Thus, an geeks_field BigIntegerField is created when you run makemigrations on the project. It is a field which can store integers ranging from -9223372036854775808 to 9223372036854775807.
If we create objects of this model from the admin server. we can see geeks_field where one can store numbers.
Field Options are the arguments given to each field for applying some constraint or imparting a particular characteristic to a particular Field. For example, adding an argument null = True to BigIntegerField will enable it to store empty values for that table in relational database.Here are the option and attributes that an BigIntegerfield can use.
NaveenArora
Django-models
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
sum() function in Python
*args and **kwargs in Python
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Ext.js - Architecture

Ext JS follows MVC/ MVVM architecture.
MVC − Model View Controller architecture (version 4)
MVVM − Model View Viewmodel (version 5)
This architecture is not mandatory for the program, however, it is a best practice to follow this structure to make your code highly maintainable and organized.
----------src
----------resources
-------------------CSS files
-------------------Images
----------JavaScript
--------------------App Folder
-------------------------------Controller
------------------------------------Contoller.js
-------------------------------Model
------------------------------------Model.js
-------------------------------Store
------------------------------------Store.js
-------------------------------View
------------------------------------View.js
-------------------------------Utils
------------------------------------Utils.js
--------------------------------app.js
-----------HTML files

Ext JS app folder will reside in JavaScript folder of your project.
The App will contain controller, view, model, store, and utility files with app.js.
app.js − The main file from where the flow of program will start, which should be included in the main HTML file using <script> tag. App calls the controller of application for the rest of the functionality.
Controller.js − It is the controller file of Ext JS MVC architecture. This contains all the control of the application, the events listeners, and most of the functionality of the code. It has the path defined for all the other files used in that application such as store, view, model, require, mixins.
View.js − It contains the interface part of the application, which shows up to the user. Ext JS uses various UI rich views, which can be extended and customized here according to the requirement.
Store.js − It contains the data locally cached which is to be rendered on the view with the help of model objects. Store fetches the data using proxies which has the path defined for services to fetch the backend data.
Model.js − It contains the objects which binds the store data to view. It has the mapping of backend data objects to the view dataIndex. The data is fetched with the help of store.
Utils.js − It is not included in MVC architecture but a best practice to use to make the code clean, less complex, and more readable. We can write methods in this file and call them in the controller or the view renderer wherever required. It is helpful for code reusability purpose as well.
In MVVM architecture, the controller is replaced by ViewModel.
ViewModel − It basically mediates the changes between view and model. It binds the data from the model to the view. At the same time, it does not have any direct interaction with the view. It has only knowledge of the model.
For example, if we are using one model object at two-three places in UI. If we change the value at one place of UI, we can see without even saving that change. The value of model changes and so gets reflected in all the places in the UI, wherever the model is used.
It makes the developer's effort much lesser and easier as no extra coding is required for binding data.
 Print
 Add Notes
 Bookmark this page
What is finally statement in C#?

The final block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not.
The error handling blocks are implemented using the try, catch, and finally keywords.
You can try to run the following code to implement finally statement −
using System;

namespace ErrorHandlingApplication {
   class DivNumbers {
      int result;

      DivNumbers() {
         result = 0;
      }

      public void division(int num1, int num2) {
         try {
            result = num1 / num2;
         } catch (DivideByZeroException e) {
            Console.WriteLine("Exception caught: {0}", e);
         } finally {
            Console.WriteLine("Result: {0}", result);
         }
      }

      static void Main(string[] args) {
         DivNumbers d = new DivNumbers();
         d.division(25, 0);
         Console.ReadKey();
      }
   }
}
Contains Duplicate II in C++

Suppose we have an array and an integer k, we have to check whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.
So, if the input is like [1,2,4,1] and k = 3, then the output will be True
To solve this, we will follow these steps −
Define an array nn of pairs
Define an array nn of pairs
for initialize i := 0, when i − size of nums, update (increase i by 1), do −insert {nums[i], i} at the end of nn
for initialize i := 0, when i − size of nums, update (increase i by 1), do −
insert {nums[i], i} at the end of nn
insert {nums[i], i} at the end of nn
sort the array nn
sort the array nn
for initialize i := 1, when i < size of nn, update (increase i by 1), do −if first element of nn[i] is same as first element of nn[i - 1] and |second of nn[i] - second of nn[i - 1]|, then −return true
for initialize i := 1, when i < size of nn, update (increase i by 1), do −
if first element of nn[i] is same as first element of nn[i - 1] and |second of nn[i] - second of nn[i - 1]|, then −return true
if first element of nn[i] is same as first element of nn[i - 1] and |second of nn[i] - second of nn[i - 1]|, then −
return true
return true
return false
return false
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   bool containsNearbyDuplicate(vector<int>& nums, int k) {
      vector<pair<int, int> > nn;
      for (<) {
         nn.push_back(make_pair(nums[i], i));
      }
      sort(nn.begin(), nn.end());
      for (int i = 1; i < nn.size(); i++) {
         if (nn[i].first == nn[i - 1].first and abs(nn[i].second - nn[i - 1].second) <= k)
            return true;
         }
         return false;
      }
};
main(){
   Solution ob;
   vector<int> v = {1,2,4,1};
   cout << (ob.containsNearbyDuplicate(v, 3));
}
{1,2,4,1}
1
How do you create line segments between two points in Matplotlib?

To create line segments between two points in matplotlib, we can take the following steps
Set the figure size and adjust the padding between and around the subplots.
To make two points, create two lists.
Extract x and y values from point1 and point2.
Plot x and y values using plot() method.
Place text for both the points.
To display the figure, use show() method.
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
point1 = [1, 2]
point2 = [3, 4]
x_values = [point1[0], point2[0]]
y_values = [point1[1], point2[1]]
plt.plot(x_values, y_values, 'bo', linestyle="--")
plt.text(point1[0]-0.015, point1[1]+0.25, "Point1")
plt.text(point2[0]-0.050, point2[1]-0.25, "Point2")
plt.show()
Print all full nodes in a Binary Tree in C++

In this problem, we are given a binary tree. Our task is to print all nodes of the tree that are full nodes.
The binary tree is a tree in which a node can have a maximum of 2 child nodes. Node or vertex can have no nodes, one child or two child nodes.
Example −
A full node is a node that has both its left and right child available. In other words, a node with the left and right child is a full node. In the above binary tree, 4 and 9 are full nodes.
Let’s take an example to understand the problem −
Output − 4 9
A simple and easy approach to solve this problem is to traverse the tree using any traversal algorithm. Check if the current node has left and right children or node. If yes then print the node’s value otherwise leave it.
Program to illustrate our solution,
 Live Demo
#include <iostream>
using namespace std;
struct Node{
   int data;
   struct Node *left, *right;
};
Node *insertNode(int data){
   Node *temp = new Node;
   temp->data = data;
   temp->left = temp->right = NULL;
   return temp;
}
void printFullNode(Node *root){
   if (root != NULL){
      printFullNode(root->left);
      if (root->left != NULL && root->right != NULL)
         cout<<root->data<<"\t";
      printFullNode(root->right);
   }
}
int main(){
   Node* root = insertNode(100);
   root->left = insertNode(56);
   root->right = insertNode(12);
   root->left->left = insertNode(89);
   root->right->left = insertNode(32);
   root->right->right = insertNode(45);
   cout<<"All full nodes of the tree are :\n";
   printFullNode(root);
   return 0;
}
All full nodes of the tree are −
100 12
Check whether a value exists in JSON object?

Let’s say the following is our object −
var apiJSONObject =
[
   {subjectName:"MySQL"},
   {subjectName:"Java"},
   {subjectName:"JavaScript"},
   {subjectName:"MongoDB"}
]
Let’s check for existence of a value “JavaScript” −
var apiJSONObject =
[
   {subjectName:"MySQL"},
   {subjectName:"Java"},
   {subjectName:"JavaScript"},
   {subjectName:"MongoDB"}
]
for(var i=0;i<apiJSONObject.length;i++){
   if(apiJSONObject[i].subjectName=="JavaScript"){
      console.log("The search found in JSON Object");
      break;
   }
}
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo117.js.
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo117.js
The search found in JSON Object
kill() - Unix, Linux System Call

Unix - Home
Unix - Getting Started
Unix - File Management
Unix - Directories
Unix - File Permission
Unix - Environment
Unix - Basic Utilities
Unix - Pipes & Filters
Unix - Processes
Unix - Communication
Unix - The vi Editor
Unix - What is Shell?
Unix - Using Variables
Unix - Special Variables
Unix - Using Arrays
Unix - Basic Operators
Unix - Decision Making
Unix - Shell Loops
Unix - Loop Control
Unix - Shell Substitutions
Unix - Quoting Mechanisms
Unix - IO Redirections
Unix - Shell Functions
Unix - Manpage Help
Unix - Regular Expressions
Unix - File System Basics
Unix - User Administration
Unix - System Performance
Unix - System Logging
Unix - Signals and Traps
Unix - Useful Commands
Unix - Quick Guide
Unix - Builtin Functions
Unix - System Calls
Unix - Commands List
Unix Useful Resources
Computer Glossary
Who is Who
Copyright © 2014 by tutorialspoint
#include <sys/types.h> 

#include <signal.h> 

int kill(pid_t pid, int sig); 


int kill(pid_t pid, int sig); 


If pid is positive, then signal sig is sent to pid.


If pid equals 0, then sig is sent to every process in the
process group of the current process.


If pid equals -1, then sig is sent to every process
for which the calling process has permission to send signals,
except for process 1 (init), but see below.


If pid is less than -1, then sig is sent to every process
in the process group -pid.


If sig is 0, then no signal is sent, but error checking is still
performed.


For a process to have permission to send a signal
it must either be privileged (under Linux: have the
CAP_KILL capability), or the real or effective
user ID of the sending process must equal the real or
saved set-user-ID of the target process.
In the case of SIGCONT it suffices when the sending and receiving
processes belong to the same session.


POSIX.1-2001 requires that kill(-1,sig) send sig
to all processes that the current process may send signals to,
except possibly for some implementation-defined system processes.
Linux allows a process to signal itself, but on Linux the call
kill(-1,sig) does not signal the current process.


POSIX.1-2001 requires that if a process sends a signal to itself,
and the sending thread does not have the signal blocked,
and no other thread
has it unblocked or is waiting for it in sigwait(), at least one
unblocked signal must be delivered to the sending thread before the
kill().

_exit (2)
_exit (2)
killpg (2)
killpg (2)
signal (2)
signal (2)
sigqueue (2)
sigqueue (2)
tkill (2)
tkill (2)

Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Getting Tooltips for mobile browsers in HTML

When you will click on an element with a title attribute, a child element with title text is appended. Let us see an example −
For HTML −
<p>
   The <span class="demo" title="this is underscore">underlined</span> character.
</p>
jQuery −
$("span[title]").click(function () {
   var $title = $(this).find(".title");
   if (!$title.length) {
      $(this).append('<span class="title">' + $(this).attr("title") + '</span>');
   } else {
      $title.remove();
   }
});
The following is the CSS −
.demo {
   border-bottom: 2px dotted;
   position: relative;
}
.demo .title {
   position: absolute;
   top: 15px;
   background: gray;
   padding: 5px;
   left: 0;
   white-space: nowrap;
}
Installing TensorFlow. It isn’t as difficult as you may have... | by David R. Pugh | Towards Data Science

I have seen a growing number of articles floating around suggesting that installing TensorFlow is difficult. Building TensorFlow from source is definitely not for the faint of heart, but installing TensorFlow for use in your next GPU-accelerated data science project can be done in one line (if you use the right tool for the job).
With Conda (+pip) you can install the newest version of TensorFlow with GPU support in a single line.
conda create --name tensorflow-22 \    tensorflow-gpu=2.2 \    cudatoolkit=10.1 \    cudnn=7.6 \    python=3.8 \    pip=20.0
If you have never used Conda (+pip) before I recommend checking out Getting Started with Conda.
While the above one-line solution works great if you just want to get up and running quickly to try out some new feature of TensorFlow 2.2, if you are starting a new project using TensorFlow 2.2, then I would recommend creating an environment.yml file for your project and then installing your Conda environment as a sub-directory inside your project directory.
name: nullchannels:  - conda-forge  - defaultsdependencies:  - cudatoolkit=10.1  - cudnn=7.6  - nccl=2.4  - pip=20.0  - python=3.8  - tensorflow-gpu=2.2
conda env create --prefix ./env --file environment.yml --force
For more Conda “best practices” I recommend checking out Managing your data science project environments with Conda.
There are a number of benefits of using Conda (+pip) to install TensorFlow. Most importantly there is no need to manually install the NVIDIA CUDA Toolkit, cuDNN, or NVIDIA Collective Communications Library (NCCL). Installing TensorFlow into a virtual Conda environment instead of installing system-wide avoids touching the system Python and allows you to have multiple versions of TensorFlow installed on your machine (if needed). Finally, if you elect to go with my preferred approach, you will also have an environment.yml that your colleagues and peers can use to rebuild your Conda environment on their machines or that you can use to re-build your Conda environment on public clouds such as AWS, GCP, Microsoft Azure.
How can we remove FOREIGN KEY constraint from a column of an existing MySQL table?

We can remove FOREIGN KEY constraint from a column of an existing table by using DROP keyword along with ALTER TABLE statement.
ALTER TABLE table_name DROP FOREIGN KEY constraint_name

Here constraint name is the name of foreign key constraint which we applied while creating the table. If no constraint name is specified then MySQL will provide constraint name which can be checked by SHOW CREATE TABLE statement.
The following query will delete the FOREIGN KEY constraint from ‘orders’ table −
mysql> Alter table orders DROP FOREIGN KEY orders_ibfk_1;
Query OK, 0 rows affected (0.22 sec)
Records: 0 Duplicates: 0 Warnings: 0
How does one use glide to download an image into a bitmap using Kotlin?

This example demonstrates how to use glide to download an image into a bitmap using Kotlin
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.
<?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">
   <ImageView
      android:id="@+id/imageView"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.widget.ImageView
import androidx.annotation.Nullable
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition;
class MainActivity : AppCompatActivity() {
   lateinit var imageView: ImageView
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      imageView = findViewById(R.id.imageView)
      Glide.with(this).asBitmap().load("https://www.google.es/images/srpr/logo11w.png").into(object : CustomTarget<Bitmap?>() {
         override fun onResourceReady(resource: Bitmap, @Nullable transition: Transition<in Bitmap?>?) {
            imageView.setImageBitmap(resource)
         }
         override fun onLoadCleared(@Nullable placeholder: Drawable?) {}
      })
   }
}
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="com.example.q11">
   <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 the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen.
Click here to download the project code.
Tryit Editor v3.7

Tryit: HTML table - striped columns
Find all distinct pairs with difference equal to k in Python

In this article we are going to see how to count the numbers of pairs of numbers which have an exact difference equal to k. The given numbers are in form of a list and we supply the value of k to the program.
In this approach we design two for loops, one inside another. The outer for loop keeps track of visiting each element of the given list. The inner for loop keeps comparing each of the remaining elements with the element of the outer loop and increase the value of the count variable if it matches the required difference.
listA = [5, 3, 7, 2, 9]

k = 2
count = 0

# Elements of the list
for i in range(0, len(listA)):

# Make pairs
   for j in range(i + 1, len(listA)):

      if listA[i] - listA[j] == k or listA[j] - listA[i] == k:
         count += 1

print("Required Pairs: ",count)
Running the above code gives us the following result −
Required Pairs: 3
In another approach we use the while loop alogn with if else clause. Here we keep incrementing the current and next index depending on whether the difference between the two pairs matches the required difference.
 Live Demo
listA = [5, 3, 7, 2, 9]

k = 2
count = 0

listA.sort()

next_index = 0
current_index = 0

while current_index < len(listA):
   if listA[current_index] - listA[next_index] == k:
      count += 1
      next_index += 1
      current_index += 1

   elif listA[current_index] - listA[next_index] > k:
      next_index += 1
   else:
      current_index += 1

print("Required Pairs: ",count)
Running the above code gives us the following result −
Required Pairs: 3
MySQL query to select distinct order by id

For this, use ORDER BY MAX(). Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Id int,
   -> Name varchar(100)
   -> );
Query OK, 0 rows affected (0.81 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(10,'John');
Query OK, 1 row affected (0.51 sec)

mysql> insert into DemoTable values(10,'John');
Query OK, 1 row affected (0.10 sec)

mysql> insert into DemoTable values(20,'Sam');
Query OK, 1 row affected (0.17 sec)

mysql> insert into DemoTable values(20,'Sam');
Query OK, 1 row affected (0.11 sec)

mysql> insert into DemoTable values(30,'David');
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable values(30,'David');
Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-------+
| Id   | Name  |
+------+-------+
|   10 | John  |
|   10 | John  |
|   20 | Sam   |
|   20 | Sam   |
|   30 | David |
|   30 | David |
+------+-------+
6 rows in set (0.00 sec)
Following is the query to select distinct order by id −
mysql> select Name from DemoTable
   -> group by Name
   -> order by max(Id) DESC
   -> limit 2;
This will produce the following output −
+-------+
| Name  |
+-------+
| David |
| Sam   |
+-------+
2 rows in set (0.06 sec)
How to store and retrieve date into Sqlite3 database using Python?

You can very easily store and retrieve date into Sqlite3 database using the sqlite3 module. When inserting the date in the database, pass the date directly and Python handles it automatically.
import sqlite3
import datetime
conn = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES)
conn.execute('''CREATE TABLE TEST (ID TEXT PRIMARY KEY NOT NULL, DATE DATE)''')
# Save changes
conn.commit()
# Insert the object directly
conn.execute("INSERT INTO TEST (ID,DATE) VALUES (?, ?)", ('My date', datetime.date(2018, 1, 4)))
conn.commit()
print("Record inserted")
This will give the output −
Record inserted
Now when you will fetch the values from the database, you will get the date already parsed to the datetime object.
import sqlite3
import datetime
conn = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES)
cursor = conn.execute("SELECT ID,DATE from TEST")
for row in cursor:
    print row
This will give the output −
(u'foo', datetime.date(2014, 4, 28))
Maximum number of threads that can be created within a process in C

Given the task is to find the maximum number of threads that can be created within a process in
C.
A thread is lightweight process and can be independently managed by the scheduler. Because a
thread is a component of a process, therefore multiple number of threads can be associated in a
process and also it takes less time for context switching as it is lighter than the process.
Threads require less resources than the processes and they also share memory with its peer
threads. All user level peer threads are treated as a single task by the operating system. Less
time is required for their creation as well as termination.
The output will always be different every time the program is executed.
Create function void* create(void *) and leave it empty as it only demonstrates the
work of the thread.
Create function void* create(void *) and leave it empty as it only demonstrates the
work of the thread.
In main() function initialize two variables max = 0 and ret = 0 both of type int to
store the maximum number of threads and the return value respectively.
In main() function initialize two variables max = 0 and ret = 0 both of type int to
store the maximum number of threads and the return value respectively.
Declare a variable “th” of type pthread_t.
Declare a variable “th” of type pthread_t.
Run a while loop with condition ret == 0 and put ret = pthread_create (&th,
NULL, create, NULL);
Run a while loop with condition ret == 0 and put ret = pthread_create (&th,
NULL, create, NULL);
Iterate max++ inside the loop.
Iterate max++ inside the loop.
Print max outside the loop.
Print max outside the loop.
#include<pthread.h>
#include<stdio.h>
/*Leave the function empty as it
only demonstrates work of thread*/
void *create ( void *){
}
//main function
int main(){
   int max = 0, ret = 0;
   pthread_t th;
   //Iterate until 0 is returned
   while (ret == 0){
      ret = pthread_create (&th, NULL, create, NULL);
      max++;
   }
   printf(" %d ", max);
}
5741
C# Program to Demonstrate the Example of LINQ Intersect() Method with OrderBy() Method - GeeksforGeeks

06 Dec, 2021
LINQ is known as Language Integrated Query and it is introduced in .NET 3.5. It provides the power to .NET languages to create queries to retrieve data from the data source. In this article we will demonstrate the example of the LINQ intersect() method with OrderBy() method.
1. intersect() Method: This is used to get the common elements from the two given lists. Or we can say that this method returns the intersection of two lists. It is available in both the Queryable and Enumerable classes.
Syntax:
data1.Intersect(data2)
Where data1 is the first list and data2 is the second list.
2. OrderBy() Method: The sole purpose of this method is to sort the given list of elements in ascending order. When you write the LINQ query using this method you need not write extra conditions to sort the array in ascending order.
Syntax:
data1.OrderBy(i => i)
Where i is the iterator. 
Now, we are combining the intersect() and OrderBy() method by first getting common elements using intersect() function, and then from the result we are getting the data in the ascending order with OrderBy() function and display the data using the iterator. So to do this we use the following query:
data1.Intersect(data2).OrderBy(i => i);
Where data1 is the first list and data2 is the second list
Example:
Input: { 10, 20, 30, 40, 50, 60, 70 }
       { 50, 60, 70, 80, 90, 100 }
Output:
50 
60 
70 

Input: { 10, 20, 30 }
       { 50, 60, 70 }
Output:
No Output
Approach:
1. Create and initialize two lists of integer type named as data1 and data2.
2. Now we use the below query to find the common elements from these lists and then sort them in ascending order.
final = data1.Intersect(data2).OrderBy(i => i);
3. Iterate the results using foreach loop.
foreach (var j in final)
{
    Console.WriteLine(j + " ");
}
Example:
C#
// C# program to illustrate how to use Intersect() method// with OrderBy() method in LINQusing System;using System.Linq;using System.Collections.Generic;  class GFG{      static void Main(string[] args){          // Create first list    List<int> data1 = new List<int>(){        10, 20, 30, 40, 50, 60, 70 };              // Create second list    List<int> data2 = new List<int>() {        50, 60, 70, 80, 90, 100 };      // Finding the intersection of two lists and    // then order them in ascending order.    var final = data1.Intersect(data2).OrderBy(i => i);      // Display the numbers    Console.WriteLine("Final Result is: ");    foreach(var j in final)    {        Console.WriteLine(j + " ");    }}}
Output:
Final Result is: 
50 
60 
70 
CSharp LINQ
Picked
C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
C# | Generics - Introduction
Convert String to Character Array in C#
Getting a Month Name Using Month Number in C#
Program to Print a New Line in C#
Socket Programming in C#
Program to find absolute value of a given number
Delete Action in MS SQL Server - GeeksforGeeks

28 Aug, 2020
Prerequisite – Foreign key in MS SQL Server
A column can be inserted in a child table only if it is a part of the parent table in case of a foreign key. The foreign key allows us to perform other actions called Referential Actions. Referential actions allow to update or delete a row in case of the parent table. If a user has updated/deleted a column in the parent table, the column is being automatically updated/deleted in the child table also.
Syntax :
foreign key(foreign-key_constraint) 
references parent_table(parentkey_column) 
ON Delete Action
Consider two tables – Student (Parent Table) and Marks (Child Table) from the University database. If a user wants to delete a column, then it has to be done as shown below :
SQL query to perform the Delete Action on the table is –
foreign key references Student(Name) 
ON Delete Action
Output –
This deletes the rows from the entire parent and child table as well. There are other permitted actions – no action, cascade, set null, set default.
On Delete No Action –It raises an error and rolls back the delete action on parent table.
On Delete Cascade –The cascade action deletes all the rows from the parent and child table.
On Delete Set Null –The rows from the parent and child table are set null only if the foreign key is nullable.
On Delete Set Default –The child table rows are set to default if the corresponding parent table rows are deleted only if the foreign key has default definitions.
DBMS-SQL
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
Deadlock in DBMS
KDD Process in Data Mining
Conflict Serializability in DBMS
What is Temporary Table in SQL?
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
How to Update Multiple Columns in Single Update Statement in SQL?
How to Create a Table With Multiple Foreign Keys in SQL?
Java Examples - Create an Applet

How to create a basic Applet?
Following example demonstrates how to create a basic Applet by extending Applet Class. You will need to embed another HTML code to run this program.
import java.applet.*;
import java.awt.*;

public class Main extends Applet {
   public void paint(Graphics g) {
      g.drawString("Welcome in Java Applet.",40,20);
   }
}
Now compile the above code and call the generated class in your HTML code as follows −
<HTML>
   <HEAD>
   </HEAD>
   
   <BODY>
      <div >
         <APPLET CODE = "Main.class" WIDTH = "800" HEIGHT = "500"></APPLET>
      </div>
   </BODY>
</HTML>
The above code sample will produce the following result in a java enabled web browser.
Welcome in Java Applet.

 Print
 Add Notes
 Bookmark this page
TimeSpan.Add() Method in C#

The TimeSpan.Add() method in C# is used to return a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.
The syntax is as follows −
public TimeSpan Add (TimeSpan span);
Above, the parameter span is the time interval to add.
Let us now see an example −
 Live Demo
using System;
public class Demo {
   public static void Main(){
      TimeSpan span1 = new TimeSpan(2, 17, 20, 30);
      TimeSpan span2 = new TimeSpan(3, 18, 25, 25);
      TimeSpan span3 = new TimeSpan(-8, 30, 0);
      TimeSpan res1 = span1.Add(span2);
      TimeSpan res2 = span2.Add(span3);
      Console.WriteLine("Final Timespan (TimeSpan1 + TimeSpan2) = "+res1);
      Console.WriteLine("Final Timespan (TimeSpan2 + TimeSpan3) = "+res2);
   }
}
This will produce the following output −
Final Timespan (TimeSpan1 + TimeSpan2) = 6.11:45:55
Final Timespan (TimeSpan2 + TimeSpan3) = 3.10:55:25
Let us now see another example −
 Live Demo
using System;
public class Demo {
   public static void Main(){
      TimeSpan span1 = new TimeSpan(-6, 25, 0);
      TimeSpan span2 = new TimeSpan(1, 11, 25, 20);
      TimeSpan span3 = TimeSpan.MinValue;
      TimeSpan res1 = span1.Add(span2);
      TimeSpan res2 = span2.Add(span3);
      Console.WriteLine("Final Timespan (TimeSpan1 + TimeSpan2) = "+res1);
      Console.WriteLine("Final Timespan (TimeSpan2 + TimeSpan3) = "+res2);
   }
}
This will produce the following output −
Final Timespan (TimeSpan1 + TimeSpan2) = 1.05:50:20
Final Timespan (TimeSpan2 + TimeSpan3) = -10675197.15:22:45.4775808
How to retrieve windows registry keys and values using PowerShell?

To browse through the registry in PowerShell, we can use the Get-ChildItem command. For example to get all keys from the path HKLM:\Hardware we can use the below command.
Get-ChildItem HKLM:\HARDWARE
Or you can set the location and use the dir (get-ChildItem or ls) command to browse the path.
PS C:\> Set-Location HKLM:\HARDWARE
PS HKLM:\HARDWARE> dir
Hive: HKEY_LOCAL_MACHINE\HARDWARE
Name    Property
----    --------
ACPI
DESCRIPTION
DEVICEMAP
RESOURCEMAP
To get the properties of the key, use the Get-ItemProperty command.
Set-Location 'HKLM:\SOFTWARE\VMware, Inc.'
Get-ItemProperty '.\VMware Drivers'
efifw.status      : 1|1.1.0.0.0.1|oem2.inf
vmxnet3.status    : 1|1.1.8.16.0.1|oem3.inf
pvscsi.status     : 1|1.1.3.15.0.1|oem4.inf
vmusbmouse.status : 1|1.12.5.10.0.1|oem5.inf
vmmouse.status    : 1|1.12.5.10.0.1|oem6.inf
Convert number to alphabet letter JavaScript

We are required to write a function that takes in a number between 1 and 26 (both inclusive)
and returns the corresponding English alphabet for it. (capital case)
If the number is out of this range return -1.
For example −
toAlpha(3) = C
toAlpha(18) = R
And so on.
ASCII codes are the standard numerical representation of all the characters and numbers
present on our keyboard and many for.
The capital English alphabets are also mapped in the ascii char codes, they start from 65 and
goes all the way up to 90, with 65 being the value for ‘A’, 66 for ‘B’ and so.
We can use these codes to map our alphabets
The full code for doing this will be −
const toAlpha = (num) => {
   if(num < 1 || num > 26 || typeof num !== 'number'){
      return -1;
   }
   const leveller = 64;
   //since actually A is represented by 65 and we want to represent it
   with one
   return String.fromCharCode(num + leveller);
};
console.log(toAlpha(18));
The output in the console will be −
R
Java Abstraction

Data abstraction is the process of hiding certain details and showing only essential information to the user.
Abstraction can be achieved with either abstract classes or 
interfaces (which you will learn more about in the next chapter).
The abstract keyword is a non-access modifier, used for classes and methods:

Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class).
Abstract method: can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from).
An abstract class can have both abstract and regular methods:
abstract class Animal {
  public abstract void animalSound();
  public void sleep() {
    System.out.println("Zzz");
  }
}
 
 

From the example above, it is not possible to create an object of the Animal class:
Animal myObj = new Animal(); // will generate an error

To access the abstract class, it must be inherited from another class. Let's convert the Animal class we used in the Polymorphism chapter to an abstract class:
Remember from the Inheritance chapter that we use the extends keyword to inherit from a class.
// Abstract class
abstract class Animal {
  // Abstract method (does not have a body)
  public abstract void animalSound();
  // Regular method
  public void sleep() {
    System.out.println("Zzz");
  }
}

// Subclass (inherit from Animal)
class Pig extends Animal {
  public void animalSound() {
    // The body of animalSound() is provided here
    System.out.println("The pig says: wee wee");
  }
}

class Main {
  public static void main(String[] args) {
    Pig myPig = new Pig(); // Create a Pig object
    myPig.animalSound();
    myPig.sleep();
  }
}
 
 
 


Try it Yourself »

To achieve security - hide certain details and only show the important 
details of an object.
Note: Abstraction can also be achieved with Interfaces, which you will learn more about in the next chapter.
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.
Automatically close window after a certain time in Tkinter

In order to close a Tkinter application, we generally refer to close the parent window using the destroy() method. To close the Tkinter window automatically after a certain time limit, we have to use the after(time in ms, callback) method by specifying the time and the callback function which needs to be run after a certain time limit.
#Import the required Libraries
from tkinter import *
from tkinter import ttk

#Create an instance of tkinter frame
win = Tk()

#Set the geometry of tkinter frame
win.geometry("750x270")

#Initialize a Label widget
Label(win, text= "This window will get closed after 3 seconds...",
font=('Helvetica 20 bold')).pack(pady=20)

#Automatically close the window after 3 seconds
win.after(3000,lambda:win.destroy())

win.mainloop()
Running the above code will display a window that will get closed after 3 seconds.
The given output window will get closed after 3 seconds which can be modified by changing the value in the after (time, callback) method.
How to wait for options in a select to be populated in Selenium?

We can wait for options in a select tag to be populated with Selenium. This can be done with the explicit wait concept in synchronization. The explicit wait is designed on the expected condition for an element.
To wait for the options, we shall verify if presenceOfNestedElementsLocatedBy is available within the explicit wait time. We shall implement the entire verification within the try catch block.
Let us see if the options are available for selection in the Continents dropdown. The ExpectedCondition along with WebDriverWait is used for explicit wait.
HTML code of the select dropdown.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class SelectOptWait{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm");
      //expected condition presenceOfNestedElementsLocatedBy on options
      WebDriverWait w = new WebDriverWait(driver,3);
      try {
         w.until(ExpectedConditions
         .presenceOfNestedElementsLocatedBy
         (By.xpath("//select[@name='continents']"), By.tagName("option")));
         // identify dropdown
         WebElement l = driver.findElement(By.xpath("//select[@name='continents']"));
         // select option by Select class
         Select s = new Select(l);
         // selectByVisibleText to choose an option
         s.selectByVisibleText("Africa");
      }
      catch(Exception e) {
         System.out.println("Options not available");
      }
      driver.quit();
   }
}
java.time.OffsetDateTime.parse() Method Example

The java.time.OffsetDateTime.parse(CharSequence text, DateTimeFormatter formatter) method obtains an instance of OffsetDateTime from a text string using a specific formatter.
Following is the declaration for java.time.OffsetDateTime.parse(CharSequence text, DateTimeFormatter formatter) method.
public static OffsetDateTime parse(CharSequence text, DateTimeFormatter formatter)

text − the text to parse such as "2017-02-03T10:15:30+01:00", not null.
text − the text to parse such as "2017-02-03T10:15:30+01:00", not null.
formatter − the formatter to use, not null.
formatter − the formatter to use, not null.
the local date, not null.
DateTimeParseException − if the text cannot be parsed.
The following example shows the usage of java.time.OffsetDateTime.parse(CharSequence text, DateTimeFormatter formatter) method.
package com.tutorialspoint;

import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

public class OffsetDateTimeDemo {
   public static void main(String[] args) {
  
      DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
      String date = "2017-12-03T10:15:30+01:00";
      OffsetDateTime date1 = OffsetDateTime.parse(date, dateTimeFormatter);
      System.out.println(date1);
   }
}
Let us compile and run the above program, this will produce the following result −
2017-12-03T10:15:30+01:00

 Print
 Add Notes
 Bookmark this page
What is the use of the @ symbol in PHP?

PHP supports the error control operator i.e. the at sign (@). When @ is prepended to an expression, any error messages that might be generated by that expression gets ignored.
To use @ symbol in PHP, the code is as follows−
 Live Demo
<?php
   $file = @file ('non_existent_file') or
   die ("Failed in opening the file: Error Message = '$err'");
   $value = @$cache[$key];
?>
This will produce the following output−
Failed in opening the file: Error Message = ''PHP Notice: Undefined
variable: err in /home/cg/root/6985034/main.php on line 4
Let us now see another example−
 Live Demo
<?php
   $val = $test['5']
   $val = @$test['5']
?>
This will produce the following output−
PHP Parse error: syntax error, unexpected '$val' (T_VARIABLE) in /home/cg/root/6985034/main.php on line 5
C++ Program to Check Whether Number is Even or Odd

A number is even if it is divisible by two and odd if it is not divisible by two.
Some of the even numbers are −
2, 4, 6, 8, 10, 12, 14, 16
Some of the odd numbers are −
1, 3, 5, 7, 9, 11, 13, 15, 17
A program to check whether number is even or odd using modulus is as follows.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int num = 25;
   if(num % 2 == 0)
   cout<<num<<" is even";
   else
   cout<<num<<" is odd";
   return 0;
}
25 is odd
In the above program, the number num is divided by 2 and its remainder is observed. If the remainder is 0, then the number is even. If the remainder is 1, then the number is odd.
if(num % 2 == 0)
   cout<<num<<" is even";
else
   cout<<num<<" is odd";
A number is odd if it has 1 as its rightmost bit in bitwise representation. It is even if it has 0 as its rightmost bit in bitwise representation. This can be found by using bitwise AND on the number and 1. If the output obtained is 0, then the number is even and if the output obtained is 1, then the number is odd.
A program to check whether number is even or odd using Bitwise AND is as follows −
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int num = 7;
   if((num & 1) == 0)
   cout<<num<<" is even";
   else
   cout<<num<<" is odd";
   return 0;
}
7 is odd
In the above program, bitwise AND is done on num and 1. If the output is 0, then num is even, otherwise num is odd.
if((num & 1) == 0)
cout<<num<<" is even";
else
cout<<num<<" is odd";