code-rag-bench/online-tutorials huggingface dataset:
What is the difference between <html lang="en'> and <html lang="en-US'> ? - GeeksforGeeks

08 May, 2020
The lang attribute specifies which language is used to write the content of a web page. It is used to set the language for the whole text of the web page.
The difference between <html lang=”en’> and <html lang=”en-US’> is described below:
<html lang=”en’>The <html lang=”en’> only specifies the language code of the page meaning en or English is used for all the text on the page.
Example:
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width,      initial-scale=1.0">    <title>lang Attribute</title>    <style>        body{            text-align: center;        }        h1{            color: green;        }    </style></head><body>    <h1>GeeksforGeeks</h1>    <p>jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document,or more precisely the Document Object Model (DOM), and JavaScript.Elaborating the terms, jQuery simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser JavaScript development.</p></body></html>
Output:
<html lang=”en-US’>The <html lang=”en-US’> specifies the language code of the page followed by the country code that means US style of English language is used for all the text on the page.
<html lang=”en-GB’> which means the United Kingdom style of English<html lang=”en-IN’> which means the Indian style of English
Example:
<!DOCTYPE html><html lang="en-US"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width,     initial-scale=1.0">    <title>lang Attribute</title>    <style>        body{            text-align: center;        }        h1{            color: green;        }    </style></head><body>    <h1>GeeksforGeeks</h1>    <p>jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript.Elaborating the terms, jQuery simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser JavaScript development.</p></body></html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Misc
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to get an object containing parameters of current URL in JavaScript ? - GeeksforGeeks

23 Apr, 2021
The purpose of this article is to get an object which contains the parameter of the current URL.
Example:
Input: www.geeksforgeeks.org/search?name=john&age=27
Output: { 
           name: "john", 
           age: 27
        }

Input: geeksforgeeks.org
Output: {}
To achieve this, we follow the following steps.
Create an empty object.
Using the String.match() method extract all the query params which are separated by ? and &, to achieve this we use the regex /([^?=&]+)(=([^&]*))/g
The String.match() method returns an array containing all the queries.
Using the for...each loop iterates the array and at every iteration split the value at = sign by using the String.split() method. This method returns an array of 2 strings the 0’th string is the left part of the = sign and the 1st string is the right part of the = sign.
Assign the first string as the key and the second string as the value of that key in the newly created object.
Finally, return the newly created object.
Example:
Javascript
<script>    function getAllParams(url) {          // Create an empty object        let obj = {};          // Extract the query params        let paramsArray = url.match(/([^?=&]+)(=([^&]*))/g)          // Check if there is one or more params        if (paramsArray) {              // Iterate the params array            paramsArray.forEach((query) => {                  // Split the array                let strings = query.split("=")                  // Assign the values to the object                obj[strings[0]] = strings[1]            })        }                  // Return the object        return obj;    }      console.log(getAllParams(        "www.geeksforgeeks.org/search?name=john&age=27"))    console.log(getAllParams("geeksforgeeks.org"))</script>
Output:
{
  age: "27",
  name: "john"
}
{}
{}

JavaScript-Methods


javascript-object


JavaScript-Questions


Picked


JavaScript


Web Technologies

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
                            
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?

Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Python | winfo_ismapped() and winfo_exists() in Tkinter

29 Nov, 2021
Tkinter provides numerous of universal widget methods or basic widget methods which works almost with all the available widgets. 
This method is used to check whether the specified widget is visible or not. 
Syntax: widget.winfo_ismapped()Return Value: Returns True if widget is visible (or mapped), otherwise returns False.Exception: If widget is destroyed, then it throws error.
 
Puython
# Imports tkinter and ttk modulefrom tkinter import * from tkinter.ttk import * import time  # toplevel windowroot = Tk()  def forget(widget):    widget.forget()    print("After Forget method called. Is widget mapped? = ",                               bool(widget.winfo_ismapped()))  def retrieve(widget):    widget.pack()    print("After retrieval of widget. Is widget mapped? = ",                                bool(widget.winfo_exists()))  # Button widgetsb1 = Button(root, text = "Btn 1")b1.pack()  # This is used to make widget invisibleb2 = Button(root, text = "Btn 2", command = lambda : forget(b1))b2.pack()   # This will retrieve widgetb3 = Button(root, text = "Btn 3", command = lambda : retrieve(b1))b3.pack()  # infinite loop, interrupted by keyboard or mousemainloop()
Output: 
 
 
This method is used to check if the specified widget exists or not i.e if the widget is destroyed or not. 
Syntax: widget.winfo_exists()Return value: Returns True if widget exists, False otherwise.
 
Python
# Imports tkinter and ttk modulefrom tkinter import * from tkinter.ttk import *  # toplevel windowroot = Tk()  def dest(widget):    widget.destroy()    print("Destroy method called. Widget exists? = ",                          bool(widget.winfo_exists()))      def exist(widget):    print("Checking for existence = ", bool(widget.winfo_exists()))  # Button widgetsb1 = Button(root, text = "Btn 1")b1.pack()  # This is used to destroy widgetb2 = Button(root, text = "Btn 2", command = lambda : dest(b1))b2.pack()   # This is used to check existence of the widgetb3 = Button(root, text = "Btn 3", command = lambda : exist(b1))b3.pack()  # infinite loop, interrupted by keyboard or mousemainloop()
Output: 
 
 
Note: If a widget is destroyed it cannot be retrieved again. 
shubham_singh
bloominator
clintra
Python-gui
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
How to get day of month, day of year and day of week in android using offset date time API class?

This example demonstrate about How to get day of month, day of year and day of week in android using offset date time API class.
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"?>
<android.support.constraint.ConstraintLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
   <TextView
      android:id="@+id/date"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Local Date"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintLeft_toLeftOf="parent"
      app:layout_constraintRight_toRightOf="parent"
      app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
In the above code, we have taken textview to show day of month, day of year and day of the week.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import java.time.OffsetDateTime;
import java.time.OffsetTime;

public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      TextView textView = findViewById(R.id.date);
      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
         OffsetDateTime offset = OffsetDateTime.now();
         textView.setText(String.valueOf(offset.getDayOfWeek() + " : " + offset.getDayOfMonth() + " : " + offset.getDayOfYear()));
      }
   }
}
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result, it is showing the current day, month and year.
Click here to download the project code
How to create a fixed/sticky footer with CSS?

