Snippets Collections
Conditional statements:
1.Write PL/SQL Program to find the sum of two numbers.
2.Write PL/SQL Program to display even numbers in a given range.
3.Write PL/SQL Program to find the given number is prime or not.
4.Write PL/SQL Program to find the given number is perfect or not.
5.Write PL/SQL Program to find the given number is armstrong or not.
Functions
1.Write a Function to find Factorial of a given number.
2.Write a Function to find GCD of a two numbers.
3.Write a Function to find x^n.
Procedures
1.Write a Procedure to find Fibonacci series upto given range.
2.Write a Procedure to swap two numbers.
3.Write a Procedure to Reverse a number.
4.Write a Procedure to find the given number is Palindrome or not.
Cursors
1.Write a Program to check whether there is atleast one row satisfying given select statement or not using implict cursor.          
2.Write a Program to change the ename colummn values to uppercase using implict cursor.
3.Write a Program to update the salary of those employee to 20% whose salary is greater than the given salary,using implict cursor.
4.Write a Program to display details of employee using explicit cursor.
5.Write a Program using explicit cursor to display first 5 records only.
6.Write a Program using explicit cursor to insert values into a table empc from employee table,whose experience >=23.
7.Write a Program to display all employee's details working in the accepted department number using cursor for loop.
Exceptions
1.Write a Progrsm for creating an exception & raising it when the basic is <3000,while inserting rows into a table & also handle it to perform any other action.
2.Write a Program for creating an exception & raising it when ever you try to insert any negative number into a table.
3.Write a Program to handle value error exception.
4.Write a Program to raise inavlidCursor exception.
Triggers:
1.Write a trigger to display a message when Record is inserted in employee table(using before).
2.Write a trigger to display a message when Record is inserted in employee table(using After).
3.Write a trigger to display a message when Record is inserted or updated in employee table.






#include<stdio.h>
 
struct process {
    int pid;      
    int burst;   
    int waiting;  
    int turnaround;
};
 
void calculateTimes(struct process proc[], int n) {
    int total_waiting = 0, total_turnaround = 0;
   
    proc[0].waiting = 0;
    
    proc[0].turnaround = proc[0].burst;
 
    for (int i = 1; i < n; i++) {
        proc[i].waiting = proc[i - 1].waiting + proc[i - 1].burst;
        proc[i].turnaround = proc[i].waiting + proc[i].burst;
    }
}
 
void displayProcesses(struct process proc[], int n) {
    printf("Process ID\tBurst Time\tWaiting Time\tTurnaround Time\n");
    for (int i = 0; i < n; i++) {
        printf("%d\t\t%d\t\t%d\t\t%d\n", proc[i].pid, proc[i].burst, proc[i].waiting, proc[i].turnaround);
    }
}
 
void calculateAverages(struct process proc[], int n, float *avg_waiting, float *avg_turnaround) {
    int total_waiting = 0, total_turnaround = 0;
    for (int i = 0; i < n; i++) {
        total_waiting += proc[i].waiting;
        total_turnaround += proc[i].turnaround;
    }
    *avg_waiting = (float)total_waiting / n;
    *avg_turnaround = (float)total_turnaround / n;
}
 
int main() {
    int n; 
    printf("Enter the number of processes: ");
    scanf("%d", &n);
    struct process proc[n]; 
    printf("Enter the burst time for each process:\n");
    for (int i = 0; i < n; i++) {
        proc[i].pid = i + 1;
        printf("Process %d: ", i + 1);
        scanf("%d", &proc[i].burst);
    }
    calculateTimes(proc, n);
    displayProcesses(proc, n);
    float avg_waiting, avg_turnaround;
    calculateAverages(proc, n, &avg_waiting, &avg_turnaround);
    printf("\nAverage Waiting Time: %.2f\n", avg_waiting);
    printf("Average Turnaround Time: %.2f\n", avg_turnaround);
 
    return 0;
}
 
 
 
 
Output:
 
Enter the number of processes: 4
Enter the burst time for each process:
Process 1: 1
Process 2: 2
Process 3: 3
Process 4: 4
Process ID	Burst Time	Waiting Time	Turnaround Time
1		1		0		1
2		2		1		3
3		3		3		6
4		4		6		10
 
Average Waiting Time: 2.50
Average Turnaround Time: 5.00
code:
#include<stdio.h>  
    #include<stdlib.h>  
     
    void main()  {  
        int i, NOP, sum=0,count=0, y, quant, wt=0, tat=0, at[10], bt[10], temp[10];  
        float avg_wt, avg_tat;  
        printf(" Total number of process in the system: ");  
        scanf("%d", &NOP);  
        y = NOP; 
    for(i=0; i<NOP; i++){  
    printf("\n Enter the Arrival and Burst time of the Process[%d]\n", i+1);  
    printf(" Arrival time is: \t");   
    scanf("%d", &at[i]);  
    printf(" \nBurst time is: \t"); 
    scanf("%d", &bt[i]);  
    temp[i] = bt[i]; 
    }  
    printf("Enter the Time Quantum for the process: \t");  
    scanf("%d", &quant);  
    printf("\n Process No \t\t Burst Time \t\t TAT \t\t Waiting Time ");  
    for(sum=0, i = 0; y!=0; )  
    {  
    if(temp[i] <= quant && temp[i] > 0){  
        sum = sum + temp[i];  
        temp[i] = 0;  
        count=1;  
        }    
        else if(temp[i] > 0){  
            temp[i] = temp[i] - quant;  
            sum = sum + quant;    
        }  
        if(temp[i]==0 && count==1){  
            y--;  
            printf("\nProcess No[%d] \t\t %d\t\t\t\t %d\t\t\t %d", i+1, bt[i], sum-at[i], sum-at[i]-bt[i]);  
            wt = wt+sum-at[i]-bt[i];  
            tat = tat+sum-at[i];  
            count =0;    
        }  
        if(i==NOP-1)  
        {i=0;}  
        else if(at[i+1]<=sum){  
            i++;  
        }  
        else { i=0; }  
    }  

    avg_wt = wt * 1.0/NOP;  
    avg_tat = tat * 1.0/NOP;  
    printf("\n Average Turn Around Time: \t%f", avg_tat);  
    printf("\n Average Waiting Time: \t%f",avg_wt);
    }
    
output:
Total number of process in the system: 4
 Enter the Arrival and Burst time of the Process[1]
 Arrival time is: 	2
Burst time is: 	6
 Enter the Arrival and Burst time of the Process[2]
 Arrival time is: 	4
Burst time is: 	7
 Enter the Arrival and Burst time of the Process[3]
 Arrival time is: 	4
Burst time is: 	8
 Enter the Arrival and Burst time of the Process[4]
 Arrival time is: 	8
Burst time is: 	2
Enter the Time Quantum for the process: 	3
 Process No 		 Burst Time 		 TAT 		 Waiting Time 
Process No[1] 		 6				 4			 -2
Process No[4] 		 2				 6			 4
Process No[2] 		 7				 17			 10
Process No[3] 		 8				 19			 11
 Average Turn Around Time: 	11.500000
 Average Waiting Time: 	5.750000
