Snippets Collections
Test-PSSessionConfigurationFile -Path (Get-PSSessionConfiguration -Name Restricted).ConfigFilePath
Invoke-Command
Receive-Job
Remove-Job
Resume-Job
Start-Job
Stop-Job
Suspend-Job
Wait-Job
about_Jobs
about_Job_Details
about_Remote_Jobs
about_Scheduled_Jobs
PS> Get-Job

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
2      Job2            BackgroundJob   Completed     True            localhost            .\Get-Archive.ps1
4      Job4            RemoteJob       Failed        True            Server01, Server02   .\Get-Archive.ps1
7      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
8      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
9      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
10     UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help

PS> Get-Job -IncludeChildJob

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
2      Job2            BackgroundJob   Completed     True            localhost           .\Get-Archive.ps1
3      Job3                            Completed     True            localhost           .\Get-Archive.ps1
4      Job4            RemoteJob       Failed        True            Server01, Server02  .\Get-Archive.ps1
5      Job5                            Failed        False           Server01            .\Get-Archive.ps1
6      Job6                            Completed     True            Server02            .\Get-Archive.ps1
7      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
8      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
9      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
10     UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help

PS> Get-Job -Name Job4 -ChildJobState Failed

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
2      Job2            BackgroundJob   Completed     True            localhost           .\Get-Archive.ps1
4      Job4            RemoteJob       Failed        True            Server01, Server02  .\Get-Archive.ps1
5      Job5                            Failed        False           Server01            .\Get-Archive.ps1
7      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
8      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
9      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
10     UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help

PS> (Get-Job -Name Job5).JobStateInfo.Reason

Connecting to remote server Server01 failed with the following error message:
Access is denied.
PS> Workflow WFProcess {Get-Process}
PS> WFProcess -AsJob -JobName WFProcessJob -PSPrivateMetadata @{MyCustomId = 92107}
PS> Get-Job -Filter @{MyCustomId = 92107}
Id     Name            State         HasMoreData     Location             Command
--     ----            -----         -----------     --------             -------
1      WFProcessJob    Completed     True            localhost            WFProcess
PS> Start-Job -ScriptBlock {Get-Process}
Id     Name       PSJobTypeName   State       HasMoreData     Location             Command
--     ----       -------------   -----       -----------     --------             -------
1      Job1       BackgroundJob   Failed      False           localhost            Get-Process

PS> (Get-Job).JobStateInfo | Format-List -Property *
State  : Failed
Reason :

PS> Get-Job | Format-List -Property *
HasMoreData   : False
StatusMessage :
Location      : localhost
Command       : get-process
JobStateInfo  : Failed
Finished      : System.Threading.ManualReset
EventInstanceId    : fb792295-1318-4f5d-8ac8-8a89c5261507
Id            : 1
Name          : Job1
ChildJobs     : {Job2}
Output        : {}
Error         : {}
Progress      : {}
Verbose       : {}
Debug         : {}
Warning       : {}
StateChanged  :

PS> (Get-Job -Name job2).JobStateInfo.Reason
Connecting to remote server using WSManCreateShellEx api failed. The async callback gave the
following error message: Access is denied.
Start-Job -ScriptBlock {Get-EventLog -LogName System}
Invoke-Command -ComputerName S1 -ScriptBlock {Get-EventLog -LogName System} -AsJob
Invoke-Command -ComputerName S2 -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Get-Job

Id     Name       PSJobTypeName   State         HasMoreData     Location        Command
--     ----       -------------   -----         -----------     --------        -------
1      Job1       BackgroundJob   Running       True            localhost       Get-EventLog System
2      Job2       RemoteJob       Running       True            S1              Get-EventLog System

$Session = New-PSSession -ComputerName S2
Invoke-Command -Session $Session -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Invoke-Command -Session $Session -ScriptBlock {Get-Job}

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command                   PSComputerName
--     ----            -------------   -----         -----------     --------             -------                   --------------
1      Job1            BackgroundJob   Running       True            localhost            Get-EventLog -LogName Sy… S2
Start-Job -ScriptBlock {Get-Process} -Name MyJob
$j = Get-Job -Name MyJob
$j

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
6      MyJob           BackgroundJob   Completed     True            localhost            Get-Process