To create fixed footer with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
   body{
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
   }
   .footer {
      font-size: 20px;
      position: fixed;
      left: 0;
      bottom: 0;
      width: 100%;
      background-color: rgb(50, 6, 100);
      color: white;
      text-align: center;
   }
</style>
</head>
<body>
<h1>Fixed/Sticky Footer Example</h1>
<div class="footer">
<p>All rights reserved ©</p>
</div>
</body>
</html>
The above code will produce the following output −
JSTL - fn:containsIgnoreCase() Function

The fn:containsIgnoreCase() function determines whether an input string contains a specified substring. While doing search it ignores the case.
The fn:containsIgnoreCase() function has the following syntax −
boolean containsIgnoreCase(java.lang.String, java.lang.String)

Following is the example to explain the functionality of the fn:containsIgnoreCase() function −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %>

<html>
   <head>
      <title>Using JSTL Functions</title>
   </head>

   <body>
      <c:set var = "theString" value = "I am a test String"/>

      <c:if test = "${fn:containsIgnoreCase(theString, 'test')}">
         <p>Found test string<p>
      </c:if>

      <c:if test = "${fn:containsIgnoreCase(theString, 'TEST')}">
         <p>Found TEST string<p>
      </c:if>

   </body>
</html>
You will receive the following result −
Found test string
Found TEST string


    108 Lectures 
     11 hours 

 Chaand Sheikh

    517 Lectures 
     57 hours 

 Chaand Sheikh

    41 Lectures 
     4.5 hours 

 Karthikeya T

    42 Lectures 
     5.5 hours 

 TELCOMA Global

    15 Lectures 
     3 hours 

 TELCOMA Global

    44 Lectures 
     15 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Adding Customized Color Theme in PySimpleGUI - GeeksforGeeks