#include <stdio.h>
 
struct Process {
    int process_id;
    int arrival_time;
    int burst_time;
};
 
void sjf_scheduling(struct Process processes[], int n) {
    int completion_time[n];
    int waiting_time[n];
    int turnaround_time[n];

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (processes[i].arrival_time > processes[j].arrival_time) {
                struct Process temp = processes[i];
                processes[i] = processes[j];
                processes[j] = temp;
            }
        }
    }
 
    int current_time = 0;
    for (int i = 0; i < n; i++) {
        printf("Enter details for process %d:\n", i + 1);
        printf("Process ID: ");
        scanf("%d", &processes[i].process_id);
        printf("Arrival Time: ");
        scanf("%d", &processes[i].arrival_time);
        printf("Burst Time: ");
        scanf("%d", &processes[i].burst_time);
        if (current_time < processes[i].arrival_time) {
            current_time = processes[i].arrival_time;
        }
        completion_time[i] = current_time + processes[i].burst_time;
        waiting_time[i] = current_time - processes[i].arrival_time;
        turnaround_time[i] = waiting_time[i] + processes[i].burst_time;
        current_time += processes[i].burst_time;
    }
    printf("\nProcess\tCompletion Time\tWaiting Time\tTurnaround Time\n");
    for (int i = 0; i < n; i++) {
        printf("%d\t\t%d\t\t%d\t\t%d\n", processes[i].process_id, completion_time[i], waiting_time[i], turnaround_time[i]);
    }

    int total_waiting_time = 0;
    int total_turnaround_time = 0;
    for (int i = 0; i < n; i++) {
        total_waiting_time += waiting_time[i];
        total_turnaround_time += turnaround_time[i];
    }
    float avg_waiting_time = (float)total_waiting_time / n;
    float avg_turnaround_time = (float)total_turnaround_time / n;
    printf("\nAverage Waiting Time: %.2f\n", avg_waiting_time);
    printf("Average Turnaround Time: %.2f\n", avg_turnaround_time);
}
 
int main() {
    int n;
    printf("Enter the number of processes: ");
    scanf("%d", &n);
    struct Process processes[n];
    sjf_scheduling(processes, n);
    return 0;
}
 Enter the number of processes: 5
Enter details for process 1:
Process ID: 1
Arrival Time: 2
Burst Time: 2
Enter details for process 2:
Process ID: 2
Arrival Time: 4
Burst Time: 3
Enter details for process 3:
Process ID: 3
Arrival Time: 6
Burst Time: 4
Enter details for process 4:
Process ID: 4
Arrival Time: 8
Burst Time: 5
Enter details for process 5:
Process ID: 5
Arrival Time: 10
Burst Time: 6

Process	Completion Time	Waiting Time	Turnaround Time
1		4		0		2
2		7		0		3
3		11		1		5
4		16		3		8
5		22		6		12

Average Waiting Time: 2.00
Average Turnaround Time: 6.00

 
var url = "http://scratch99.com/web-development/javascript/";
var urlParts = url.replace('http://','').replace('https://','').split(/[/?#]/);
var domain = urlParts[0];
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BowlingBall : MonoBehaviour
{
    public float forwardForce;
    public float leftBorder;
    public float rightBorder;
    public float moveIncrement;

    public Rigidbody rig;

 

    public void Bowl ()
    {
        rig.AddForce(transform.forward * forwardForce, ForceMode.Impulse);
    }

    public void MoveLeft()
    {
        transform.position += new Vector3(-moveIncrement, 0, 0);
    }

    public void MoveRight()
    {
        transform.position += new Vector3(moveIncrement, 0, 0);
    }
}
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#Persistent

; Hotkeys
^Numpad1::Copy(1)
^Numpad4::Paste(1)
^Numpad7::Clear(1)

^Numpad2::Copy(2)
^Numpad5::Paste(2)
^Numpad8::Clear(2)

^Numpad3::Copy(3)
^Numpad6::Paste(3)
^Numpad9::Clear(3)

Copy(clipboardID)
{
	global ; All variables are global by default
	local oldClipboard := ClipboardAll ; Save the (real) clipboard
	
	Clipboard = ; Erase the clipboard first, or else ClipWait does nothing
	Send ^c
	ClipWait, 2, 1 ; Wait 1s until the clipboard contains any kind of data
	if ErrorLevel 
	{
		Clipboard := oldClipboard ; Restore old (real) clipboard
		return
	}
	
	ClipboardData%clipboardID% := ClipboardAll
	
	Clipboard := oldClipboard ; Restore old (real) clipboard
}

Cut(clipboardID)
{
	global ; All variables are global by default
	local oldClipboard := ClipboardAll ; Save the (real) clipboard
	
	Clipboard = ; Erase the clipboard first, or else ClipWait does nothing
	Send ^x
	ClipWait, 2, 1 ; Wait 1s until the clipboard contains any kind of data
	if ErrorLevel 
	{
		Clipboard := oldClipboard ; Restore old (real) clipboard
		return
	}
	ClipboardData%clipboardID% := ClipboardAll
	
	Clipboard := oldClipboard ; Restore old (real) clipboard
}

Paste(clipboardID)
{
	global
	local oldClipboard := ClipboardAll ; Save the (real) clipboard

	Clipboard := ClipboardData%clipboardID%
	Send ^v

	Clipboard := oldClipboard ; Restore old (real) clipboard
	oldClipboard = 
}

Clear(clipboardID)
{
	global
	local oldClipboard := ClipboardAll ; Save the (real) clipboard

	Clipboard := ClipboardData%clipboardID%
	ClipboardData%clipboardID% :=

	Clipboard := oldClipboard ; Restore old (real) clipboard
	oldClipboard = 
}
from peewee import SqliteDatabase, Model, UUIDField, CharField, IntegerField
from uuid import uuid4

db = SqliteDatabase('mydb.db')

# Create user Model
class User(Model):
    userId = UUIDField(primary_key = True, default = uuid4)
    name = CharField(max_length = 10)
    age = IntegerField()

    class Meta:
        database = db

# Connect to db
db.connect()
db.create_tables([User])
db.commit()

# Add new user to database
user = User.create(name = 'user123', age = 20)
user.save()

# Get all users
for user in User.select():
    print(user.name, user.userId)
Hi! dear i have a Coat Pin Shop in Bangladesh. i want make purchase from you. i need customized Coat Pin for multiple Company coat pin and medal. so please let me know how you work. please email me.
Material: Metal/zinc alloy/iron/brass,
Size: Custom size
Plating: Gold/Silver/Black Nickel
Color: Custom colors
Logo: Customer Logo
Back accessories: Rubber buckle/butterfly cap/safety pin
transport: Courier/Marine/DHL UPS TNT FEDEX EMS
custom enamel pin: pin badge
Material: Metal
Printing: Letterpress printing
Printing: Gravure printing
Printing: Silk screen printing
Printing: Digital printing
Printing: UV printing
Printing: Thermal transfer printing
Printing: Embossing printing
Printing: Die cutting printing
Print Method: 1 color
Print Method: 2 color
Print Method: 4 color
Print Method: 5 color
Print Method: 6 color
Type: metal
Product Type: Badge & Emblem
Style: Cartoon, animal, love
Theme: Cartoon, animal, love
Regional Feature: China, Japan, United States, Europe, UAE, Australia
Technique: Die casting, stamping, soft enamel, hard enamel
Use: Souvenirs, gifts, decorations, promotions
div#comparison { 

  width: 0vw;

  height: 60vw;

  max-width: 600px;

  max-height: 600px;
6
  overflow: hidden; }

div#comparison figure { 

  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/photoshop-face-before.jpg); 

  background-size: cover;

  position: relative;

  font-size: 0;

  width: 100%; 

  height: 100%;

  margin: 0; 

}