Receive-Job -Job $j

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
    124       4    13572      12080    59            1140 audiodg
    783      16    11428      13636   100             548 CcmExec
     96       4     4252       3764    59            3856 ccmsetup
...
Get-Job -Command "*Get-Process*"

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
3      Job3            BackgroundJob   Running       True            localhost            Get-Process
$j = Get-Job -Name Job1
$ID = $j.InstanceID
$ID

Guid
----
03c3232e-1d23-453b-a6f4-ed73c9e29d55

Stop-Job -InstanceId $ID
Get-Job

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
1      Job1            BackgroundJob   Completed     True            localhost             $env:COMPUTERNAME
Get-Job
   [-IncludeChildJob]
   [-ChildJobState <JobState>]
   [-HasMoreData <Boolean>]
   [-Before <DateTime>]
   [-After <DateTime>]
   [-Newest <Int32>]
   [-Command <String[]>]
   [<CommonParameters>]
Get-Job
   [-IncludeChildJob]
   [-ChildJobState <JobState>]
   [-HasMoreData <Boolean>]
   [-Before <DateTime>]
   [-After <DateTime>]
   [-Newest <Int32>]
   [-Command <String[]>]
   [<CommonParameters>]
Get-Job
   [-IncludeChildJob]
   [-ChildJobState <JobState>]
   [-HasMoreData <Boolean>]
   [-Before <DateTime>]
   [-After <DateTime>]
   [-Newest <Int32>]
   [[-Id] <Int32[]>]
   [<CommonParameters>]
Get-Command
   [[-Name] <String[]>]
   [-Module <String[]>]
   [-FullyQualifiedModule <ModuleSpecification[]>]
   [-CommandType <CommandTypes>]
   [-TotalCount <Int32>]
   [-Syntax]
   [-ShowCommandInfo]
   [[-ArgumentList] <Object[]>]
   [-All]
   [-ListImported]
   [-ParameterName <String[]>]
   [-ParameterType <PSTypeName[]>]
   [<CommonParameters>]
Get-Command
   [-Verb <String[]>]
   [-Noun <String[]>]
   [-Module <String[]>]
   [-FullyQualifiedModule <ModuleSpecification[]>]
   [-TotalCount <Int32>]
   [-Syntax]
   [-ShowCommandInfo]
   [[-ArgumentList] <Object[]>]
   [-All]
   [-ListImported]
   [-ParameterName <String[]>]
   [-ParameterType <PSTypeName[]>]
   [<CommonParameters>]
Get-Process -Name Explorer, Winlogon, Services
$cmd = Get-Command Get-Random
$cmd.ParameterSets |
    Select-Object Name, IsDefault, @{n='Parameters';e={$_.ToString()}} |
    Format-Table -Wrap
NAME
    Get-Command

SYNOPSIS
    Gets all commands.

SYNTAX

    Get-Command [[-Name] <System.String[]>] [[-ArgumentList] <System.Object[]>]
    [-All] [-CommandType {Alias | Function | Filter | Cmdlet | ExternalScript |
    Application | Script | Workflow | Configuration | All}]
    [-FullyQualifiedModule <Microsoft.PowerShell.Commands.ModuleSpecification[]>]
    [-ListImported] [-Module <System.String[]>] [-ParameterName <System.String[]>]
    [-ParameterType <System.Management.Automation.PSTypeName[]>]
    [-ShowCommandInfo] [-Syntax] [-TotalCount <System.Int32>]
    [-UseAbbreviationExpansion] [-UseFuzzyMatching] [<CommonParameters>]

    Get-Command [[-ArgumentList] <System.Object[]>] [-All]
    [-FullyQualifiedModule <Microsoft.PowerShell.Commands.ModuleSpecification[]>]
    [-ListImported] [-Module <System.String[]>] [-Noun <System.String[]>]
    [-ParameterName <System.String[]>]
    [-ParameterType <System.Management.Automation.PSTypeName[]>]
    [-ShowCommandInfo] [-Syntax] [-TotalCount <System.Int32>]
    [-Verb <System.String[]>] [<CommonParameters>]