05 Aug, 2020
PySimpleGUI allows users to choose Themes for its Theme list. Also, it allows users to specify and customize the Theme according to their choice. The User only should know the Color shades i.e the hex codes of the Colors. Accordingly, he/she can customize the Theme by new Colors.
Example:
import PySimpleGUI as sg  # Add your new theme colors and settingssg.LOOK_AND_FEEL_TABLE['MyCreatedTheme'] = {'BACKGROUND': '# 000066',                                        'TEXT': '# FFCC66',                                        'INPUT': '# 339966',                                        'TEXT_INPUT': '# 000000',                                        'SCROLL': '# 99CC99',                                        'BUTTON': ('# 003333', '# FFCC66'),                                        'PROGRESS': ('# D1826B', '# CC8019'),                                        'BORDER': 1, 'SLIDER_DEPTH': 0, 'PROGRESS_DEPTH': 0, }  # Switch to use your newly created themesg.theme('MyCreatedTheme')  # Call a popup to show what the theme looks likesg.popup_get_text('This how the MyNewTheme is created')      
Output:
Python-gui
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
Python - Display text to PyGame window

Pygame is a multimedia library for Python for making games and multimedia applications. In this article we will see how to use the pygame module to get customized font and text on the screen taking into consideration, its height, width, and position in the pygame window.
In the below program we initialize the pygame module and then define the mode and the caption for the image. Next we add the font text and define the coordinates for the font. The screen.blit function paints the screen while the while loop keeps listening the end of the game is clicked.
import pygame
import sys
# Initialize pygame
pygame.init()
#scren dimension
sur_obj=pygame.display.set_mode((300,200))
# Screen caption
pygame.display.set_caption("Text in Pygame")
font_color=(0,150,250)
font_obj=pygame.font.Font("C:\Windows\Fonts\segoeprb.ttf",25)
# Render the objects
text_obj=font_obj.render("Welcome to Pygame",True,font_color)
while True:
   sur_obj.fill((255,255,255))
   sur_obj.blit(text_obj,(22,0))
   for eve in pygame.event.get():
      if eve.type==pygame.QUIT:
         pygame.quit()
         sys.exit()
   pygame.display.update()
Running the above code gives us the following result −
MySQL Joins

A JOIN clause is used to combine rows from two or more tables, based on 
a related column between them.
Let's look at a selection from the "Orders" table:
Then, look at a selection from the "Customers" table:
Notice that the "CustomerID" column in the "Orders" table refers to the 
"CustomerID" in the "Customers" table. The relationship between the two tables above 
is the "CustomerID" column.
Then, we can create the following SQL statement (that contains an 
INNER JOIN), 
that selects records that have matching values in both tables:
and it will produce something like this:
INNER JOIN: Returns records that have matching values in both tables
LEFT JOIN: Returns all records from the left table, and the matched records from the right table
RIGHT JOIN: Returns all records from the right table, and the matched records from the left table
CROSS JOIN: Returns all records from both 
  tables

 
 
 


Insert the missing parts in the JOIN clause to join the two tables Orders and Customers,
using the CustomerID field in both tables as the relationship between the two tables.
SELECT *
FROM Orders
LEFT JOIN Customers
=;

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.
Solidity - Ether Units

In solidity we can use wei, finney, szabo or ether as a suffix to a literal to be used to convert various ether based denominations. Lowest unit is wei and 1e12 represents 1 x 1012.
assert(1 wei == 1);
assert(1 szabo == 1e12);
assert(1 finney == 1e15);
assert(1 ether == 1e18);
assert(2 ether == 2000 fenny);
Similar to currency, Solidity has time units where lowest unit is second and we can use seconds, minutes, hours, days and weeks as suffix to denote time.
assert(1 seconds == 1);
assert(1 minutes == 60 seconds);
assert(1 hours == 60 minutes);
assert(1 day == 24 hours);
assert(1 week == 7 days);

    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    31 Lectures 
     3.5 hours 

 Swapnil Kole
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: HTML table - set column width
C# | Swap two Strings without using third user defined variable - GeeksforGeeks

18 Oct, 2021
Given two string variables a and b, swap these variables without using a temporary or third variable in C#. Use of library methods is allowed.
Example:
Input:
a = "Hello"
b = "World"

Output:
Strings before swap: a = Hello and b = World
Strings after swap: a = World and b = Hello
The idea is to do string concatenation and then use Substring() method to perform this operation. The Substring() method comes in two forms as listed below:
String.Substring Method (startIndex): This method is used to retrieve a substring from the current instance of the string. The parameter “startIndex” will specify the starting position of substring and then substring will continue to the end of the string.
String.Substring Method (int startIndex, int length): This method is used to extract a substring that begins from specified position described by parameter startIndex and has a specified length. If startIndex is equal to the length of string and parameter length is zero, then it will return nothing as substring.
Algorithm:
1) Append second string to first string and 
   store in first string:
   a = a + b