div#comparison figure > img { 

  position: relative;

  width: 100%;

}

div#comparison figure div { 

  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/photoshop-face-after.jpg);

  background-size: cover;
<div id="comparison">

  <figure>

    <div id="divisor"></div>

  </figure>

  <input type="range" min="0" max="100" value="50" id="slider" oninput="moveDivisor()">

</div>

​
#include <iostream>
using namespace std;

int main() {
    int num;
    cout << "Keya Aap Ko Janna Hai Ki Yahan Jo aap No. Enter Ker Rahen Hain Wo Even Hai Yo Odd? : " << endl;
    cout << "To Der Kis Baat Ki Number Enter Karen Aur Dekhen Mere Dimag ka Kamal: " << endl;
    cin >> num;
    if (num % 2 == 0)
        cout << "    ----- Ye Even No. Hai Agar Main Sahi Houn To Mere Channal Ko Like Karen Thanks." << endl;
    else
        cout << "    ----- Ye Odd No. Hai Agar Main Sahi Houn To Mere Channal Ko Like Karen Thanks. " << endl;
    return 0;
}
String objType='Contact';
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType leadSchema = schemaMap.get(objType);
Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
List<String> shagni = new List<String>();

for (String fieldName: fieldMap.keySet()) {
  Schema.DisplayType fielddataType = fieldMap.get(fieldName).getDescribe().getType();
  System.debug(fielddataType);
}
#include <iostream>
using namespace std;

int main() {
    int num1 = 5, num2 = 3;
    int sum = num1 + num2;
    cout << "5 Aur 3 Ko Jodna Tha Na Ans Hai : " << sum << endl;
    cout << "Agar Main Sahi Houn To Muskura Dijye Smile PLZ........." << endl;
    return 0;
}
#include <iostream>
using namespace std;

int main() {
    cout << "Asalam o Alikum!" << endl;
    return 0;
}
string np = [SELECT NamespacePrefix FROM Organization].NamespacePrefix;
System.debug(np);
Email was not designed to be used as an alert console. It is not a scalable solution when it comes to monitoring and alert visualisation. A minimal installation of Alerta can be deployed quickly and easily extended as monitoring requirements and confidence grow.
Augmentor is an AI framework for Drupal which allows for the easy integration of disparate AI systems into Drupal.

Augmentor provides a plugable ecosystem for managing a variety of AI services such as GPT3, ChatGPT, NLP Cloud, Google Cloud Vision and many more.
google_cloud_vision_safe_search: Detects explicit content such as adult content or violent content within an image.
google_cloud_vision_labels_detection: Detect labels on an image.
View(active tab)
Version control
21people starred this project

Integrates your Drupal site with CrowdSec to keep suspicious users and cybercriminals away. No account with CrowdSec required, and no other agent software to be installed. This module brings everything required with it. Download with composer, enable the module and rest assured, that a lot of malicious traffic and many attack vectors will just be gone!
Mattermost is an open source platform for secure collaboration across the entire software development lifecycle. This repo is the primary source for core development on the Mattermost platform; it's written in Go and React and runs as a single Linux binary with MySQL or PostgreSQL. A new compiled version is released under an MIT license every month on the 16th.
<template>
    <lightning-combobox
            name="progress"
            label="Status"
            value={value}
            placeholder="Select Progress"
            options={options}
            onchange={handleChange} ></lightning-combobox>

    <p>Selected value is: {value}</p>
</template>

https://developer.salesforce.com/docs/component-library/bundle/lightning-combobox/example
Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();

for (Schema.ChildRelationship cr: R.getChildRelationships()) {
    if (cr.getRelationshipName() == null) continue;
    system.debug('Child Object Relationship Name:'+cr.getRelationshipName());            
}
from selenium import webdriver
from selenium.webdriver.common.by import By
from dotenv import load_dotenv

# https://pypi.org/project/2captcha-python/
from twocaptcha import TwoCaptcha


import time
import sys
import os

# https://github.com/2captcha/2captcha-python

sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))


url = 'https://accounts.hcaptcha.com/demo'

driver = webdriver.Chrome()

driver.get(url=url)

time.sleep(2)

site_key = driver.find_element(
    by = By.XPATH, 
    value = '//*[@id="hcaptcha-demo"]').get_attribute('data-sitekey')




load_dotenv()

# create account in 2captcha from here : https://bit.ly/3MkkuPJ
# make deposit at least 3$
# https://2captcha.com/pay

# create env file or you can put your API key direct in TwoCaptcha function


api_key = os.getenv('APIKEY_2CAPTCHA')


api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')

solver = TwoCaptcha(api_key)

try:
    result = solver.hcaptcha(
        sitekey=site_key,
        url=url,
    )

    code = result['code']
    print(code)

    

    driver.execute_script(f"document.getElementsByName('h-captcha-response')[0].innerHTML = '{code}'")
    
    # submit
    driver.find_element(by = By.ID, value = 'hcaptcha-demo-submit').click()
    

except Exception as e:
    sys.exit(e)



input()
title: "number positive/negative"
.model small
.stack 100h
.data
   num1 db 80h
  positive db "The number is positive $"
  negative db "The number is negative $"
  zero db "The number is zero $"
.code
   mov ax,@data
       mov ds,ax
       xor ax,ax
   mov al,num1
   cmp num1,0
   jp greater
   jl lower
   jz zeros 
greater: mov ah,09h
         lea dx,positive
         jnt 21h
         jmp end
lower: mov ah,09h
       lea dx,zero
       int 21h
end:mov ah,4ch
    int 21h
end        
title: "count no.of 0's"
.model small
.stack 100h
.data
   num1 db 0feh
   count db dup(0)
.code
   start:
   mov ax,@data
       mov ds,ax
       xor ax,ax
   mov al,num1
   mov cx,08
   mov bl,0 
   again: rol al,1
          jc noadd
          inc bl
   noadd:loop again
         mov count,bl
   mov ah,4ch
       int 21h
end             
title: "count no.of 1's"
.model small
.stack 100h
.data
   num1 db 05
   count db dup(0)