...
Get-Command [[-ArgumentList] <Object[]>] [-Verb <string[]>] [-Noun <string[]>]
 [-Module <string[]>] [-FullyQualifiedModule <ModuleSpecification[]>]
 [-TotalCount <int>] [-Syntax] [-ShowCommandInfo] [-All] [-ListImported]
 [-ParameterName <string[]>] [-ParameterType <PSTypeName[]>]
 [<CommonParameters>]

Get-Command [[-Name] <string[]>] [[-ArgumentList] <Object[]>]
 [-Module <string[]>] [-FullyQualifiedModule <ModuleSpecification[]>]
 [-CommandType <CommandTypes>] [-TotalCount <int>] [-Syntax] [-ShowCommandInfo]
 [-All] [-ListImported] [-ParameterName <string[]>]
 [-ParameterType <PSTypeName[]>] [-UseFuzzyMatching]
 [-FuzzyMinimumDistance <uint>] [-UseAbbreviationExpansion]
 [<CommonParameters>]
Get-Help
   [[-Name] <String>]
   [-Path <String>]
   [-Category <String[]>]
   [-Component <String[]>]
   [-Functionality <String[]>]
   [-Role <String[]>]
   -ShowWindow
   [<CommonParameters>]
// Ensure object exists
currentAccount ||= {};

// Ensure movementsDates exists if currentAccount already has it defined
currentAccount.movementsDates ||= [];

// Add the current date in ISO format to the movementsDates array
currentAccount.movementsDates.push(new Date().toISOString());

console.log(currentAccount.movementsDates);
$category = CategoryModel::query()->whereJsonContains('slug->' . app()->getLocale(), $category)->first();
dd($category->toArray());
'policy' => Rule::requiredIf(function ()  {
                return request()->status == 1 && request()->is_single == 1;
            }),



  public function messages()
    {
        return [
            'policy.required' => 'Please select Policy if you select "Single" Option',
        ];
    }
dependencies:
  dartz: ^0.10.1
class Animal {

    // Method in the superclass

    void sound() {

        System.out.println("Animal makes a sound");

    }

}

class Dog extends Animal {

    // Overriding the sound method in the subclass

    @Override

    void sound() {

        System.out.println("Dog barks");

    }

}

class Cat extends Animal {

    // Overriding the sound method in the subclass

    @Override

    void sound() {

        System.out.println("Cat meows");

    }

}

public class Main {

    public static void main(String[] args) {

        Animal myDog = new Dog();

        Animal myCat = new Cat();

        myDog.sound(); // Outputs: Dog barks

        myCat.sound(); // Outputs: Cat meows

    }

}

<!DOCTYPE html>
<html>
 <head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>My Mobile-First Approach</title>
   <style>
     /* Default styles for mobile */
     .grid-container-flex {
       display: flex;
       flex-direction: column;
       background-color: purple;
       font-size: 0.9rem;
       color: white;
       margin-top: 1rem;
       height: 9em;
     }

     .grid-container-grid {
       display: grid;
       grid-template-columns: 20em;
       height: 8em;
       font-size: 1.1rem;
     }

     /* Media query for tablets */
     @media (min-width: 768px) {
       .grid-container-flex {
         font-size: 1.3rem;
       }

       .grid-container-grid {
         grid-template-columns: none;
         height: 10em;
       }
     }

     /* Media query for desktops */
     @media (min-width: 1024px) {
       .grid-container-flex {
         font-size: 2rem;
       }

       .grid-container-grid {
         grid-template-columns: none;
         height: 12em;
       }
     }
   </style>
 </head>
 <body>
   <header>
     <h1>My Mobile-First Approach HTML Structuring</h1>
     <nav>
       <a href="">Home</a>
       <a href="">Shop</a>
       <a href="">Contact</a>
       <a href="">Store</a>
     </nav>
   </header>

   <main>
     <section class="grid-container-flex">
       <h2>About Us</h2>
       <p>We work with skilled artisans and select premium materials to craft footwear that stands the test of time</p>
     </section>

     <section class="grid-container-grid">
       <h2>Our Products</h2>
       <ul>
         <li>Men's shoes</li>
         <li>Women's Shoes</li>
         <li>Kid's Shoes</li>
       </ul>
     </section>

     <section>
       <h2>Contact Us</h2>
       <form>
         <label for="name">Name:</label>
         <input type="text" id="name" name="name">

         <label for="email">Email:</label>
         <input type="email" id="email" name="email">

         <label for="message">Message:</label>
         <textarea id="message" name="message"></textarea>

         <input type="submit" value="Send Message">
       </form>
     </section>
   </main>

   <footer>
     <p>&copy; 2023 My Mobile-First Approach Example. All rights reserved.</p>
   </footer>
 </body>