2) Call the Substring Method (int startIndex, int length)
   by passing startindex as 0 and length as,
   a.Length - b.Length:
   b = Substring(0, a.Length - b.Length);

3) Call the Substring Method(int startIndex) by passing 
   startindex as b.Length as the argument to store the 
   value of initial b string in a
   a = Substring(b.Length);

// C# program to swap two strings// without using a temporary variable.using System;  class GFG {      // Main Method    public static void Main(String[] args)    {        // Declare two strings        String a = "Hello";        String b = "Geeks";          // Print String before swapping        Console.WriteLine("Strings before swap: a =" +                           " " + a + " and b = " + b);          // append 2nd string to 1st        a = a + b;          // store initial string a in string b        b = a.Substring(0, a.Length - b.Length);          // store initial string b in string a        a = a.Substring(b.Length);          // print String after swapping        Console.WriteLine("Strings after swap: a =" +                          " " + a + " and b = " + b);    }}
Output:
Strings before swap: a = Hello and b = Geeks
Strings after swap: a = Geeks and b = Hello

kashishsoda
CSharp-string
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#
How to validate if JTable has an empty cell in Java?

A JTable is a subclass of JComponent class for displaying complex data structures. A JTable can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable will generate TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener and RowSorterListener interfaces.
We can validate whether the JTable cell is empty or not by implementing the getValueAt() method of JTable class. If we click on the "Click Here" button, it will generate an action event and display a popup message like "Field is Empty" to the user.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class JTableEmptyValidateTest extends JFrame {
   private JPanel panel;
   private JTable table;
   private JButton button;
   String[] columnNames = new String[] {"Student 1", "Student 2"};
   String[][] dataValues = new String[][] {{"95", "100"}, {"", "85"}, {"80", "100"}};
   public JTableEmptyValidateTest() {
      setTitle("Empty Validation Table");
      panel = new JPanel();
      table = new JTable();
      TableModel model = new myTableModel();
      table.setModel(model);
      panel.add(new JScrollPane(table));
      button = new JButton("Click Here");
      button.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
            if(validCheck()) {
               JOptionPane.showMessageDialog(null,"Field is filled up");
            } else {
               JOptionPane.showMessageDialog(null, "Field is empty");
            }
         }
      });
      add(panel, BorderLayout.CENTER);
      add(button, BorderLayout.SOUTH);
      setSize(470, 300);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      setVisible(true);
   }
   public boolean validCheck() {
      if(table.getCellEditor()!= null) {
         table.getCellEditor().stopCellEditing();
      }
      for(int i=0; i < table.getRowCount(); i++) {
         for(int j=0; j < table.getColumnCount(); j++) {
            String value = table.getValueAt(i,j).toString();
            if(value.trim().length() == 0) {
               return false;
            }
         }
      }
      return true;
   }
   class myTableModel extends DefaultTableModel {
      myTableModel() {
         super(dataValues, columnNames);
      }
      public boolean isCellEditable(int row, int cols) {
         return true;
      }
   }
   public static void main(String args[]) {
      new JTableEmptyValidateTest();
   }
}
MATLAB - The for Loop

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.
The syntax of a for loop in MATLAB is −
for index = values
   <program statements>
            ...
end

values has one of the following forms −
initval:endval
increments the index variable from initval to endval by 1, and repeats execution of program statements until index is greater than endval.
initval:step:endval
increments index by the value step on each iteration, or decrements when step is negative.
valArray
creates a column vector index from subsequent columns of array valArray on each iteration. For example, on the first iteration, index = valArray(:,1). The loop executes for a maximum of n times, where n is the number of columns of valArray, given by numel(valArray, 1, :). The input valArray can be of any MATLAB data type, including a string, cell array, or struct.
Create a script file and type the following code −
for a = 10:20 
   fprintf('value of a: %d\n', a);
end
When you run the file, it displays the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
value of a: 20

Create a script file and type the following code −
for a = 1.0: -0.1: 0.0
   disp(a)
end
When you run the file, it displays the following result −
1
0.90000
0.80000
0.70000
0.60000
0.50000
0.40000
0.30000
0.20000
0.10000
0