.code
   mov ax,@data
       mov ds,ax
       xor ax,ax
   mov al,num1
   mov cx,08
   mov bl,0 
   again: rol al,1
          jnc noadd
          inc bl
   noadd:loop again
         mov count,bl
title: "aaa"
.model small
.stack 100h
.data
   num1 db '9'
   num2 db '5'
   ascadj dw dup(0)
.code
   mov ax,@data
       mov ds,ax
       xor ax,ax
   mov al,num1
   add al,num2
   aaa
   mov ascadj,ax
   mov ah,4ch
       int 21h
end              
title: "daa"
.model small
.stack 100h
.data
   num1 dw 59h
   num2 dw 35h
   ascadj dw dup(0)
.code
   mov ax,@data
       mov ds,ax
       xor ax,ax
   mov ax,num1
   add ax,num2
   daa
   mov ascadj,ax
   mov ah,4ch
       int 21h
end         
title: "pack"
.model small
.stack 100h
.data
   num1 db 09h
   num2 db 05h
   pack db dup(0)
.code
   mov ax,@data
       mov ds,ax
       xor ax,ax
   mov al,num1
   add al,num2
   ror al,4
   or al,bl
   mov pack,al
   mov ah,4ch
       int 21h
end         
title:"aaa"
.model small
.stack 100h
.data
    num1 db '9'
    num2 db '5'
    ascadj dw dup(0)
.code
    mov ax,@data
    mov ds,ax
    xor ax,ax
    mov al,num1
    add al,num2
    aaa
    mov ascadj,ax
    mov ah,4ch
    int 21h
end
2------------------------------------------------------------------------------------
//BinarySearchTree.java
public class BinarySearchTree {
    public Node insertNode(Node root, int data) {
        if (root == null) {
            return new Node(data);
        }

        if (data < root.data) {
            root.left = insertNode(root.left, data);
        } else if (data > root.data) {
            root.right = insertNode(root.right, data);
        }

        return root;
    }

    public void display(Node root) {
        if (root != null) {
            display(root.left);
            System.out.print(root.data + " ");
            display(root.right);
        }
    }

    public int printAncestor(Node root, int element) {
        System.out.println("Ancestors of "+element+": ");
        return printAncestorHelper(root, element);
    }

    private int printAncestorHelper(Node root, int element) {
        if (root == null) {
            return 0;
        }

        if (root.data == element) {
            return 1;
        }

        if (printAncestorHelper(root.left, element) == 1 || printAncestorHelper(root.right, element) == 1) {
            System.out.print(root.data + " ");
            return 1;
        }

        return 0;
    }
}
// Main.java
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        BinarySearchTree bst = new BinarySearchTree();
        Node root = null;
        int choice;

        do {
            System.out.println("Binary Search Tree Implementation");
            System.out.println("1. Insert");
            System.out.println("2. Print ancestor");
            System.out.println("3. Display");
            System.out.println("4. Exit");
            System.out.println("Enter your choice: ");
            choice = scanner.nextInt();

            switch (choice) {
                case 1:
                    System.out.println("Enter the element to insert: ");
                    int elementToInsert = scanner.nextInt();
                    root = bst.insertNode(root, elementToInsert);
                    System.out.println("Element inserted successfully.");
                    break;
                case 2:
                    System.out.println("Enter the element to find its ancestor: ");
                    int elementToFindAncestor = scanner.nextInt();
                    bst.printAncestor(root, elementToFindAncestor);
                    System.out.println();
                    break;
                case 3:
                    if(root==null)
                        System.out.println("There are no elements in the BST. ");
                    else{
                        System.out.print("The elements are :");
                    bst.display(root);
                    }
                    break;
                case 4:
                    System.out.println("Exiting the program.");
                    break;
                default:
                    System.out.println("Invalid choice. Please try again.");
                    break;
            }
        } while (choice != 4);
    }
}

1-----------------------------------------------------------------------------------------------------------------------------------------------
public class BinaryTree {
 public void insert(TNode[] s, int num) {
        TNode newNode = new TNode(num);

        if (s[0] == null) {
            s[0] = newNode;
            return;
        }
        TNode root=s[0];
        while(root!=null){
            if(num > root.data){
                if(root.right==null){
                    root.right=newNode;
                    break;
                }
                root=root.right;
            }
            else{
                if(root.left==null){
                    root.left=newNode;
                    break;
                }
                root=root.left;
            }

        }
    }


    public void inorder(TNode s) {
        if (s != null) {
            inorder(s.left);
            System.out.print(s.data + " ");
            inorder(s.right);
        }
    }

    public int diameter(TNode tree) {
        if (tree == null) {
            return 0;
        }

        int leftHeight = height(tree.left);
        int rightHeight = height(tree.right);

        int leftDiameter = diameter(tree.left);
        int rightDiameter = diameter(tree.right);

        return max(leftHeight + rightHeight + 1, max(leftDiameter, rightDiameter));
    }

    public int height(TNode node) {
        if (node == null) {
            return 0;
        } else {
            int leftHeight = height(node.left);
            int rightHeight = height(node.right);

            return 1 + max(leftHeight, rightHeight);
        }
    }

    public int max(int a, int b) {
        return a > b ? a : b;
    }
}
class Client {
    private Integer clientId;
    private String clientName;
    private String phoneNumber;
    private String email;
    private String passport;
    private Country country;

    public Client() {
    }

    public Client(Integer clientId, String clientName, String phoneNumber, String email, String passport, Country country) {
        this.clientId = clientId;
        this.clientName = clientName;
        this.phoneNumber = phoneNumber;
        this.email = email;
        this.passport = passport;
        this.country = country;
    }

    // Getters and setters
    public Integer getClientId() {
        return clientId;
    }

    public void setClientId(Integer clientId) {
        this.clientId = clientId;
    }

    public String getClientName() {
        return clientName;
    }

    public void setClientName(String clientName) {
        this.clientName = clientName;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassport() {
        return passport;
    }

    public void setPassport(String passport) {
        this.passport = passport;
    }

    public Country getCountry() {
        return country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }

    @Override
    public String toString() {
        return String.format("%-25s %-25s %-25s %-25s %-25s %s", clientId, clientName, phoneNumber, email, passport, country);
    }
}

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter number of clients");
        int numClients = scanner.nextInt();
        scanner.nextLine(); // Consume newline
        Client[] clients = new Client[numClients];

        for (int i = 0; i < numClients; i++) {
            System.out.println("Enter client " + (i + 1) + " details:");
            System.out.println("Enter the client id");
            int clientId = scanner.nextInt();
            scanner.nextLine(); // Consume newline
            System.out.println("Enter the client name");
            String clientName = scanner.nextLine();
            System.out.println("Enter the phone number");
            String phoneNumber = scanner.nextLine();
            System.out.println("Enter the email id");
            String email = scanner.nextLine();
            System.out.println("Enter the passport number");
            String passport = scanner.nextLine();
            System.out.println("Enter the iata country code");
            String iataCountryCode = scanner.nextLine();
            System.out.println("Enter the country name");
            String countryName = scanner.nextLine();

            Country country = new Country(iataCountryCode, countryName);
            clients[i] = new Client(clientId, clientName, phoneNumber, email, passport, country);
        }