</html>
public class SumAvg {
    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6};
        int sum = 0;
        
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
        }
        
        double avg = (double) sum / array.length;
        
        System.out.println("Sum: " + sum);
        System.out.println("Average: " + avg);
    }
}
public class Command {
    public static void main(String[] args) {
        if (args.length > 0) {
            // Loop through each command-line argument
            for (int i = 0; i < args.length; i++) {
                // Print each argument along with its length
                System.out.println(args[i] + " " + args[i].length());
            }

            // Print the total number of arguments
            System.out.println("Total number of arguments: " + args.length);
        }
    }
}
// Custom exception class extending Exception

class CustomException extends Exception {

    public CustomException(String message) {

        super(message);

    }

}

// Custom error class extending Error

class CustomError extends Error {

    public CustomError(String message) {

        super(message);

    }

}

public class ThrowableAndExceptionDemo {

    public static void main(String[] args) {

        try {

            // Triggering custom exception

            triggerCustomException();

        } catch (CustomException e) {

            System.out.println("Caught custom exception: " + e.getMessage());

        } catch (Exception e) {

            System.out.println("Caught general exception: " + e.getMessage());

        }

        try {

            // Triggering custom error

            triggerCustomError();

        } catch (CustomError e) {

            System.out.println("Caught custom error: " + e.getMessage());

        } catch (Error e) {

            System.out.println("Caught general error: " + e.getMessage());

        }

        System.out.println("Program completed.");

    }

    // Method to trigger custom exception

    public static void triggerCustomException() throws CustomException {

        throw new CustomException("This is a custom exception.");

    }

    // Method to trigger custom error

    public static void triggerCustomError() {

        throw new CustomError("This is a custom error.");

    }

}

public class String_Builder {
    public static void main(String[] args) {
        StringBuilder s = new StringBuilder("hellooooooo");
        System.out.println(s);

        // Deleting characters from index 0 to 2 (exclusive)
        System.out.println(s.delete(0, 3));

        // Deleting the character at index 5
        System.out.println(s.deleteCharAt(5));

        // Inserting "Raghu" at index 3
        System.out.println(s.insert(3, "Varshith"));

        // Printing the length of the StringBuilder
        System.out.println(s.length());

        // Finding the last index of the string "oo"
        System.out.println(s.lastIndexOf("oo"));
    }
}
public class StringMethodsExample {
    public static void main(String[] args) {
        String str = "Hello, World!";

        // Length of the string
        int length = str.length();
        System.out.println("Length of the string: " + length);

        // Concatenation
        String newStr = str.concat(" How are you?");
        System.out.println("Concatenated string: " + newStr);

        // Substring
        String substring = str.substring(7);
        System.out.println("Substring from index 7: " + substring);

        // Character at a specific index
        char charAtIndex = str.charAt(0);
        System.out.println("Character at index 0: " + charAtIndex);

        // Index of a specific character
        int indexOfComma = str.indexOf(",");
        System.out.println("Index of comma: " + indexOfComma);

        // Conversion to lowercase and uppercase
        String lowercase = str.toLowerCase();
        String uppercase = str.toUpperCase();
        System.out.println("Lowercase: " + lowercase);
        System.out.println("Uppercase: " + uppercase);

        // Checking for presence of a substring
        boolean containsHello = str.contains("Hello");
        System.out.println("Contains 'Hello': " + containsHello);

        // Removing leading and trailing whitespaces
        String stringWithSpaces = "   Trim me   ";
        String trimmedString = stringWithSpaces.trim();
        System.out.println("Trimmed string: " + trimmedString);
    }
}
public class Student
{
	private String name;
	private String rollno;
	private int age;
	