Create a script file and type the following code −
for a = [24,18,17,23,28]
   disp(a)
end
When you run the file, it displays the following result −
24

18

17

23

28


    30 Lectures 
     4 hours 

 Nouman Azam

    127 Lectures 
     12 hours 

 Nouman Azam

    17 Lectures 
     3 hours 

 Sanjeev

    37 Lectures 
     5 hours 

 TELCOMA Global

    22 Lectures 
     4 hours 

 TELCOMA Global

    18 Lectures 
     3 hours 

 Phinite Academy
 Print
 Add Notes
 Bookmark this page
Git - Perform Changes

Jerry clones the repository and decides to implement basic string operations. So he creates string.c file. After adding the contents, string.c will look like as follows −
#include <stdio.h>

int my_strlen(char *s)
{
   char *p = s;

   while (*p)
      ++p;

   return (p - s);
}

int main(void)
{
   int i;
   char *s[] = 
   {
      "Git tutorials",
      "Tutorials Point"
   };

   for (i = 0; i < 2; ++i)
      
   printf("string lenght of %s = %d\n", s[i], my_strlen(s[i]));

   return 0;
}
He compiled and tested his code and everything is working fine. Now, he can safely add these changes to the repository.
Git add operation adds file to the staging area.
[jerry@CentOS project]$ git status -s
?? string
?? string.c

[jerry@CentOS project]$ git add string.c

Git is showing a question mark before file names. Obviously, these files are not a part of Git, and that is why Git does not know what to do with these files. That is why, Git is showing a question mark before file names.
Jerry has added the file to the stash area, git status command will show files present in the staging area.
[jerry@CentOS project]$ git status -s
A string.c
?? string

To commit the changes, he used the git commit command followed by –m option. If we omit –m option. Git will open a text editor where we can write multiline commit message.
[jerry@CentOS project]$ git commit -m 'Implemented my_strlen function'

The above command will produce the following result −
[master cbe1249] Implemented my_strlen function
1 files changed, 24 insertions(+), 0 deletions(-)
create mode 100644 string.c

After commit to view log details, he runs the git log command. It will display the information of all the commits with their commit ID, commit author, commit date and SHA-1 hash of commit.
[jerry@CentOS project]$ git log

The above command will produce the following result −
commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277
Author: Jerry Mouse <jerry@tutorialspoint.com>
Date: Wed Sep 11 08:05:26 2013 +0530

Implemented my_strlen function


commit 19ae20683fc460db7d127cf201a1429523b0e319
Author: Tom Cat <tom@tutorialspoint.com>
Date: Wed Sep 11 07:32:56 2013 +0530

Initial commit


    251 Lectures 
     35.5 hours 

 Gowthami Swarna

    23 Lectures 
     2 hours 

 Asif Hussain

    15 Lectures 
     1.5 hours 

 Abhilash Nelson

    125 Lectures 
     9 hours 

 John Shea

    13 Lectures 
     2.5 hours 

 Raghu Pandey

    13 Lectures 
     3 hours 

 Sebastian Sulinski
 Print
 Add Notes
 Bookmark this page
How to add line breaks to an HTML textarea? - GeeksforGeeks

28 Jan, 2020
Way of implementing line breaks differ from one platform to another. The following approach takes input text from HTML Textarea and adds line breaks using JavaScript.
Approach:This task can be achieved by using some predefined array and string functions provided by JavaScript. In the following code, the input from the textarea is processed by JavaScript on the click of the submit button to produce a required output with line breaks.
Functions Used:split(): is a predefined JavaScript function that splits a string into an array using a parameter.join(): is a predefined JavaScript function that joins an array to convert it into a string using provided parameters.
Example:
<!DOCTYPE html><html>  <head>      <script type="text/javascript">        function divide() {            var txt;            txt = document.getElementById('a').value;            var text = txt.split(".");            var str = text.join('.</br>');            document.write(str);        }    </script>    <title></title></head>  <body>    <form>        ENTER TEXT:        <br>        <textarea rows="20"                   cols="50"                   name="txt"                   id="a">      </textarea>        <br>        <br>        <input type="submit"                name="submit"               value="submit"                onclick="divide()" />    </form></body>  </html>
Output:Code without line break:
Geeks for geeks. Geeks for geeks. Geeks for geeks. Geeks for geeks.
Code with line break:
Geeks for geeks. 
Geeks for geeks. 
Geeks for geeks. 
Geeks for geeks.
JavaScript-Misc
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
Difference between var, let and const keywords in JavaScript
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to get formatted date and time in Python?