        ClientBO clientBO = new ClientBO();
        int choice;
        do {
            System.out.println("Menu:");
            System.out.println("1.View client details");
            System.out.println("2.Filter client with country");
            System.out.println("3.Exit");
            choice = scanner.nextInt();

            switch (choice) {
                case 1:
                    clientBO.viewDetails(clients);
                    break;
                case 2:
                    System.out.println("Enter country name");
                      scanner.nextLine();
                    String countryName = scanner.nextLine();
                    clientBO.printClientDetailsWithCountry(clients, countryName);
                    break;
                case 3:
                    break;
                default:
                    System.out.println("Invalid choice. Please enter again.");
            }
        } while (choice != 3);
    }
}

class Country {
    private String iataCountryCode;
    private String countryName;

    public Country() {
    }

    public Country(String iataCountryCode, String countryName) {
        this.iataCountryCode = iataCountryCode;
        this.countryName = countryName;
    }

    // Getters and setters
    public String getIataCountryCode() {
        return iataCountryCode;
    }

    public void setIataCountryCode(String iataCountryCode) {
        this.iataCountryCode = iataCountryCode;
    }

    public String getCountryName() {
        return countryName;
    }

    public void setCountryName(String countryName) {
        this.countryName = countryName;
    }

    @Override
    public String toString() {
        return String.format("%-25s %s\n", iataCountryCode, countryName);
    }
}

class ClientBO {
    public void viewDetails(Client[] clientList) {
        System.out.println("ClientId                  ClientName                PhoneNumber               Email                     Passport                  IATACountryCode           CountryName");
        for (Client client : clientList) {
            System.out.println(client);
        }
    }

    public void printClientDetailsWithCountry(Client[] clientList, String countryName) {
        System.out.println("ClientId                  ClientName                PhoneNumber               Email                     Passport                  IATACountryCode           CountryName");
        for (Client client : clientList) {
            if (client.getCountry().getCountryName().equalsIgnoreCase(countryName)) {
                System.out.println(client);
            }
        }
    }
}




//2-----------------------------------------------------------------------------------
// CountryBO.java
public class CountryBO {
    public Country createCountry(String data) {
        String[] parts = data.split(",");
        String iataCountryCode = parts[0];
        String countryName = parts[1];
        return new Country(iataCountryCode, countryName);
    }
}

// AirportBO.java
public class AirportBO {
    public Airport createAirport(String data, Country[] countryList) {
        String[] parts = data.split(",");
        String airportName = parts[0];
        String countryName = parts[1];
        Country country = null;
        for (Country c : countryList) {
            if (c.getCountryName().equals(countryName)) {
                country = c;
                break;
            }
        }
        return new Airport(airportName, country);
    }

    public String findCountryName(Airport[] airportList, String airportName) {
        for (Airport airport : airportList) {
            if (airport.getAirportName().equals(airportName)) {
                return airport.getCountry().getCountryName();
            }
        }
        return null;
    }

    public boolean findWhetherAirportsAreInSameCountry(Airport[] airportList, String airportName1, String airportName2) {
        String country1 = null;
        String country2 = null;
        for (Airport airport : airportList) {
            if (airport.getAirportName().equals(airportName1)) {
                country1 = airport.getCountry().getCountryName();
            }
            if (airport.getAirportName().equals(airportName2)) {
                country2 = airport.getCountry().getCountryName();
            }
        }
        return country1 != null && country2 != null && country1.equals(country2);
    }
}

// Airport.java
public class Airport {
    private String airportName;
    private Country country;

    public Airport() {
    }

    public Airport(String airportName, Country country) {
        this.airportName = airportName;
        this.country = country;
    }

    public String getAirportName() {
        return airportName;
    }

    public void setAirportName(String airportName) {
        this.airportName = airportName;
    }

    public Country getCountry() {
        return country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }
}

// Main.java
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter the country count");
        int countryCount = scanner.nextInt();
        scanner.nextLine(); // Consume newline
        Country[] countries = new Country[countryCount];

        CountryBO countryBO = new CountryBO();
        for (int i = 0; i < countryCount; i++) {
            System.out.println("Enter country " + (i + 1) + " details");
            String data = scanner.nextLine();
            countries[i] = countryBO.createCountry(data);
        }

        System.out.println("Enter the airport count");
        int airportCount = scanner.nextInt();
        scanner.nextLine(); // Consume newline
        Airport[] airports = new Airport[airportCount];

        AirportBO airportBO = new AirportBO();
        for (int i = 0; i < airportCount; i++) {
            System.out.println("Enter airport " + (i + 1) + " details");
            String data = scanner.nextLine();
            airports[i] = airportBO.createAirport(data, countries);
        }

        System.out.println("Enter the airport name for which you need to find the country name");
        String airportName = scanner.nextLine();
        String countryName = airportBO.findCountryName(airports, airportName);
        System.out.println(airportName + " belongs to " + countryName);

        System.out.println("Enter 2 airport names");
        String airportName1 = scanner.nextLine();
        String airportName2 = scanner.nextLine();
        boolean sameCountry = airportBO.findWhetherAirportsAreInSameCountry(airports, airportName1, airportName2);
        if (sameCountry) {
            System.out.println("The 2 airports are in the same Country");
        } else {
            System.out.println("The 2 airports are in the different Country");
        }
    }
}
// Country.java
public class Country {
    private String iataCountryCode;
    private String countryName;

    public Country() {
    }

    public Country(String iataCountryCode, String countryName) {
        this.iataCountryCode = iataCountryCode;
        this.countryName = countryName;
    }

    public String getIataCountryCode() {
        return iataCountryCode;
    }

    public void setIataCountryCode(String iataCountryCode) {
        this.iataCountryCode = iataCountryCode;
    }

    public String getCountryName() {
        return countryName;
    }

    public void setCountryName(String countryName) {
        this.countryName = countryName;
    }
}

import java.util.Scanner;

public class QuadraticProbing {

    public static int hashFunction(int key, int size) {
        return key % size;
    }

    public static void insert(int key, int[] hashTable, int size) {
        int index = hashFunction(key, size);
        if (hashTable[index] == -1) {
            hashTable[index] = key;
        } else {
            int i = 1;
            while (true) {
                int newIndex = (index + i * i) % size;
                if (hashTable[newIndex] == -1) {
                    hashTable[newIndex] = key;
                    break;
                }
                i++;
            }
        }
    }

    public static void display(int[] hashTable) {
        for (int i = 0; i < hashTable.length; i++) {
            if (hashTable[i] == -1) {
                System.out.println(" Element at position " + i + ": -1");
            } else {
                System.out.println(" Element at position " + i + ": " + hashTable[i]);
            }
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter the size of the hash table:");
        int size = scanner.nextInt();
        System.out.println("Enter the number of elements:");
        int n = scanner.nextInt();

        int[] hashTable = new int[size];
        for (int i = 0; i < size; i++) {
            hashTable[i] = -1;
        }

        System.out.println("Enter the Elements:");
        for (int i = 0; i < n; i++) {
            int key = scanner.nextInt();
            insert(key, hashTable, size);
        }

        System.out.println("\nThe elements in the array are:");
        display(hashTable);
    }
}
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        ArrayList<CallLog> callLogs = new ArrayList<>();