	//Constructor
	public Student(String name,String rollno,int age)
	{
		this.name=name;
		this.rollno=rollno;
		this.age=age;
	}
	
	//Method
	public void display()
	{
		System.out.println("Name: "+this.name);
		System.out.println("Roll No: "+this.rollno);
		System.out.println("Age: "+this.age);
		
	}	
}
////////////////////////////////////////////////////////////////
public class StudentTest
{
	public static void main(String[] args)
	{
		Student s1= new Student("John","A100",22);
		Student s2= new Student("Abhi","5S0",18);
		
		s1.display();
		s2.display();
	}
}
public class MyMath{
    public static int add(int a, int b){
        return a+b;
    }
    public static double add(double a, double b){
        return a+b;

    }
    public static long add(long a,long b){
        return a+b;

    }
    public static float add(float a,float b){
        return a+b;
    }

}

///

public class MyMathTest{
    public static void main(String[] args){
        System.out.println(MyMath.add(1,2));
        System.out.println(MyMath.add(1234L,1432L));
        System.out.println(MyMath.add(1.27,24.8));
        System.out.println(MyMath.add(1.23F,1.45F));

    }
}
public class ExceptionHandlingDemo {

    public static void main(String[] args) {

        try {

            // Attempt to divide by zero

            int result = divide(10, 0);

            System.out.println("Result: " + result);

        } catch (ArithmeticException e) {

            // This block will execute when an ArithmeticException is caught

            System.out.println("Error: Division by zero is not allowed.");

        } finally {

            // This block will always execute

            System.out.println("This is the finally block, it always executes.");

        }

        try {

            // Attempt to access an invalid array index

            int[] array = {1, 2, 3};

            System.out.println("Array element: " + array[5]);

        } catch (ArrayIndexOutOfBoundsException e) {

            // This block will execute when an ArrayIndexOutOfBoundsException is caught

            System.out.println("Error: Array index out of bounds.");

        } finally {

            // This block will always execute

            System.out.println("This is the finally block for array access, it always executes.");

        }

        try {

            // Manually throwing an exception

            throwException();

        } catch (Exception e) {

            // This block will execute when a general Exception is caught

            System.out.println("Caught an exception: " + e.getMessage());

        } finally {

            // This block will always execute

            System.out.println("This is the finally block for throwException, it always executes.");

        }

    }

    // Method to demonstrate exception handling

    public static int divide(int a, int b) throws ArithmeticException {

        return a / b;

    }

    // Method to demonstrate manually throwing an exception

    public static void throwException() throws Exception {

        throw new Exception("This is a manually thrown exception.");

    }

}

public class StringBuilderDemo {

    public static void main(String[] args) {

        // Creating a StringBuilder object

        StringBuilder sb = new StringBuilder("Hello");

        // 1. append()

        sb.append(" World");

        System.out.println("After append: " + sb);

        // 2. insert()

        sb.insert(5, ",");

        System.out.println("After insert: " + sb);

        // 3. replace()

        sb.replace(5, 6, "!");

        System.out.println("After replace: " + sb);

        // 4. delete()

        sb.delete(5, 6);

        System.out.println("After delete: " + sb);

        // 5. deleteCharAt()

        sb.deleteCharAt(5);

        System.out.println("After deleteCharAt: " + sb);

        // 6. reverse()

        sb.reverse();

        System.out.println("After reverse: " + sb);

        

        // Reversing back to original for further operations

        sb.reverse();

        // 7. setCharAt()

        sb.setCharAt(5, '-');

        System.out.println("After setCharAt: " + sb);

        // 8. substring()

        String subStr = sb.substring(0, 5);

        System.out.println("Substring (0, 5): " + subStr);

        // 9. length()

        int length = sb.length();

        System.out.println("Length of StringBuilder: " + length);

        // 10. capacity()

        int capacity = sb.capacity();

        System.out.println("Capacity of StringBuilder: " + capacity);

        // Additional methods for better understanding

        // Ensure Capacity

        sb.ensureCapacity(50);

        System.out.println("New Capacity after ensureCapacity(50): " + sb.capacity());

        // Trim to Size

        sb.trimToSize();

        System.out.println("Capacity after trimToSize: " + sb.capacity());

    }

}
public class StringBufferDemo {