You can get formatted date and time using strftime function. It accepts a format string that you can use to get your desired output. Following are the directives supported by it.
You can use these directives in the strftime function as follows −
import datetime
now = datetime.datetime.now()
print("Current date and time: ")
print(now.strftime('%Y-%m-%d %H:%M:%S'))
print(now.strftime('%H:%M:%S on %A, %B the %dth, %Y'))
This will give the output −
2017-12-29 12:19:13
12:19:13 on Friday, December the 29th, 2017
How can we add/insert a JButton to JTable cell in Java?

A JTable is a subclass of JComponent class and it can be used to create a table with information displayed in multiple rows and columns. When a value is selected from a JTable, a TableModelEvent is generated, which is handled by implementing a TableModelListener interface. We can add or insert a JButton to JTable cell by customizing the code either in DefaultTableModel or AbstractTableModel and we can also customize the code by implementing TableCellRenderer interface and need to override getTableCellRendererComponent() method.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class JTableButtonTest extends JFrame {
   private JTable table;
   private JScrollPane scrollPane;
   public JTableButtonTest() {
      setTitle("JTableButton Test");
      TableCellRenderer tableRenderer;
      table = new JTable(new JTableButtonModel());
      tableRenderer = table.getDefaultRenderer(JButton.class);
      table.setDefaultRenderer(JButton.class, new JTableButtonRenderer(tableRenderer));
      scrollPane = new JScrollPane(table);
      add(scrollPane, BorderLayout.CENTER);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      setSize(400, 300);
      setVisible(true);
   }
   public static void main(String[] args) {
      new JTableButtonTest();
   }
}
class JTableButtonRenderer implements TableCellRenderer {
   private TableCellRenderer defaultRenderer;
   public JTableButtonRenderer(TableCellRenderer renderer) {
      defaultRenderer = renderer;
   }
   public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if(value instanceof Component)
         return (Component)value;
         return defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   }
}
class JTableButtonModel extends AbstractTableModel {
   private Object[][] rows = {{"Button1", new JButton("Button1")},{"Button2", new JButton("Button2")},{"Button3", new JButton("Button3")}, {"Button4", new JButton("Button4")}};
   private String[] columns = {"Count", "Buttons"};
   public String getColumnName(int column) {
      return columns[column];
   }
   public int getRowCount() {
      return rows.length;
   }
   public int getColumnCount() {
      return columns.length;
   }
   public Object getValueAt(int row, int column) {
      return rows[row][column];
   }
   public boolean isCellEditable(int row, int column) {
      return false;
   }
   public Class getColumnClass(int column) {
      return getValueAt(0, column).getClass();
   }
}
AtomicBoolean getAndSet() method in Java with Examples - GeeksforGeeks

27 Feb, 2019
The Java.util.concurrent.atomic.AtomicBoolean.getAndSet() is an inbuilt method in java that sets the given value to the value passed in the parameter and returns the value before updation which is of data-type boolean.
Syntax:
public final boolean getAndSet(boolean val)

Parameters: The function accepts a single mandatory parameter val which specifies the value to be updated.
Return Value: The function returns the value before update operation is performed to the previous value.
Below programs illustrate the above method:
Program 1:
// Java program that demonstrates// the getAndSet() function  import java.util.concurrent.atomic.AtomicBoolean;  public class GFG {    public static void main(String args[])    {          // Initially value as false        AtomicBoolean val = new AtomicBoolean(false);          // Updates and sets        boolean res            = val.getAndSet(true);          System.out.println("Previous value: "                           + res);          // Prints the updated value        System.out.println("Current value: "                           + val);    }}
Previous value: false
Current value: true

Program 2:
// Java program that demonstrates// the getAndSet() function  import java.util.concurrent.atomic.AtomicBoolean;  public class GFG {    public static void main(String args[])    {          // Initially value as true        AtomicBoolean val = new AtomicBoolean(true);          // Gets and updates        boolean res = val.getAndSet(false);          System.out.println("Previous value: "                           + res);        // Prints the updated value        System.out.println("Current value: "                           + val);    }}
Previous value: true
Current value: false

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicBoolean.html#getAndSet-boolean-
Java-AtomicBoolean
Java-concurrent-package
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
Stream In Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Python PIL | ImageChops.subtract() method - GeeksforGeeks