        try (BufferedReader br = new BufferedReader(new FileReader("weeklycall.csv"))) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] parts = line.split(",");
                if (parts.length == 4) {
                    String name = parts[0];
                    String dialledNumber = parts[1];
                    int duration = Integer.parseInt(parts[2]);
                    Date dialledDate = new SimpleDateFormat("yyyy-MM-dd").parse(parts[3]);
                        callLogs.add(new CallLog(name, dialledNumber, duration, dialledDate));

                }
            }
        } catch (IOException | ParseException e) {
            e.printStackTrace();
        }
        Collections.sort(callLogs);
        Collections.reverse(callLogs);
        System.out.println("Call-Logs");
        System.out.println("Caller  Name  Duration");

        for (CallLog log : callLogs) {
            System.out.println(log);
        }
    }
}

//CallLog.java
import java.util.Date;

public class CallLog implements Comparable<CallLog> {
    private String name;
    private String dialledNumber;
    private int duration;
    private Date dialledDate;

    public CallLog(String name,String d,int du,Date di){
        this.name=name;
        this.dialledNumber=d;
        this.duration=du;
        this.dialledDate=di;
    }
    @Override
    public int compareTo(CallLog other) {
        return this.name.compareTo(other.name);
    }

    @Override
    public String toString() {
        return name + "(+91-"+this.dialledNumber+") " + duration + " Seconds";
    }
}
//Hill.java
public class Hill {
   public int findPairCount(int[] arr) {
        int pairCount = 0;
        int n = arr.length;

        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (canSeeEachOther(arr, i, j)) {
                    pairCount++;
                }
            }
        }
        return pairCount;
    }

    private boolean canSeeEachOther(int[] arr, int i, int j) {
        for (int k = i + 1; k < j; k++) {
            if (arr[k] >= arr[i] || arr[k] >= arr[j]) {
                return false;
            }
        }
        return true;
    }

}

//Main.java
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Hill hill = new Hill();

        int n = scanner.nextInt();
        int[] heights = new int[n];

        for (int i = 0; i < n; i++) {
            heights[i] = scanner.nextInt();
        }

        int pairCount = hill.findPairCount(heights);
        System.out.println( pairCount);

    }
}

//2

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Main {
    static class Bug {
        int power;
        int position;

        Bug(int power, int position) {
            this.power = power;
            this.position = position;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int X = scanner.nextInt();
        Queue<Bug> queue = new LinkedList<>();

        for (int i = 1; i <= N; i++) {
            int power = scanner.nextInt();
            queue.add(new Bug(power, i));
        }


        int[] selectedPositions = findSelectedPositions(N, X, queue);
        

        for (int position : selectedPositions) {
            System.out.print(position + " ");
        }
    }

    static int[] findSelectedPositions(int N, int X, Queue<Bug> queue) {
        int[] selectedPositions = new int[X];

        for (int i = 0; i < X; i++) {
            int maxPower = -1;
            int maxIndex = -1;
            Queue<Bug> tempQueue = new LinkedList<>();


            for (int j = 0; j < X && !queue.isEmpty(); j++) {
                Bug bug = queue.poll();
                tempQueue.add(bug);
                if (bug.power > maxPower) {
                    maxPower = bug.power;
                    maxIndex = bug.position;
                }
            }

            selectedPositions[i] = maxIndex;


            while (!tempQueue.isEmpty()) {
                Bug bug = tempQueue.poll();
                 if (bug.position != maxIndex) {
                        if (bug.power > 0) {
                        bug.power--;
                    }
                    queue.add(bug);
                }
            }
        }

        return selectedPositions;
    }
}
//Hill.java
public class Hill {
   public int findPairCount(int[] arr) {
        int pairCount = 0;
        int n = arr.length;

        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (canSeeEachOther(arr, i, j)) {
                    pairCount++;
                }
            }
        }
        return pairCount;
    }

    private boolean canSeeEachOther(int[] arr, int i, int j) {
        for (int k = i + 1; k < j; k++) {
            if (arr[k] >= arr[i] || arr[k] >= arr[j]) {
                return false;
            }
        }
        return true;
    }

}

//Main.java
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Hill hill = new Hill();

        int n = scanner.nextInt();
        int[] heights = new int[n];

        for (int i = 0; i < n; i++) {
            heights[i] = scanner.nextInt();
        }

        int pairCount = hill.findPairCount(heights);
        System.out.println( pairCount);

    }
}