    public static void main(String[] args) {

        // Creating a StringBuffer object

        StringBuffer sb = new StringBuffer("Hello");

        // 1. append()

        sb.append(" World");

        System.out.println("After append: " + sb);

        // 2. insert()

        sb.insert(5, ",");

        System.out.println("After insert: " + sb);

        // 3. replace()

        sb.replace(5, 6, "!");

        System.out.println("After replace: " + sb);

        // 4. delete()

        sb.delete(5, 6);

        System.out.println("After delete: " + sb);

        // 5. deleteCharAt()

        sb.deleteCharAt(5);

        System.out.println("After deleteCharAt: " + sb);

        // 6. reverse()

        sb.reverse();

        System.out.println("After reverse: " + sb);

        

        // Reversing back to original for further operations

        sb.reverse();

        // 7. setCharAt()

        sb.setCharAt(5, '-');

        System.out.println("After setCharAt: " + sb);

        // 8. substring()

        String subStr = sb.substring(0, 5);

        System.out.println("Substring (0, 5): " + subStr);

        // 9. length()

        int length = sb.length();

        System.out.println("Length of StringBuffer: " + length);

        // 10. capacity()

        int capacity = sb.capacity();

        System.out.println("Capacity of StringBuffer: " + capacity);

        // Additional methods for better understanding

        // Ensure Capacity

        sb.ensureCapacity(50);

        System.out.println("New Capacity after ensureCapacity(50): " + sb.capacity());

        // Trim to Size

        sb.trimToSize();

        System.out.println("Capacity after trimToSize: " + sb.capacity());

    }

}
//Producer-Consumer Inter-thread communication

//Table.java 

public class Table
{
	private String obj;
	private boolean empty = true;
	 
	public synchronized void put(String obj)
	{  
	   if(!empty)
	    {   try
		    {  wait();
			}catch(InterruptedException e)
			{ e.printStackTrace(); }
		}
				
		this.obj = obj; 
		empty = false;
		System.out.println(Thread.currentThread().getName()+" has put "+obj);
		notify();
		
	}
	
	public synchronized void get()
	{   
	    if(empty)
	    {   try
		    {   wait();
			}catch(InterruptedException e)
			{ e.printStackTrace(); }
		}
		
		empty = true;
		System.out.println(Thread.currentThread().getName()+" has got "+obj);
		notify();		
	}
	
	public static void main(String[] args)
	{
		Table table = new Table();
		
		Runnable p = new Producer(table);
		Runnable c = new Consumer(table);
		
		Thread pthread = new Thread(p, "Producer");
		Thread cthread = new Thread(c, "Consumer");
		
		pthread.start(); cthread.start();
		
		try{ pthread.join(); cthread.join(); }
		catch(InterruptedException e){ e.printStackTrace(); }
	}
}

/////////////Producer.java

public class Producer implements Runnable
{   private Table table;

	public Producer(Table table)
	{ this.table = table; }
	
	public void run()
	{   java.util.Scanner scanner = new java.util.Scanner(System.in);
		for(int i=1; i <= 5; i++)
		{   System.out.println("Enter text: ");
	        table.put(scanner.next());	
            try{ Thread.sleep(1000); }	
			catch(InterruptedException e){ e.printStackTrace(); }		
		}
	}
}

///////////Consumer.java

public class Consumer implements Runnable
{   
	private Table table;

	public Consumer(Table table)
	{ this.table = table; }
	
	public void run()
	{   for(int i=1; i <= 5; i++){ 
			table.get();
		}
		
	}
}