29 Jun, 2019
PIL.ImageChops.subtract() method subtracts two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. At least one of the images must have mode “1”.
Syntax: PIL.ImageChops.subtract(image1, image2, scale=1.0, offset=0)

Parameters:
image1: first image
image2: second image
scale: numeric value
offset: numeric value

Return Type: Image

Image1:
Image2:
# Importing Image and ImageChops module from PIL package  from PIL import Image, ImageChops     # creating a image1 object im1 = Image.open(r"C:\Users\sadow984\Desktop\a2.PNG")     # creating a image2 object im2 = Image.open(r"C:\Users\sadow984\Desktop\x5.PNG")     # applying subtract method im3 = ImageChops.add(im1, im2, scale = 1.0, offset = 2)     im3.show() 
Output:
# Importing Image and ImageChops module from PIL package  from PIL import Image, ImageChops     # creating a image1 object im1 = Image.open(r"C:\Users\sadow984\Desktop\a2.PNG")     # creating a image2 object im2 = Image.open(r"C:\Users\sadow984\Desktop\x5.PNG")     # applying subtract method im3 = ImageChops.add(im1, im2, scale = 1.0, offset = 2)     im3.show() 
Output:
Image-Processing
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
zlib.adler32() in Python - GeeksforGeeks

23 Mar, 2020
With the help of zlib.adler32() method, we can compute the checksum for adler32 to a particular data. It will give 32-bit integer value as a result by using zlib.adler32() method.
Syntax : zlib.adler32(s)Return : Return the unsigned 32-bit checksum integer.
Example #1 :In this example we can see that by using zlib.adler32() method, we are able to compute the unsigned 32-bit checksum for given data by using this method.
# import zlib and adler32import zlib  s = b'I love python, Hello world'  # using zlib.adler32() methodt = zlib.adler32(s)  print(t)
Output :
2073102698
Example #2 :
# import zlib and adler32import zlib  s = b'Hello GeeksForGeeks'  # using zlib.adler32() methodt = zlib.adler32(s)  print(t)
Output :
1156384538
python-zlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
PyQt5 QSpinBox - Setting Special Value Text - GeeksforGeeks

28 May, 2020
In this article we will see how we can set the special value text to the spin box. Setting special value text to spin box will display this special text instead of a numeric value whenever the current value is equal to minimum value. Typical use of this is to indicate that this choice has a special (default) meaning.
In order to do this we use setSpecialValueText method with the spin box object.
Syntax : spin_box.setSpecialValueText(text)
Argument : It takes string as argument
Return : It returns None
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()          # method for widgets    def UiComponents(self):        # creating spin box        self.spin = QSpinBox(self)          # setting geometry to spin box        self.spin.setGeometry(100, 100, 250, 40)          # setting range to the spin box        self.spin.setRange(0, 999999)          # setting prefix to spin        self.spin.setPrefix("PREFIX ")          # setting suffix to spin        self.spin.setSuffix(" SUFFIX")          # setting special value text        self.spin.setSpecialValueText("Geeks for Geeks")    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-SpinBox
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Python PIL | ImageOps.colorize() Method - GeeksforGeeks

26 Aug, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.
PIL.ImageOps.colorize() Colorize grayscale image. The black and white arguments should be RGB tuples; this function calculates a color wedge mapping all black pixels in the source image to the first color, and all white pixels to the second color.
Syntax: PIL.ImageOps.colorize(image, black, white)
Parameters:
image – The image to colorize.
black – The color to use for black input pixels.
white – The color to use for white input pixels.
Returns: An Image .
Image Used:
Code :
     # importing image object from PILfrom PIL import Image, ImageOps  # creating an image objectimg = Image.open(r"C:\Users\System-Pc\Desktop\pinktree.jpg").convert("L")  # image colorize functionimg1 = ImageOps.colorize(img, black ="blue", white ="white")img1.show()
Output:
Another Example: Here we use different parameters.
Image Used:
Code :
     # importing image object from PILfrom PIL import Image, ImageOps  # creating an image objectimg = Image.open(r"C:\Users\System-Pc\Desktop\bird.jpg").convert("L")  # image colorize functionimg1 = ImageOps.colorize(img, black ="red", white ="yellow")img1.show()
Output:
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
MySQL query to check if a string contains a value (substring) within the same row?

Since we need to match strings from the same row, use LIKE operator. Let us first create a table −
mysql> create table DemoTable
(
   FirstName varchar(100),
   FullName varchar(100)
);
Query OK, 0 rows affected (0.53 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('John','John Smith');
Query OK, 1 row affected (0.08 sec)
mysql> insert into DemoTable values('David','John Miller');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('Bob','Sam Miller');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values('Chris','Chris Brown');
Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+-------------+
| FirstName | FullName    |
+-----------+-------------+
| John      | John Smith  |
| David     | John Miller |
| Bob       | Sam Miller  |
| Chris     | Chris Brown |
+-----------+-------------+
4 rows in set (0.00 sec)
Following is the query to check if a string contains a value within the same row −
mysql> select FirstName,FullName from DemoTable
   where FullName LIKE concat('%', FirstName, '%');
This will produce the following output −
+-----------+-------------+
| FirstName | FullName    |
+-----------+-------------+
| John      | John Smith  |
| Chris     | Chris Brown |
+-----------+-------------+
2 rows in set (0.00 sec)
LISP - Arithmetic Operators

The following table shows all the arithmetic operators supported by LISP. Assume variable A holds 10 and variable B holds 20 then −
Create a new source code file named main.lisp and type the following code in it.
(setq a 10)
(setq b 20)
(format t "~% A + B = ~d" (+ a b))
(format t "~% A - B = ~d" (- a b))
(format t "~% A x B = ~d" (* a b))
(format t "~% B / A = ~d" (/ b a))
(format t "~% Increment A by 3 = ~d" (incf a 3))
(format t "~% Decrement A by 4 = ~d" (decf a 4))
When you click the Execute button, or type Ctrl+E, LISP executes it immediately and the result returned is −
A + B = 30
A - B = -10
A x B = 200
B / A = 2
Increment A by 3 = 13
Decrement A by 4 = 9


    79 Lectures 
     7 hours 

 Arnold Higuit
 Print
 Add Notes
 Bookmark this page
Currency getCurrencyCode() Method in Java with Examples - GeeksforGeeks

27 Dec, 2018
The getCurrencyCode() Method of Currency class in Java is used to retrieve the currency code of this currency which is actually the official ISO 4217 currency code.
Syntax:
CURRENCY.getCurrencyCode()
Parameters: This method does not accept any parameters.
Return Value: This method returns the ISO 4217 currency code of the currency.
Exceptions: The method throws Runtime Error if an invalid code is called.
Below program illustrates the working of getCurrencyCode() method:
Program 1:
// Java Code to illustrate// getCurrencyCode() method  import java.util.*;  public class Currency_Demo {    public static void main(String[] args)    {          // Creating a currency with the code        Currency curr_ency            = Currency.getInstance("INR");          // Getting the currency code        String currency_code            = curr_ency.getCurrencyCode();        System.out.println("Currency Code of India is: "                           + currency_code);    }}
Currency Code of India is: INR

Program 2:
// Java Code to illustrate// getCurrencyCode() method  import java.util.*;  public class Currency_Demo {    public static void main(String[] args)    {          // Creating a currency with the code        Currency curr_ency            = Currency.getInstance("USD");          // Getting the currency code        String currency_code            = curr_ency.getCurrencyCode();        System.out.println("Currency Code of USA is: "                           + currency_code);    }}
Currency Code of USA is: USD

Program 3: For an invalid Currency Code.
// Java Code to illustrate getCurrencyCode() method  import java.util.*;  public class Currency_Demo {    public static void main(String[] args)    {        try {              // Creating a currency with the code            Currency curr_ency                = Currency.getInstance("USDA");              // Getting the currency code            String currency_code                = curr_ency.getCurrencyCode();            System.out.println("Invalid Currency Code: "                               + currency_code);        }        catch (Exception e) {            System.out.println(e);        }    }}
java.lang.IllegalArgumentException

Java - util package
Java-Currency
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
Interfaces in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
How to iterate any Map in Java
Initialize an ArrayList in Java
Overriding in Java
Collections in Java
Singleton Class in Java
Multithreading in Java