//2

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Main {
    static class Bug {
        int power;
        int position;

        Bug(int power, int position) {
            this.power = power;
            this.position = position;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int X = scanner.nextInt();
        Queue<Bug> queue = new LinkedList<>();

        for (int i = 1; i <= N; i++) {
            int power = scanner.nextInt();
            queue.add(new Bug(power, i));
        }


        int[] selectedPositions = findSelectedPositions(N, X, queue);
        

        for (int position : selectedPositions) {
            System.out.print(position + " ");
        }
    }

    static int[] findSelectedPositions(int N, int X, Queue<Bug> queue) {
        int[] selectedPositions = new int[X];

        for (int i = 0; i < X; i++) {
            int maxPower = -1;
            int maxIndex = -1;
            Queue<Bug> tempQueue = new LinkedList<>();


            for (int j = 0; j < X && !queue.isEmpty(); j++) {
                Bug bug = queue.poll();
                tempQueue.add(bug);
                if (bug.power > maxPower) {
                    maxPower = bug.power;
                    maxIndex = bug.position;
                }
            }

            selectedPositions[i] = maxIndex;


            while (!tempQueue.isEmpty()) {
                Bug bug = tempQueue.poll();
                 if (bug.position != maxIndex) {
                        if (bug.power > 0) {
                        bug.power--;
                    }
                    queue.add(bug);
                }
            }
        }

        return selectedPositions;
    }
}
extends Node3D


@onready var ap = $AuxScene/AnimationPlayer
@onready var raycast = $RayCast3D
@onready var eyes = $eyes
@onready var nav = $NavigationAgent3D

const speed = 5


enum {
	IDLE,
	ALERT,
	STUNND,
	CHASING
}

var target
const  T_S = 2
var state = IDLE

func _ready():
	pass # Replace with function body.

func _process(delta):
		
	match state:
		IDLE:
			ap.play("RifleIdle0")
		ALERT:
			ap.play("FiringRifle0")

			eyes.look_at(target.global_transform.origin, Vector3.UP)
			rotate_y(deg_to_rad(eyes.rotation.y * T_S))
			var direction = (target.global_transform.origin - global_transform.origin).normalized()
		CHASING:
			ap.play("RifleRun0")
			
func _on_area_3d_body_entered(body):
	if body.is_in_group("player"):
		state = ALERT
		target = body

func _on_area_3d_body_exited(body):
	if body.is_in_group("player"):
		state = CHASING



<?php
// Include WordPress bootstrap file
require_once('wp-load.php');

// Get global database object
global $wpdb;

// Function to generate SKU for variations
function generate_variation_sku($parent_sku, $attributes) {
    $sku = $parent_sku;
    foreach ($attributes as $attribute) {
        $sku .= '-' . strtoupper($attribute);
    }
    return $sku;
}

// Get all published parent products
$parent_products = $wpdb->get_results("
    SELECT ID, post_title
    FROM {$wpdb->posts}
    WHERE post_type = 'product'
    AND post_status = 'publish'
");

if ($parent_products) {
    $count = 1; // SKU counter
    foreach ($parent_products as $parent_product) {
        $parent_id = $parent_product->ID;

        // Get parent SKU
        $parent_sku = get_post_meta($parent_id, '_sku', true);

        // If parent SKU is empty or not set, assign a new SKU
        if (empty($parent_sku)) {
            $parent_sku = sprintf('%03d', $count); // Format SKU as 001, 002, etc.
            update_post_meta($parent_id, '_sku', $parent_sku);

            // Get variations for the parent product
            $variations = get_posts(array(
                'post_type' => 'product_variation',
                'post_status' => 'publish',
                'post_parent' => $parent_id,
                'fields' => 'ids'
            ));

            if ($variations) {
                foreach ($variations as $variation_id) {
                    // Get attributes for the variation
                    $variation_attributes = wc_get_product_variation_attributes($variation_id);

                    // Generate SKU for the variation
                    $variation_sku = generate_variation_sku($parent_sku, array_values($variation_attributes));

                    // Update SKU for the variation
                    update_post_meta($variation_id, '_sku', $variation_sku);
                }
            }

            $count++; // Increment SKU counter
        }
    }
    echo 'SKUs assigned successfully!';
} else {
    echo 'No parent products found.';
}
const url ='http://sample.example.file.doc'
const authHeader ="Bearer 6Q************" 

const options = {
  headers: {
    Authorization: authHeader
  }
};
 fetch(url, options)
  .then( res => res.blob() )
  .then( blob => {
    var file = window.URL.createObjectURL(blob);
    window.location.assign(file);
  });
 Software, that convert VDI files
The list contains a list of dedicated software for converting VDI and ISO files. The list may also include programs that support VDI files and allow you to save them with different file extensions.


VDI to ISO Converters
MagicISO
UltraIso
2 VDI to ISO converters
VDI and ISO conversions
From VDI
VDI to HDD
VDI to ASHDISC
VDI to OVA
VDI to RAW
VDI to VMDK
VDI to FLP
VDI to GI
VDI to ISO
VDI to PVM
VDI to PVM
VDI to VHD
VDI to BIN
VDI to HDS
To ISO
000 to ISO
ASHDISC to ISO
B5I to ISO
B5T to ISO
BIN to ISO
C2D to ISO
CCD to ISO
CDR to ISO
CUE to ISO
DAA to ISO
DAO to ISO
DMG to ISO
GCZ to ISO
IMG to ISO
ISZ to ISO
MDF to ISO
MDS to ISO
NRG to ISO
P01 to ISO
UIF to ISO
VCD to ISO
B6I to ISO
B6T to ISO
CDI to ISO
CSO to ISO
DEB to ISO
FCD to ISO
GBI to ISO
GCD to ISO
I00 to ISO
I01 to ISO
IMAGE to ISO
IMZ to ISO
WBFS to ISO
VHD to ISO
WIA to ISO
NCD to ISO
NDIF to ISO
PDI to ISO
SPARSEIMAGE to ISO
TAR to ISO
TAR.GZ to ISO
TOAST to ISO
UDF to ISO
UIBAK to ISO
B5L to ISO
CISO to ISO
ZIP to ISO
RAR to ISO
CIF to ISO
Full Name	Disc Image Format
Developer	N/A
Category	Disk Image Files

 Software, that convert VDI files
The list contains a list of dedicated software for converting VDI and ISO files. The list may also include programs that support VDI files and allow you to save them with different file extensions.


VDI to ISO Converters
MagicISO
UltraIso
2 VDI to ISO converters
VDI and ISO conversions
From VDI
VDI to HDD
VDI to ASHDISC
VDI to OVA
VDI to RAW
VDI to VMDK
VDI to FLP
VDI to GI
VDI to ISO
VDI to PVM
VDI to PVM
VDI to VHD
VDI to BIN
VDI to HDS
To ISO
000 to ISO
ASHDISC to ISO
B5I to ISO
B5T to ISO
BIN to ISO
C2D to ISO
CCD to ISO
CDR to ISO
CUE to ISO
DAA to ISO
DAO to ISO
DMG to ISO
GCZ to ISO
IMG to ISO
ISZ to ISO
MDF to ISO
#include <stdio.h>
#include <string.h>

int are_anagrams(char *str1, char *str2) {
    int len1 = strlen(str1);
    int len2 = strlen(str2);
    if (len1 != len2) {
        return 0;
    }
    int map[256] = {0};
    for (int i = 0; i < len1; i++) {
        map[str1[i]]++;
        map[str2[i]]--;
    }
    for (int i = 0; i < 256; i++) {
        if (map[i] != 0) {
            return 0;
        }
    }
    return 1;
}

int main() {
    char string1[] = "listen";
    char string2[] = "silent";
    printf("String1: %s\n", string1);
    printf("String2: %s\n", string2);
    printf("Are they anagrams? %s\n", are_anagrams(string1, string2) ? "Yes" : "No");
    return 0;
}

 public function store(Request $request)
    {
        $request->validate([
            'question' => ['required', 'string'],
            'answer' => ['required', 'string'],
        ]);

        $faq = FAQ::create([
            'question' => $request->question,
            'answer' => $request->answer,
        ]);

        return response()->json(new FAQResource($faq), 200);
    }
  /**
     * @OA\Post(
     * path="/admin/faqs",
     * description="Add new faq.",
     * tags={"Admin - FAQs"},
     * security={{"bearer_token": {} }},
     *   @OA\RequestBody(
     *       required=true,
     *       @OA\MediaType(
     *           mediaType="application/json",
     *           @OA\Schema(
     *              required={"question", "answer"},
     *                 @OA\Property(
     *                     property="question",
     *                     type="array",
     *                     @OA\Items(type="string"),
     *                     description="Array of question strings"
     *                 ),
     *                 @OA\Property(
     *                     property="answer",
     *                     type="array",
     *                     @OA\Items(type="string"),
     *                     description="Array of answer strings"
     *                 ),
     * 
     *          )
     *       )
     *   ),
     * @OA\Response(
     *    response=200,
     *    description="successful operation",
     *     ),
     *   @OA\Response(
     *     response=401,
     *     description="Unauthenticated",
     *  ),
     *   @OA\Response(
     *     response=422,
     *     description="The question field must be an array. | The answer field must be an array. | The question field is required. | The answer field is required.",
     *  )
     * )
     * )
     */

    // TODO ask MJ if he want arrays or just one pair question and answer
    public function store(Request $request)
    {
        $request->validate([
            'question' => ['required', 'array'],
            'question.*' => ['required', 'string'],
            'answer' => ['required', 'array'],
            'answer.*' => ['required', 'string'],
        ]);

        $questions = $request->input('question');
        $answers = $request->input('answer');

        $faqs = [];
        $count = min(count($questions), count($answers));
        for ($i = 0; $i < $count; $i++) {
            $faq = Faq::create([
                'question' => $questions[$i],
                'answer' => $answers[$i],
            ]);
            $faqs[] = new FAQResource($faq);
        }

        return response()->json(FAQResource::collection($faqs), 200);
    }
  public function index(Request $request)
    {
        $request->validate([
            'per_page' => ['integer', 'min:1'],
            'sort_by' => ['string', 'in:question,answer'],
            'sort_order' => ['string', 'in:asc,desc'],
        ]);

        $q = FAQ::query();

        if ($request->q) {
            $searchTerm = $request->q;
            $q->where('question', 'like', "%{$searchTerm}%")
                ->orWhere('answer', 'like', "%{$searchTerm}%");
        }

        $sortBy = $request->sort_by ?? 'question';
        $sortOrder = $request->sort_order ?? 'asc';

        $q->orderBy($sortBy, $sortOrder);

        $faqs = $q->paginate($request->per_page ?? 10);
        return FAQResource::collection($faqs);
    }
star

Mon May 06 2024 07:06:33 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon May 06 2024 05:24:31 GMT+0000 (Coordinated Universal Time)

@login123

star

Mon May 06 2024 05:21:45 GMT+0000 (Coordinated Universal Time)

@login123

star

Mon May 06 2024 05:20:31 GMT+0000 (Coordinated Universal Time)

@login123

star

Sun May 05 2024 21:54:54 GMT+0000 (Coordinated Universal Time)

@Rongrammer1995

star

Sun May 05 2024 19:59:35 GMT+0000 (Coordinated Universal Time) https://medium.com/@ephrahimadedamola/easy-way-to-debug-flutter-apps-wirelessly-with-android-devices-on-mac-27c6711efc35

@lewiseman

star

Sun May 05 2024 15:38:27 GMT+0000 (Coordinated Universal Time)

@iliavial #c#

star

Sun May 05 2024 12:44:33 GMT+0000 (Coordinated Universal Time)

@r0dri #bash

star

Sun May 05 2024 01:50:52 GMT+0000 (Coordinated Universal Time) https://sourcing.alibaba.com/rfq_detail.htm?spm

@sadjxt

star

Sat May 04 2024 22:56:30 GMT+0000 (Coordinated Universal Time) https://codepen.io/dudleystorey/pen/DJqNKP

@skatzy #undefined

star

Sat May 04 2024 22:56:23 GMT+0000 (Coordinated Universal Time) https://codepen.io/dudleystorey/pen/DJqNKP

@skatzy #undefined

star

Sat May 04 2024 20:03:00 GMT+0000 (Coordinated Universal Time)

@khalidbinshamim

star

Sat May 04 2024 19:53:59 GMT+0000 (Coordinated Universal Time)

@saloni_naik

star

Sat May 04 2024 19:42:49 GMT+0000 (Coordinated Universal Time)

@khalidbinshamim

star

Sat May 04 2024 19:35:48 GMT+0000 (Coordinated Universal Time)

@khalidbinshamim

star

Sat May 04 2024 17:45:59 GMT+0000 (Coordinated Universal Time)

@saloni_naik

star

Sat May 04 2024 17:18:40 GMT+0000 (Coordinated Universal Time) https://www.linkedin.com/pulse/how-use-lightning-datatable-web-component-kashish-bansal-tbese/

@saloni_naik

star

Sat May 04 2024 16:49:21 GMT+0000 (Coordinated Universal Time) https://alerta.io/

@al.thedigital

star

Sat May 04 2024 16:18:30 GMT+0000 (Coordinated Universal Time) https://www.drupal.org/project/augmentor

@al.thedigital #explicitcheck #manageaisystems #pluggable

star

Sat May 04 2024 16:15:49 GMT+0000 (Coordinated Universal Time) https://www.drupal.org/project/augmentor_google_cloud_vision

@al.thedigital #imgautocheck #imgtextcheck

star

Sat May 04 2024 16:08:25 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v

@ahmadou

star

Sat May 04 2024 16:07:37 GMT+0000 (Coordinated Universal Time) https://www.drupal.org/project/crowdsec

@al.thedigital #security #crowd

star

Sat May 04 2024 14:03:26 GMT+0000 (Coordinated Universal Time)

@saloni_naik

star

Sat May 04 2024 13:58:13 GMT+0000 (Coordinated Universal Time)

@saloni_naik

star

Sat May 04 2024 09:56:59 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat May 04 2024 09:47:23 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat May 04 2024 09:44:08 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat May 04 2024 09:27:59 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat May 04 2024 09:27:03 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat May 04 2024 09:26:23 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat May 04 2024 08:50:21 GMT+0000 (Coordinated Universal Time)

@signup

star

Sat May 04 2024 06:14:48 GMT+0000 (Coordinated Universal Time)

@cms

star

Sat May 04 2024 06:07:52 GMT+0000 (Coordinated Universal Time)

@cms

star

Sat May 04 2024 05:00:09 GMT+0000 (Coordinated Universal Time)

@cms

star

Sat May 04 2024 04:59:20 GMT+0000 (Coordinated Universal Time)

@cms

star

Sat May 04 2024 04:58:16 GMT+0000 (Coordinated Universal Time)

@cms

star

Sat May 04 2024 04:20:35 GMT+0000 (Coordinated Universal Time)

@signup

star

Fri May 03 2024 23:05:41 GMT+0000 (Coordinated Universal Time)

@azariel #glsl

star

Fri May 03 2024 18:15:39 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/32545632/how-can-i-download-a-file-using-window-fetch

@porobertdev #javascript #promise

star

Fri May 03 2024 17:04:01 GMT+0000 (Coordinated Universal Time) https://converter.tips/convert/vdi-to-iso

@j3d1n00b

star

Fri May 03 2024 17:03:18 GMT+0000 (Coordinated Universal Time) https://converter.tips/convert/vdi-to-iso

@j3d1n00b

star

Fri May 03 2024 11:03:32 GMT+0000 (Coordinated Universal Time)

@zeinrahmad99

star

Fri May 03 2024 10:55:45 GMT+0000 (Coordinated Universal Time)

@zeinrahmad99

star

Fri May 03 2024 10:43:25 GMT+0000 (Coordinated Universal Time)

@zeinrahmad99

star

Fri May 03 2024 09:53:33 GMT+0000 (Coordinated Universal Time)

@Sephjoe

Save snippets that work with our extensions

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