import java.io.*;
public class OutputStreamDemo{
	public static void main(String[] args){
		FileInputStream fis = null;
		FileOutputStream fos = null;
		try{
			fis = new FileInputStream("input.txt");
			fos = new FileOutputStream("output.txt");
			System.out.println("Available data "+fis.available()+" data");
			int c = fis.read();
			while(c!=-1){
				fos.write((char)c);
				c = fis.read();
			}
		}
		catch(IOException ie){
			ie.printStackTrace();
		}
		finally{
			try{
				if(fis!=null)
					fis.close();
			}
			catch(IOException ie){
				ie.printStackTrace();
			}                                    
			try{
				if(fos!=null)
					fos.close();
			}
			catch(IOException ie){
				ie.printStackTrace();
			}
		}
	}
}
import java.io.*;

public class InputStreamDemo{
	public static void main(String[] args){
	FileInputStream fis = null;
	try{
		fis = new FileInputStream("InputStreamDemo.java");
		System.out.println("Available data: "+fis.available()+" bytes");
		int c = fis.read();
		while(c!=-1){
			System.out.println((char)c);
			c = fis.read();
		}
	}
	catch(IOException ie){
		ie.printStackTrace();
	}
	finally{
		try{
			if(fis!=null)
				fis.close();
		}
		catch(IOException ie){
			ie.printStackTrace();
		}
	}
	}
}
star

Tue Jul 09 2024 01:39:32 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/test-pssessionconfigurationfile?view

@Dewaldt

star

Tue Jul 09 2024 01:39:23 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/test-pssessionconfigurationfile?view

@Dewaldt

star

Tue Jul 09 2024 01:39:05 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/test-pssessionconfigurationfile?view

@Dewaldt

star

Tue Jul 09 2024 01:38:25 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:36:57 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:35:39 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:35:29 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:34:50 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:34:38 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:34:26 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:33:35 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:33:25 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:33:15 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:32:42 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:32:17 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:32:06 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:31:43 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-command?view

@Dewaldt

star

Tue Jul 09 2024 01:31:28 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-command?view

@Dewaldt

star

Tue Jul 09 2024 01:30:37 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:30:24 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:30:03 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:29:57 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:29:36 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:29:27 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:28:35 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:28:07 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:26:52 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:26:30 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:26:21 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:25:37 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-help?view

@Dewaldt

star

Mon Jul 08 2024 22:54:44 GMT+0000 (Coordinated Universal Time)

@davidmchale #checking #object

star

Mon Jul 08 2024 19:47:45 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/66080731/laravel-8-x-where-json-search-in-array

@xsirlalo

star

Mon Jul 08 2024 19:30:30 GMT+0000 (Coordinated Universal Time) https://laracasts.com/discuss/channels/laravel/laravel-request-validation-rule-based-on-two-values

@xsirlalo

star

Mon Jul 08 2024 18:16:18 GMT+0000 (Coordinated Universal Time)

@Hussein

star

Mon Jul 08 2024 17:45:51 GMT+0000 (Coordinated Universal Time) https://www.blackbox.ai/playground?action

@j3d1n00b

star

Mon Jul 08 2024 17:40:56 GMT+0000 (Coordinated Universal Time)

@projectrock

star

Mon Jul 08 2024 16:43:52 GMT+0000 (Coordinated Universal Time) https://blog.openreplay.com/mobile-first-approach-with-html-and-css/

@Black_Shadow

star

Mon Jul 08 2024 16:13:52 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon Jul 08 2024 16:13:14 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon Jul 08 2024 16:12:41 GMT+0000 (Coordinated Universal Time)

@projectrock

star

Mon Jul 08 2024 16:12:35 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon Jul 08 2024 16:11:35 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon Jul 08 2024 16:10:29 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon Jul 08 2024 16:09:35 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon Jul 08 2024 16:06:13 GMT+0000 (Coordinated Universal Time)

@projectrock

star

Mon Jul 08 2024 15:45:55 GMT+0000 (Coordinated Universal Time)

@projectrock

star

Mon Jul 08 2024 15:45:11 GMT+0000 (Coordinated Universal Time)

@projectrock

star

Mon Jul 08 2024 15:19:46 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon Jul 08 2024 14:51:56 GMT+0000 (Coordinated Universal Time)

@projectrock

star

Mon Jul 08 2024 14:50:56 GMT+0000 (Coordinated Universal Time)

@projectrock

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension