Snippets Collections
//delete node from starting in a doubly linked list
#include<stdio.h>
#include<stdlib.h>
struct node{
    struct node *prev;
    int data;
    struct node *next;
};

void main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->prev=NULL;
    head->data=45;
    head->next=NULL;

    struct node *current;
    current=malloc(sizeof(struct node));
    current->prev=head;
    head->next=current;
    current->data=98;
    current->next=NULL;
    
    struct node *node3;
    node3=malloc(sizeof(struct node));
    head->next->next=node3;
    node3->data=3;
    node3->next=NULL;
    node3->prev=current;



    //delete from starting in a doubly linked list
    struct node *temp;
    temp=head;
    int pos=3;
    pos--;
    while(pos != 1){
        temp=temp->next;
        pos--;
    }

    temp->prev=NULL;
    free(head);
    head=temp;
    temp=NULL; 

    struct node *ptr;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->next;
    }
}
//delete node from end of doubly linked list
#include<stdio.h>
#include<stdlib.h>
struct node{
    struct node *prev;
    int data;
    struct node *next;
};

void main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->prev=NULL;
    head->data=45;
    head->next=NULL;

    struct node *current;
    current=malloc(sizeof(struct node));
    current->prev=head;
    head->next=current;
    current->data=98;
    current->next=NULL;
    
    struct node *node3;
    node3=malloc(sizeof(struct node));
    head->next->next=node3;
    node3->data=3;
    node3->next=NULL;
    node3->prev=current;



    //delete node from end in a doubly linked list
    struct node *temp1,*temp2;
    temp1=head;
    temp2=head;

    int pos=3;
    pos--;
    while(pos != 1){
        temp1=temp1->next;
        pos--;
    }
    while(temp2->next != NULL){
        temp2=temp2->next;
    }

    temp1->next=NULL;
    temp2->prev=NULL;
    free(temp2);
    temp2=NULL;

    struct node *ptr;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->next;
    }
}
//insert node at specific position in doubly linked list
#include<stdio.h>
#include<stdlib.h>
struct node{
    struct node *prev;
    int data;
    struct node *next;
};

void main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->prev=NULL;
    head->data=45;
    head->next=NULL;

    struct node *current;
    current=malloc(sizeof(struct node));
    current->prev=head;
    head->next=current;
    current->data=98;
    current->next=NULL;
    
    struct node *node3;
    node3=malloc(sizeof(struct node));
    head->next->next=node3;
    node3->data=3;
    node3->next=NULL;
    node3->prev=current;



    //insert at specific position in doubly linked list
    struct node *newnode;
    newnode=malloc(sizeof(struct node));
    newnode->data=67;

    struct node *temp1,*temp2;
    temp1=head;
    temp2=head;

    while(temp1->next !=  NULL){
        temp1=temp1->next;
    }

    int pos=3;
    pos--;
    while(pos != 1){
        temp2=temp2->next;
        pos--;
    }

    temp2->next=newnode;
    newnode->prev=temp2;
    newnode->next=temp1;
    temp1->prev=newnode;

    struct node *ptr;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->next;
    }
}
//insert node at specific position in doubly linked list
#include<stdio.h>
#include<stdlib.h>
struct node{
    struct node *prev;
    int data;
    struct node *next;
};

void main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->prev=NULL;
    head->data=45;
    head->next=NULL;

    struct node *current;
    current=malloc(sizeof(struct node));
    current->prev=head;
    head->next=current;
    current->data=98;
    current->next=NULL;
    
    struct node *node3;
    node3=malloc(sizeof(struct node));
    head->next->next=node3;
    node3->data=3;
    node3->next=NULL;
    node3->prev=current;



    //insert at specific position in doubly linked list
    struct node *newnode;
    newnode=malloc(sizeof(struct node));
    newnode->data=67;

    struct node *temp1,*temp2;
    temp1=head;
    temp2=head;

    while(temp1->next !=  NULL){
        temp1=temp1->next;
    }

    int pos=3;
    pos--;
    while(pos != 1){
        temp2=temp2->next;
        pos--;
    }

    temp2->next=newnode;
    newnode->prev=temp2;
    newnode->next=temp1;
    temp1->prev=newnode;

    struct node *ptr;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->next;
    }
}
//adding node at the end of doubly linked list
#include<stdio.h>
#include<stdlib.h>
struct node{
    struct node *prev;
    int data;
    struct node *next;
};

void main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->prev=NULL;
    head->data=45;
    head->next=NULL;

    struct node *current;
    current=malloc(sizeof(struct node));
    current->prev=head;
    head->next=current;
    current->data=98;
    current->next=NULL;


    //adding node at end of a doubly linked list
    struct node *newnode;
    newnode=malloc(sizeof(struct node));
    newnode->data=3;
    newnode->prev=NULL;
    newnode->next=NULL;

    struct node *ptr;
    ptr=head;
    while(ptr->next != NULL){
        ptr=ptr->next;
    }

    ptr->next=newnode;
    newnode->prev=ptr;
  
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->next;
    }

}
//adding node at the beginning of a doubly linked list
#include<stdio.h>
#include<stdlib.h>
struct node{
    struct node *prev;
    int data;
    struct node *next;
};

void main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->prev=NULL;
    head->data=45;
    head->next=NULL;

    struct node *current;
    current=malloc(sizeof(struct node));
    current->prev=head;
    head->next=current;
    current->data=98;
    current->next=NULL;
    
    struct node *node3;
    node3=malloc(sizeof(struct node));
    head->next->next=node3;
    node3->data=3;
    node3->next=NULL;
    node3->prev=current;

    //adding node at beginning of doubly linked list
    //newnode
    struct node *newnode;
    newnode=malloc(sizeof(struct node));
    newnode->data=67;
    head->prev=newnode;
    newnode->next=head;
    head=newnode;
    newnode=NULL;

    struct node *ptr;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->next;
    }

}
//single linked list searching of an element
#include<stdio.h>
#include<stdlib.h>
struct node{
    int data;
    struct node *next;
};

void main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->data=45;
    head->next=NULL;

    struct node *node2;
    node2=malloc(sizeof(struct node));
    node2->data=98;
    node2->next=NULL;
    head->next=node2;

    node2=malloc(sizeof(struct node));
    node2->data=3;
    node2->next=NULL;
    head->next->next=node2;


    //search element in a single linked list
    struct node *ptr;
    ptr=head;
    int target=3;
    int count=1;
    while(ptr->data != target){
        ptr=ptr->next;
        count++;
    }
    printf("%d",count);
    
}
#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node *link;
};

void main(){
    struct node *head=NULL;
    head=malloc(sizeof(struct node));
    head->data=45;
    head->link=NULL;

    struct node *current=NULL;
    current=malloc(sizeof(struct node));
    current->data=98;
    current->link=NULL;
    head->link=current;

    current=malloc(sizeof(struct node));
    current->data=3;
    current->link=NULL;
    head->link->link=current;

    current=malloc(sizeof(struct node));
    current->data=67;
    current->link=NULL;
    head->link->link->link=current;

    struct  node *ptr;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->link;
    }

    printf("\n");



//delete at specific position in a single linked list
/* LOGIC: using first pointer traverse till last node stop when first pointer points to last node
using second pointer traverse till the node to be deleted
using third pointer traverse till second node
update third pointer's link with third pointer value to join last node with second node 
and to cut link with third node
update second pointer's link to NULL in order to cut third node's link with last node
free second pointer to delete third node 
and update it with NULL so that it donot randomly point to anyone  */

    struct node *nextnode;
    nextnode=head;
    while(nextnode->link != NULL){
        nextnode=nextnode->link;
    }

    struct node *delnode;
    delnode=head;
    while(delnode->link->link != NULL){
        delnode=delnode->link;
    }

    struct node *prevnode;
    prevnode=head;
    while(prevnode->link->link->link != NULL){
        prevnode=prevnode->link;
    }

    prevnode->link=nextnode;
    delnode->link=NULL;
    free(delnode);
    delnode=NULL;

    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->link;
    }

}
#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node *link;
};

void main(){
    struct node *head=NULL;
    head=malloc(sizeof(struct node));
    head->data=45;
    head->link=NULL;

    struct node *current=NULL;
    current=malloc(sizeof(struct node));
    current->data=98;
    current->link=NULL;
    head->link=current;

    current=malloc(sizeof(struct node));
    current->data=3;
    current->link=NULL;
    head->link->link=current;

    current=malloc(sizeof(struct node));
    current->data=67;
    current->link=NULL;
    head->link->link->link=current;

    struct  node *ptr;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->link;
    }

    printf("\n");


    //delete node from end in a single linked list
    /* LOGIC : using first pointer traverse till it points to last node 
    and then use second pointer to traverse till second last node 
    put NULL in link of second last node to make it end and to break link with last node
    then free first pointer who was still pointing to last node to delete last node permanently
    then set the next of first pointer to NULL so that it will not point to any thing. */

    struct node *lastnode;
    lastnode=head;
    while(lastnode->link != NULL){
        lastnode=lastnode->link;
    }

    struct node *secondlastnode;
    secondlastnode=head;
    while(secondlastnode->link->link != NULL){
        secondlastnode=secondlastnode->link;
    }

    secondlastnode->link=NULL;
    free(lastnode);
    lastnode=NULL;

    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->link;
    }

}
//delete first node of linked list
#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node *link;
};

void main(){
    struct node *head=NULL;
    head=malloc(sizeof(struct node));
    head->data=45;
    head->link=NULL;

    struct node *current=NULL;
    current=malloc(sizeof(struct node));
    current->data=98;
    current->link=NULL;
    head->link=current;

    current=malloc(sizeof(struct node));
    current->data=3;
    current->link=NULL;
    head->link->link=current;

    //delete first node in single linked list
    struct node *temp;
    temp=head;   //temp is pointing to first node in order to free it later
    head=head->link;  //head is pointing to second node
    free(temp);     //deleting the first node
    temp=NULL;

    struct  node *ptr=NULL;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->link;
    }
}
//adding node at specific position in singly linked list 
//using another function
#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node *link;
};

void ins_at_beg(struct node *head,struct node *temp,int pos){
    struct node *ptr;
    ptr=head;
    pos--;
    while(pos != 1){
        ptr=ptr->link;
        pos--;
    }

    temp->link=ptr->link;
    ptr->link=temp;

    ptr=head;
    while(ptr !=NULL) {
        printf( "%d ", ptr->data);
        ptr = ptr->link;
    }
}
int main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->data=45;
    head->link=NULL;

    struct node *temp;
    temp=malloc(sizeof(struct node));
    temp->data=98;
    temp->link=NULL;
    head->link=temp;

    temp=malloc(sizeof(struct node));
    temp->data=3;
    temp->link=NULL;
    head->link->link=temp;


    temp=malloc(sizeof(struct node));
    temp->data=67;
    temp->link=NULL;
    int pos;
    printf("Enter the position: ");
    scanf("%d",&pos);
    ins_at_beg(head,temp,pos);

    return 0;
}
//adding node at specific position in singly linked list
#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node *link;
};

int main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->data=45;

    struct node *temp;
    temp=malloc(sizeof(struct node));
    temp->data=98;
    head->link=temp;

    temp=malloc(sizeof(struct node));
    temp->data=3;
    temp->link=NULL;
    head->link->link=temp;

    //new node to be inserted at specific 
    struct node  *newnode;
    newnode=malloc(sizeof(struct node));
    newnode->data=67;
    newnode->link=NULL;

   /*  logic : first we have to join new node with next node 
    and then join previous node with new node .
    otherwise,
    if we first join previous node with new node we will loose the address of next node*/

    struct node *ptr;
    ptr=head;
    int pos=2;
    pos--;
    while(pos != 1){
        ptr=ptr->link;
        pos--;
    }

    newnode->link=ptr->link;
    ptr->link=newnode;

    ptr=head;
    while(ptr !=NULL) {
        printf( "%d ", ptr->data);
        ptr = ptr->link;
    }

    return 0;
}
//adding node at end in single linked list
#include<stdio.h>
#include<stdlib.h>

struct node {
    int data;
    struct node *link;
};

int main() {
    struct node *head = NULL;
    head = malloc(sizeof(struct node));
    head->data = 45;
    head->link = NULL;

    struct node *temp = NULL;
    temp = malloc(sizeof(struct node));
    temp->data = 98;
    temp->link = NULL;
    head->link = temp;

    struct node *ptr = NULL;

    temp = malloc(sizeof(struct node));
    temp->data = 3;
    temp->link = NULL;

    ptr = head;
    while (ptr->link != NULL) {
        ptr = ptr->link;
    }
    ptr->link = temp;    //adding node at last

    ptr = head; // Resetting ptr to head before traversing again
    while (ptr != NULL) {
        printf("%d ", ptr->data);
        ptr = ptr->link;
    }
    return 0;
}
//adding node at beginning in single linked list
#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node *link;
};

int main(){
    struct node *head;
    head=malloc(sizeof(struct node));
    head->data=45;
    head->link=NULL;

    struct node *temp;
    temp=malloc(sizeof(struct node));
    temp->data=98;
    temp->link=NULL;
    head->link=temp;

    temp=malloc(sizeof(struct node));
    temp->data=3;
    temp->link=NULL;
    head->link->link=temp;

    struct node *newnode;
    newnode=malloc(sizeof(struct node));
    newnode->data=67;
    newnode->link=head;

    head=newnode;
    struct node *ptr;
    ptr=head;
    while(ptr != NULL){
        printf("%d ",ptr->data);
        ptr=ptr->link;
    }
    return 0;
}
 // HTML

 <div className='container' data-columns="4">
          <div className="container__block container__block--image1"></div>
          <div className="container__block container__block--image2"></div>
          <div className="container__block container__block--image3"></div>
          <div className="container__block"></div>
      </div>




// CSS

.container{
  width: 1200px;
  height: 600px;
  margin: auto auto;
   background-color: red;
   display: grid;
  //replace the value we want to make dynamic with a var(--something, x) where x is a fallback if --something doesnt exist
  grid-template-columns: repeat(var(--column-count, 4), 1fr); 
  place-content: center;
   align-items: center;
   justify-content: center;
   justify-items: center;

   // use data attribute vales on the html to change the variable --something
   &[data-columns="2"]{
      --column-count: 2;
   }

   &[data-columns="3"]{
    --column-count: 3;
    }

    &[data-columns="4"]{
      --column-count: 4;
    }



   &__block{
    width: 200px;
    height: 200px;
    background-color: rebeccapurple;
    border: 1px solid white;
    background-size: cover;
    background-repeat: no-repeat;
    background-image: var(--selected-url);

        &--image1{
          --selected-url: url('https://source.unsplash.com/user/c_v_r')
        }

        &--image2{
          --selected-url: url('https://www.kimballstock.com/images/car-stock-photos.jpg')
        }

        &--image3{
          --selected-url: url('https://media.gettyimages.com/id/1636857191/photo/topshot-moto-prix-esp-catalunya-practice.jpg?s=2048x2048&w=gi&k=20&c=bt3AqEevYACDxkxf5Rom1MqE4bjHrMG2apxxTkmedJ8=')
        }


   }
 }
https://source.unsplash.com/user/c_v_r
//This pulls out the two functions we need from the db connection file.
const { connectToDatabase, getDb } = require('./db');

// Middleware to connect to the database to see if it is working. If working it assigns the DB connection to a variable.
app.use(async (req, res, next) => {
  await connectToDatabase(); 
  next();
}); 


app.get("/", async (req, res) => {
  //Call our database function to get the variable holding our database connection.
  const db = getDb();
  const collection = db.collection("projects");

  const documents = await collection.find({}).toArray(); 
  res.render("pages/homepage");
});
#To add the URL fro the remote repository
git remote add origin REMOTE-URL

#to verify remote URL
git remote -v

echo "# ml_flow_test" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/carlosribadeneira-se/ml_flow_test.git
git push -u origin main
git merge main

#To add the URL fro the remote repository
git remote add origin REMOTE-URL

#to verify remote URL
git remote -v

PS C:\WINDOWS\system32> reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowAllTrustedApps" /d "1"
//Import Routes 
const indexRoute = require('./routes/index');
const aboutRoute = require('./routes/about');
const pricingRoute = require('./routes/pricing');
const contactRoute = require('./routes/contact');

app.use(indexRoute);
app.use(aboutRoute);
app.use(pricingRoute);
app.use(contactRoute);
const express = require('express');
const aboutController = require('../controller/about');

const router = express.Router();

router.get('/about', aboutController.getAbout);


module.exports = router;
SÁBADO
30/3/2024
// import React from 'react'
import * as React from "react";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import Typography from "@mui/material/Typography";
import Modal from "@mui/material/Modal";
import { useState, useEffect } from "react";
import axios from "axios";


const style = {
  position: "absolute",
  top: "50%",
  left: "50%",
  transform: "translate(-50%, -50%)",
  width: 400,
  bgcolor: "background.paper",
  border: "2px solid #000",
  boxShadow: 24,
  p: 4,
};




function Show() {
const [userData, setUserData] = useState([]);


const runfun = async (id) =>{

console.log(id);


let a = id;

  try {
    const result = await axios.post(http://192.168.0.146:5000/get-single-data/${a});
    setUserData(result.data…Read more
8:45 p. m.
app.post('/get-single-data/:id', (req, res) => {
    // const id = 2225;
    const { id } = req.params;

    console.log(id);

    const query = 'SELECT * FROM app_deperment_section WHERE id = ? ';
    connection.query(query, [id], (err, results) => {
        if (err) {
            console.error(err.message);
            return res.status(500).send(err);
        }
        res.json(results);
        console.log(results)
    });
});
8:46 p. m.
1/4/2024
metoxi-bootstrap-5-admin-dashboard-template-2023-12-06-06-35-20-utc.zip
ZIP•113 MB
6:14 p. m.
VIERNES
in bootstrap if i click then run a function and close this model in react
3:02 p. m.
+918767170191
9:52 p. m.
+918767170191
9:53 p. m.
+918767170191
10:04 p. m.
SÁBADO

10:06 a. m.
TODAY
import React from "react";
import Master from "../Layout/Master";

import { Link } from "react-router-dom";

import { useState, useEffect } from "react";
import axios from "axios";

import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";

import Loding from "../Loding/Loding";

import { server } from "..//../main";

import { confirmAlert } from "react-confirm-alert"; // Import
import "react-confirm-alert/src/react-confirm-alert.css"; // Import css

function Client() {
  // !hook for model update
  const [modalOpen, setModalOpen] = useState(false);
  // !hook for model create Button
  const [create_modalOpen, setCreate_modalOpen] = useState(false);

  const [userData, setUserData] = useState([]);
  // const [selectedUserId, setSelectedUserId] = useState(null);

  // ! loading hook
  const [isLoading, setIsLoading] = useState(true);

  const sessionStorage_user_id = sessionStorage.getItem("user_id");

  const [userField, setUserField] = useState({
    user_name: "",
    user_m_no: "",
    user_w_name: "",
    user_e_nid: "",
    user_a: "",
    user_u_id: "sessionStorage_user_id",
  });

  const changeUserFieldHandler = (e) => {
    setUserField({
      ...userField,
      [e.target.name]: e.target.value,
    });
  };

  // ! --------------------------------------------------
  // Function to open the modal
  const handleCreateButtonOpen = () => {
    console.log("handleCreateButtonOpen");
    setCreate_modalOpen(true);
  };

  // Function to close the modal
  const handleCreateButtonClose = () => {
    setCreate_modalOpen(false);
  };
  // ! --------------------------------------------------
  const onSubmitChange = async (e) => {
    e.preventDefault();
    try {
      const response = await axios.post(
        ${server}/api_v2/clients/cleint_add,
        userField
      );

      var response_data = response.data.msg;
      var response_status = response.data.status;
      if (response_status == "success") {
        fetchData();
        toast.success(response_data);
        // console.log(response_data);
        // toast.success(response_data);
        // Close the modal on success
        setCreate_modalOpen(false);
      } else {
        setCreate_modalOpen(true);
        // toast.success(response_data);
        toast.error(response_data);
        // console.log(response.data);
      }
    } catch (err) {
      console.log("Something Wrong in react ");
      toast.error(response_data);
    }
  };

  const handleDelete = async (id) => {
    // console.log(id)


    try {
      const result = await axios.post(
        "http://192.168.0.109/rpgi/craftzoneapi/api_v2/clients/delete_cleint",
        {
          client_id: id,
          tc_auth_id: sessionStorage_user_id,
        }
        // console.log(result.data.msg);
      );

      if (result.data.msg == "success") {
        toast.success(result.data.msg);
        // fetchData();
      } else {
        toast.error(result.data.msg);
      }

           fetchData();
    } catch (error) {
      // console.log(error);
      toast.error("Internal Server Error");
    }





  };

  // ! -----------------------Get data---------------------------
  const fetchData = async () => {
    //
    try {
      const result = await axios.post(
        "http://192.168.0.109/rpgi/craftzoneapi/api_v2/clients/get_cleints"
      );
      //console.log("FEATCH");

      // console.log(result);

      if (result.data.status === "success") {
        console.log("first")
        setUserData(result.data.clients);
        console.log("FEATCH");



      } else {
        toast.error(result.data.msg);
      }
    } catch (err) {
      console.log("Something went wrong");
    }
  };

  // ! -----------------------Delete data---------------------------

  const deleteData = async (id) => {
    // console.log(id);
    fetchData();
    confirmAlert({
      title: "Confirm to Delete",
      message: "Are you sure to do this.",
      buttons: [
        {
          label: "Yes",
          onClick: () => handleDelete(id),
          
          // alert("Click Yes"),
        },
        {
          label: "No",
          // onClick: () =>

          // alert("Click No"),
        },
      ],
    });
  };

  useEffect(() => {
    fetchData();
  }, []);

  // ! -----------------------show single data data---------------------------

  // const [single_cleint_data, setSingle_cleint_data] = useState({});

  // ! -----------------------Update data---------------------------

  // const [data, setData] = useState([]);
  const [selectedData, setSelectedData] = useState(null);

  const handleCloseModal = () => {
    setModalOpen(false);
  };

  const fetchDataFromServer = async (id) => {
    try {
      const response = await axios.post(
        http://192.168.0.109/rpgi/craftzoneapi/api_v2/clients/get_cleint,
        {
          user_id: id,
        }
      );
      //  console.log(update);
      return response.data;
    } catch (error) {
      toast.error("Internal Server Error");
    }
  };

  const handleEditClick = async (id) => {
    try {
      const newData = await fetchDataFromServer(id);

      if (newData.status == "success") {
        setSelectedData(newData.client[0]);
        setModalOpen(true);
      } else {
        toast.error(newData.msg);
      }
    } catch (error) {
      toast.error("Internal Server Error");
    }
  };

  const handleUpdateData = async () => {
    // Perform actions to update the data
    console.log("Updated data:", selectedData);

    try {
      const users = {
        user_id: selectedData.tc_id,
        user_name: selectedData.tc_name,

        user_m_no: selectedData.tc_m_no,
        user_w_name: selectedData.tc_w_no,
        user_e_nid: selectedData.tc_e_id,
        user_a: selectedData.tc_address,
        user_u_id: sessionStorage_user_id,
      };
      const result = await axios.post(
        "http://192.168.0.109/rpgi/craftzoneapi/api_v2/clients/update_cleint",
        users
      );
      if (result.data.status == "success") {
        // alert("User Data Updated Successfully");
        toast.success(result.data.msg);
        setModalOpen(false);
        fetchData();
      } else {
        toast.error(result.data.msg);
      }
      // Close the modal
    } catch (err) {
      toast.error("Internal Server Error");
    }
  };

  setTimeout(() => {
    // setIsLoading(false);
  }, 2000);

  return (
    <>
      <Master />

      {/* //! update modal */}
      <>
        <div
          className={modal ${modalOpen ? "show" : ""}}
          tabIndex="-1"
          role="dialog"
          style={{ display: modalOpen ? "block" : "none" }}
        >
          <div className="modal-dialog" role="document">
            <div className="modal-content">
              <div className="modal-header">
                <h5 className="modal-title">Edit Data</h5>
                <button
                  type="button"
                  className="close"
                  onClick={handleCloseModal}
                >
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div className="modal-body">
                {selectedData && (
                  <form onSubmit={handleUpdateData}>
                    <div className="form-group">
                      <label htmlFor="name">Name:</label>
                      <input
                        type="text"
                        className="form-control"
                        id="name"
                        name="name"
                        value={selectedData.tc_name}
                        onChange={(e) =>
                          setSelectedData({
                            ...selectedData,
                            tc_name: e.target.value,
                          })
                        }
                      />
                    </div>
                    <div className="form-group">
                      <label htmlFor="name">Mobile Number:</label>
                      <input
                        type="text"
                        className="form-control"
                        id="name"
                        name="name"
                        value={selectedData.tc_m_no}
                        onChange={(e) =>
                          setSelectedData({
                            ...selectedData,
                            tc_m_no: e.target.value,
                          })
                        }
                      />
                    </div>
                    <div className="form-group">
                      <label htmlFor="name">Whatsapp Number:</label>
                      <input
                        type="text"
                        className="form-control"
                        id="name"
                        name="name"
                        value={selectedData.tc_w_no}
                        onChange={(e) =>
                          setSelectedData({
                            ...selectedData,
                            tc_w_no: e.target.value,
                          })
                        }
                      />
                    </div>
                    <div className="form-group">
                      <label htmlFor="name">Email:</label>
                      <input
                        type="text"
                        className="form-control"
                        id="name"
                        name="name"
                        value={selectedData.tc_e_id}
                        onChange={(e) =>
                          setSelectedData({
                            ...selectedData,
                            tc_e_id: e.target.value,
                          })
                        }
                      />
                    </div>
                    <div className="form-group">
                      <label htmlFor="name">Address:</label>
                      <input
                        type="text"
                        className="form-control"
                        id="name"
                        name="name"
                        value={selectedData.tc_address}
                        onChange={(e) =>
                          setSelectedData({
                            ...selectedData,
                            tc_address: e.target.value,
                          })
                        }
                      />
                    </div>
                  </form>
                )}
              </div>
              <div className="modal-footer">
                <button
                  type="button"
                  className="btn btn-secondary"
                  onClick={handleCloseModal}
                >
                  Close
                </button>
                <button
                  type="button"
                  className="btn btn-primary"
                  onClick={handleUpdateData}
                >
                  Update
                </button>
              </div>
            </div>
          </div>
        </div>

        {/* Modal backdrop */}
        <div
          className={modal-backdrop ${modalOpen ? "show" : ""}}
          style={{ display: modalOpen ? "block" : "none" }}
        ></div>
      </>

      {/*  */}
      {/* //! */}

      <div id="main-content">
        <div className="row clearfix">
          <div className="col-lg-12 col-md-12">
            <div className="card planned_task">
              {/*  */}
              <div className="container-fluid">
                <div className="block-header">
                  <div className="row clearfix">
                    <div className="col-md-6 col-sm-12">
                      <h1>Clients</h1>
                      <nav aria-label="breadcrumb">
                        <ol className="breadcrumb">
                          <li className="breadcrumb-item">
                            <Link to="/dashboard">
                              <i className="icon-home"> </i>
                            </Link>
                          </li>
                          <li className="breadcrumb-item">Dashboard</li>
                          <li className="breadcrumb-item active">Clients</li>
                        </ol>
                      </nav>
                    </div>

                    {/* //! Create Clients model  button  */}

                    <div
                      className="col-md-6 col-sm-12 text-right hidden-xs"
                      // onClick={handleCreateButtonOpen}
                    >
                      <div className="d-flex flex-row-reverse">
                        <button
                          onClick={handleCreateButtonOpen}
                          className="btn btn-success ml-1 mr-1"
                          data-toggle="modal"
                          // data-target=".bd-example-modal-lg"
                        >
                          <i className="icon-plus"></i> Create Clients
                        </button>
                        {/* //! Create Clients  model */}

                        {/*  */}
                        {/* //! Edit user model */}

                        {/*  */}
                      </div>
                    </div>

                    {/*  !------------------------------ */}
                  </div>
                </div>

                <>
                  <div
                    className={modal ${create_modalOpen ? "show" : ""}}
                    tabIndex="-1"
                    role="dialog"
                    style={{
                      display: create_modalOpen ? "block" : "none",
                    }}
                  >
                    <div className="modal-dialog modal-lg">
                      <div className="modal-content">
                        <div className="modal-header">
                          <h5 className="modal-title h4" id="myLargeModalLabel">
                            New Client
                          </h5>
                          <button
                            type="button"
                            className="close"
                            // data-dismiss="modal"
                            // aria-label="Close"
                            onClick={handleCreateButtonClose}
                          >
                            <span aria-hidden="true">×</span>
                          </button>
                        </div>
                        <div className="modal-body">
                          {/*  */}

                          <form onSubmit={onSubmitChange}>
                            <div className="form-group">
                              <label
                                for="exampleInputEmail1"
                                className="d-flex"
                              >
                                Client Name
                              </label>
                              <input
                                type="text"
                                className="form-control"
                                id="exampleInputEmail1"
                                aria-describedby="emailHelp"
                                placeholder="Client Name"
                                name="user_name"
                                onChange={(e) => changeUserFieldHandler(e)}
                                required
                              />
                            </div>
                            <div className="form-group">
                              <label
                                for="exampleInputPassword1"
                                className="d-flex"
                              >
                                Phone Number
                              </label>
                              <input
                                type="tel"
                                // pattern="[0-9]{10}"
                                min={10}
                                maxLength={10}
                                className="form-control"
                                // id="exampleInputPassword1"
                                placeholder=" Client Number"
                                name="user_m_no"
                                onChange={(e) => changeUserFieldHandler(e)}
                                required
                              />
                            </div>

                            {/*  */}
                            <div className="form-group">
                              <label
                                for="exampleInputPassword1"
                                className="d-flex"
                              >
                                WhatsApp Number
                              </label>
                              <input
                                type="tel"
                                // pattern="[0-9]{10}"
                                min={10}
                                maxLength={10}
                                className="form-control"
                                // id="exampleInputPassword1"
                                placeholder=" Client Number"
                                name="user_w_name"
                                onChange={(e) => changeUserFieldHandler(e)}
                                required
                              />
                            </div>
                            {/*  */}
                            <div className="form-group">
                              <label
                                for="exampleInputPassword1"
                                className="d-flex"
                              >
                                Email
                              </label>
                              <input
                                type="email"
                                className="form-control"
                                id="exampleInputPassword1"
                                placeholder=" Client Email"
                                name="user_e_nid"
                                onChange={(e) => changeUserFieldHandler(e)}
                                required
                              />
                            </div>
                            {/*  */}

                            <div className="form-group">
                              <label
                                for="exampleInputPassword1"
                                className="d-flex"
                              >
                                Client Address
                              </label>
                              <input
                                type="text"
                                className="form-control"
                                id="exampleInputPassword1"
                                placeholder=" Client Address"
                                name="user_a"
                                onChange={(e) => changeUserFieldHandler(e)}
                                required
                              />
                            </div>
                            {/*  */}
                            <div className="modal-footer">
                              <button
                                type="submit"
                                className="btn btn-primary pl-5
                                      pr-5
                                      pt-2
                                      pb-2"
                                onClick={handleCreateButtonClose}
                              >
                                Add
                              </button>
                            </div>
                          </form>

                          {/*  */}
                        </div>
                      </div>
                    </div>
                  </div>

                  <div
                    className={`modal-backdrop ${
                      create_modalOpen ? "show" : ""
                    }`}
                    style={{
                      display: create_modalOpen ? "block" : "none",
                    }}
                  ></div>
                </>

                {/*  */}
                <div className="table-responsive">
                  <table className="table table-striped">
                    <thead>
                      <tr>
                        <th>Id</th>
                        <th>NAME</th>
                        <th>Mobile Number</th>
                        <th>Whatsapp Number</th>
                        <th>Email</th>
                        <th>Address</th>
                        <th>Action</th>
                        <td></td>
                      </tr>
                    </thead>
                    <tbody>
                      {userData.length > 0 ? (
                        userData.map((item, i) => (
                          <tr key={i}>
                            <td>{item.tc_id}</td>
                            <td>{item.tc_name}</td>
                            <td>{item.tc_m_no}</td>
                            <td>{item.tc_w_no}</td>
                            <td>{item.tc_e_id}</td>
                            <th>{item.tc_address}</th>
                            <td>
                              <button
                                data-toggle="modal"
                                data-target=".bd-example-modal-lg2"
                                className="btn btn-success ml-1 mr-1"
                                data-backdrop="static"
                                data-keyboard="false"
                                onClick={() => handleEditClick(item.tc_id)}
                              >
                                Edit
                              </button>
                            </td>
                            <td>
                              <button
                                className="btn btn-danger btn-round ml-1 mr-1"
                                onClick={() => deleteData(item.tc_id)}
                              >
                                Delete
                              </button>
                            </td>
                          </tr>
                        ))
                      ) : (
                        <>
                          <tr>
                            <td colSpan={8} className="text-center">
                              No data available
                            </td>
                          </tr>
                        </>
                      )}
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>

        <ToastContainer
          position="top-right"
          autoClose={5000}
          hideProgressBar={false}
          newestOnTop={false}
          closeOnClick
          rtl={false}
          pauseOnFocusLoss
          draggable
          pauseOnHover
          theme="colored"
          // transition: Bounce,
        />
      </div>
    </>
  );
}

export default Client
const getData = require('../js/utility/getData');

module.exports = class Data {

  static getPartnerData() {
    return getData.getFileData().partners;
  }

  static getServicesData() {
    return getData.getFileData().services;
  }

  static getPricingData() {
    return getData.getFileData().prices;
  }

  static getFeatures() {
    return getData.getFileData().features;
  }

  static getValues() {
    return getData.getFileData().values;
  }

  static getStats() {
    return getData.getFileData().stats;
  }
}
const data = require('../models/data');

exports.getAbout = (req, res) => {

  let values = data.getValues();
  let stats = data.getStats();
  let firstArr = values.slice(0,2);
  let secondArr = values.slice(2,4);

  res.render('pages/about', 
    {
      firstArr,
      stats,
      secondArr
    }
  )
}
import StoreKit

//inside viewController
let productId = "your_product_id"


//Action where you want to trigger the purchase
@IBAction func btn_OneTimeButtonClicked(_ sender: UIButton) {
	if SKPaymentQueue.canMakePayments(){
		let paymentRequest = SKMutablePayment()
		paymentRequest.productIdentifier = productId
		SKPaymentQueue.default().add(paymentRequest)
	}
}

//extension to handle the transaction states

extension your_View_Controller: SKPaymentTransactionObserver{
    func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
        transactions.forEach { transaction in
            switch transaction.transactionState{
            case .purchasing:
                print("purchasing now ...")
            case .purchased:
                print("purchase successful !!!")
            case .failed:
                print("purchase failed !!!")
            case .restored:
                print("purchase restored !!!")
            case .deferred:
                print("purchase deferred !!!")
            @unknown default:
                print("Unknown error")
            }
        }
    }
}

// don't forgot to add storekit configuration file in your app if you are testing your app in simulator

with Produce AS (
  SELECT 'Kale' as product, 'good' as sales, 'Q1' as quarter UNION ALL
  SELECT 'Kale', 'bad', 'Q2' UNION ALL
  SELECT 'Kale', 'good', 'Q3' UNION ALL
  SELECT 'Kale', 'bad', 'Q4' UNION ALL
  SELECT 'Apple', 'bad', 'Q1' UNION ALL
  SELECT 'Apple', 'good', 'Q2' UNION ALL
  SELECT 'Apple', 'bad', 'Q3' UNION ALL
  SELECT 'Apple', 'good', 'Q4')
SELECT * FROM
  (SELECT product, sales, quarter FROM Produce)
  PIVOT(MAX(sales) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'))
WITH cte AS (
    SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) rn
    FROM (SELECT attribute AS attr1, value AS val1 FROM temp WHERE attribute = 'height') t1
    CROSS JOIN (SELECT attribute AS attr2, value AS val2 FROM temp WHERE attribute = 'weight') t2
    CROSS JOIN (SELECT attribute AS attr3, value AS val3 FROM temp WHERE attribute = 'gender') t3
)

SELECT rn AS Combination, attr1 AS Attribute, val1 AS Value FROM cte WHERE attr1 = 'height' UNION ALL
SELECT rn, attr2, val2 FROM cte WHERE attr2 = 'weight' UNION ALL
SELECT rn, attr3, val3 FROM cte WHERE attr3 = 'gender'
ORDER BY Combination, Attribute, Value;
SELECT
   CCY1, CCY2, CER.Exchange_Rate
FROM
    ( 
    SELECT
        c1.rec_id AS rec_id1, c1.currency AS CCY1,
        c2.rec_id AS rec_id2, c2.currency AS CCY2
    FROM
        currency c1
        CROSS JOIN --all combinations...
        currency c2
    WHERE
        c1.rec_id <> c2rec_id -- ...removes same pairs
    ) foo
    LEFT JOIN -- ...get matching FX pairs
    CurrencyExchangeRate CER ON foo.rec_id1 = cer.[from] AND foo.rec_id2 = cer.[to]
SELECT 
  c1.currency AS [From], c2.currency AS [To] , cer.Exchange_Rate
FROM
  currency c1 JOIN currency c2 ON c1.rec_id <> c2.rec_id
  LEFT OUTER JOIN CurrencyExchangeRate cer ON c1.rec_id = cer.[from] 
         AND c2.rec_id = cer.[to]
def factorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n * factorial(n-1)
npm create vite@latest name-of-your-project -- --template react
# follow prompts
cd <your new project directory>
npm install react-router-dom localforage match-sorter sort-by
npm run dev
import * as React from "react";

import * as ReactDOM from "react-dom/client";

import {

  createBrowserRouter,

  RouterProvider,

} from "react-router-dom";

import "./index.css";



const router = createBrowserRouter([

  {

    path: "/",

    element: <div>Hello world!</div>,

  },

]);



ReactDOM.createRoot(document.getElementById("root")).render(

  <React.StrictMode>

    <RouterProvider router={router} />

  </React.StrictMode>

);
//Inside a plugins folder

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.directive("click-outside", {
    beforeMount(el, binding) {
      el.clickOutsideEvent = function (event) {
        if (!(el === event.target || el.contains(event.target))) {
          binding.value(event, el);
        }
      };
      document.addEventListener("click", el.clickOutsideEvent);
    },
    unmounted(el) {
      document.removeEventListener("click", el.clickOutsideEvent);
    },
  });
});

//Inside the DOM
v-click-outside="handleCloseDestinationSearchResults"
OA1586918418	22B81A05R7	ABHI	AAGANTHAM
OA1586918419	22B81A05R8	ABHINAV	DANTHALA
OA1586918420	22B81A05R9	ABHINAY	ALLAM
OA1586918421	22B81A05S0	ABHISHEK	ALLI
OA1586918422	22B81A05S1	AKHILESH	CHIKATLA
OA1586918423	22B81A05S2	AKSHITHA	ELMELA
OA1586918424	22B81A05S3	AKSHITHA	MAMIDI
OA1586918425	22B81A05S4	ALEKHYA	KADEMAMI
OA1586918426	22B81A05S5	ALOK	GUNDE
OA1586918427	22B81A05S6	BARATHCHANDRA	PONUGOTI
OA1586918454	22B81A05S7	RANKAWAT	CHETHNA
OA1586918455	22B81A05S8	DEVENDHAR SAI	POLISHETTI
OA1586918475	22B81A05S9	DINESH REDDY	PISATI
OA1586918476	22B81A05T0	ESHA	THALLAPUREDDY
OA1586918477	22B81A05T1	GAYATHRI	GARINE
OA1586918504	22B81A05T2	GUNASAI SUDHEERTHI	BANGARU
OA1586918505	22B81A05T3	HARDHIK	RACHURI
OA1586918532	22B81A05T4	HARI	NARAPONGU
OA1586918533	22B81A05T5	GARI HARSHITH RAO	KAULAMMA
OA1586918534	22B81A05T6	CHERUKURI	HASHITHA
OA1586918535	22B81A05T7	JAIDEEP	KURNI
OA1586918536	22B81A05T8	KUMARA SATYA SAI	CHINNALA
OA1586918537	22B81A05T9	LAKSHMI MEGHANA	ARASADA
OA1586918538	22B81A05U0	MAHESH KUMAR	MUTHYALA
OA1586918539	22B81A05U1	NAREN	GOWRU
OA1586918540	22B81A05U2	NEHAL SOHEL	MOHAMMAD
OA1586918541	22B81A05U3	PRANEETH REDDY	BOOTHPUR
OA1586918542	22B81A05U4	PRAVEEN KUMAR	GANGARAM
OA1586918543	22B81A05U5	PUZAA	NIZAMPATNAM
OA1586918544	22B81A05U6	RAGHU HARAN GOUD	NIMMAGUDEM
OA1586918572	22B81A05U7	RAKESH	KASTHURI
OA1586918573	22B81A05U8	RASHMITHA	MANCHI
OA1586918574	22B81A05U9	RISHITHA REDDY	RAMIDI
OA1586918627	22B81A05V0	RISHITHA REDDY	RAMIDI
OA1586918628	22B81A05V1	SAI CHANDHU	GADDAM
OA1586918629	22B81A05V2	SAI KEERTHAN REDDY	CHINNINTI
OA1586918630	22B81A05V3	SAI MANISH	PANDIRI
OA1586918708	22B81A05V4	SAI SUHAS REDDY	PANNALA
OA1586918709	22B81A05V5	SAI VARSHITH	VEMULA
OA1586918710	22B81A05V6	SANA	SHAIK
OA1586918711	22B81A05V7	SANJINI	VEMULA
OA1586918712	22B81A05V8	SANTHOSH	PATHULOTHU
OA1586918731	22B81A05V9	SHERI
OA1586918758	22B81A05W0	SHIVA SHANKAR	GADAGOJU
OA1586918785	22B81A05W1	SHREYA	TIRUNAGARI
OA1586918786	22B81A05W2	SIRI	DEVOJU
OA1586918787	22B81A05W3	MOHAMMED SOHAIB	SHAIK
OA1586918788	22B81A05W4	SRI PAVANI	RACHAKONDA
OA1586918789	22B81A05W5	SRINITH	TAPPA
OA1586918790	22B81A05W6	SWAPNA	KORRA
OA1586918791	22B81A05W7	SWETHA SRI	PERAMALLA
OA1586918792	22B81A05W8	TEJA	G M
OA1586918793	22B81A05W9	TEJAA KARTHIKEYA GOUD	TALLA
OA1586918794	22B81A05X0	TEJASHWINI	GONDLE
OA1586918795	22B81A05X1	THANMAI	REPAKULA
OA1586918796	22B81A05X2	TWISHA REDDY	KAYITI
OA1586918797	22B81A05X3	VAMSHI	SHANIGALA
OA1586918798	22B81A05X4	VAMSHI KRISHNA	PRATHAPAGIRI
OA1586918799	22B81A05X5	VAMSHI REDDY	BARDA
OA1586918800	22B81A05X6	VENKATA SRIKARAN JYOTHIRADITHYA	DAMARAJU
OA1586918845	22B81A05X7	VENKATESHWAR REDDY	MALLYALA
OA1586918846	22B81A05X8	VIBHAVESH	ARAVA
OA1586918847	22B81A05X9	VIJAYA LAKSHMI	JAYASURYA
const { MongoClient, ServerApiVersion } = require('mongodb');

// Connection URL and Database Name
const uri = `mongodb+srv://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@portfoliocluster.ilizpko.mongodb.net/?retryWrites=true&w=majority&appName=portfoliocluster`;
const dbName = process.env.DB_NAME_TESTING;

let db;

const connectToDatabase = async () => {
  const client = new MongoClient(uri, {
    serverApi: {
      version: ServerApiVersion.v1,
      strict: true,
      deprecationErrors: true,
    } 
  });
  
  try {
    // Connect to the MongoDB server
    await client.connect();
    console.log('Connected successfully to server');
    
    // Select the database through the connection returned by the MongoClient.connect
    db = client.db(dbName);
  } catch (err) {
    console.error('Unable to connect to the database:', err);
    // Close the connection in case of a connection error
    await client.close();
  }
};

const getDb = () => {
  return db;
};

module.exports = { connectToDatabase, getDb };
Thank you for patiently waiting and for chatting Sendwave my name is Ivan, how are you doing today?
from tqdm import tqdm
from time import sleep

text = """
This is text 123
""" * 100

# repeate text 100 times

with open('out.txt', 'w') as f:
    bar = tqdm(total=len(text), unit='B', unit_scale=True)
    for c in text:
        f.write(c)
        bar.update(1)
        sleep(0.0005)

Quantifiers
In the previous lesson, we discussed sets and ranges. Now it's time to learn about quantifiers, which we can use to indicate how many times a character or expression must occur in order to be counted as a match. We'll also talk about some issues you might face when using quantifiers and how we can overcome those issues.

Basic Quantifiers
Let's say you want to find the word "millennium", but you forgot how many "L"s are in the word: 

const str = 'How many Ls in the word "millennium"?';
 Save
To do this sort of search, you'll need to write a regular expression that will search for a string that starts with 'mi', followed by one or two 'l's, and ends with 'ennium'. 

One Occurrence to Infinite Occurrences — The + Quantifier
If you place the + quantifier to the right of a specific character, the engine will look for all words in which this character occurs one or more times.

const str = 'The correct spelling of the word "millennium" is with two Ls';
const regex = /mil+ennium/;

// this regular expression will find both variants: with one "L" and with two "L"s

str.match(regex); // [ 'millennium' ]
 Save
Zero Occurrences to Infinite Ones — The * Quantifier
Another quantifier used for searching repeated characters is the asterisk quantifier — *, which works in a similar fashion to + . 

Let's take a moment to contrast these two similarly behaving quantifiers. A character followed by + must be placed in a string. This quantifier is telling the engine "Look for this specific character, and after it, there could be any number of similar characters." 

On the other hand, if we put the * quantifier after a certain character, our regular expression can find a match even if that character isn't present. 

Consider the following example:

const exc = 'artist';
const esc = 'artiste';
const regex = /artiste*/; // the letter "e" may or may not occur
exc.match(regex); // [ 'artist' ]
esc.match(regex); // [ 'artiste' ]
 Save
To reiterate, if you place + after a character, the engine will look for matches where the character occurs at least once. If you place * after a character, the engine instead looks for matches with zero or more occurrences. So, in cases like the example above, you can use the * quantifier to create regular expressions that match different spellings of a certain word. The * quantifier tells the engine that the preceding character may or may not be included in the word.

An Optional Character — the ? Quantifier
There's one more way we can make a character optional, which is by using the ? quantifier. The asterisk * can work with any amount of characters, but the question mark will only match either zero occurrences or one occurrence of your chosen character:

/* makes the letter u optional and matches 
both spelling variants: favourite and favorite. */

const regex = /favou?rite/g;
const    str = 'favourite or favorite';

str.match(regex); // ['favourite', 'favorite']
 Save
Either One Character or the Other — The | Quantifier
This quantifier allows us to create "forks" of our characters and search for alternatives in our regular expression. For example, if you write a|b, you're telling the engine that either a or b is fine:

const someSymbol = /cent(er|re)/g
const    str = 'center or centre';

console.log(str.match(someSymbol)); // ['center', 'centre']
 Save
A good situation for using the | quantifier is when you have to work with texts that are written in both American and British English as there are often a lot of subtle spelling differences between the two.

Managing The Number of Repetitions — The {} Quantifier
In order to search for a group of repeated characters, you can usually list them in a regular expression: 

const regionCode = /\d\d\d/;
const    phoneNumber = 'My phone number: +1(555)324-41-5';

phoneNumber.match(regionCode); // [ '555' ]
 Save
The quantifier {} enables us to avoid going through this process. All you have to do is specify the number of matches inside curly braces: 

const regionCode = /\d{3}/;
const    phoneNumber = 'My phone number: +1(555)324-41-5';

phoneNumber.match(regionCode); // [ '555' ]
 Save
In addition to indicating an exact number of repetitions, you can also create a range. For example, we can do this when we need to find matches ranging from 2 to 5 repetitions:

const str = 'this much, thiiis much, thiiiiiiis much';
const regex = /thi{2,5}s/;

str.match(regex); // [ 'thiiis' ]

// in the word "this" the letter "i" occurs only once
// and in the word "thiiiiiiis" the letter "i" occurs more than 5 times
 Save
Additionally, you can omit the maximum number of repetitions. For instance, you can set the quantifier to search a range from one repetition of a character to an infinite number of repetitions. To do that, omit the second number inside curly brackets, while keeping the comma. 

const someSymbol = /a{1,}/g;
const    str = 'alohaa';

console.log(str.match(someSymbol)); // ['a', 'aa']
 Save
Lazy and Greedy Quantifiers
When deciding what to return, a regular expression sometimes faces a choice. 

For example, let's imagine we want to find a string that both starts and ends with "e", using the quantifier {2,11} between the opening and closing letters to limit our search:

const    str = 'Everyone else knows that book, you know';
const someSymbols = /e.{2,11}e/gi;

console.log(str.match(someSymbols)); // ['Everyone else']
 Save
The match() method returned the string 'Everyone else'. But the word 'Everyone' could have also qualified here. After all, it starts with "e", ends in "e", and has 6 letters between the first letter and the last one. What happened?

Apparently, the engine chose the longer match over the shorter one. That's why such behavior is called greedy matching. In fact, greediness is the default behavior of the {} quantifier:

const str = 'eeeeeeeee'; // 9 repetitions of the letter "e"
const regex = /e{1,11}/;

str.match(regex); // [ 'eeeeeeeee' ] — the greedy quantifier found all "e"s 
 Save
Sometimes, our matches are greedy. Hey, nobody's perfect! The flip side of this greediness is laziness. Simply stated, a lazy quantifier will find a short match instead of a long one. To make {} lazy, we just need to put a question mark after it: {}?:

const someSymbols = /e.{2,11}?e/gi;
const    str = 'Everyone else knows that book, you know';

console.log(str.match(someSymbols)); // ['Everyone', 'else']

/* the lazy quantifier has found the shortest matches this time */ 
 Save
You can also make the + quantifier lazy by adding ? in the same way:

const someSymbols = /e.+?n/gi;
const    str = 'Ed\'s son can swim like a fish';

console.log(str.match(someSymbols));// [ "Ed's son" ]
 Save
To emphasize the difference again, notice what happens to the code above when we remove the ?. Instead of 'Ed\'s son', the larger possible match, 'Ed\'s son can', is returned instead:

const someSymbols = /e.+n/gi;
const    str = 'Ed\'s son can swim like a fish';

console.log(str.match(someSymbols));// [ "Ed's son can" ]
 Save
Quantifier	Matches
+	matches a character 1 or more times in a row.
*	matches a character 0 or more times in a row.
׀	matches one of two characters (the one on the left of ׀ or the one on the right)
?	matches a character 0 or 1 times.
{}	matches an exact number of occurrences or a range of repeated characters.
Remember that quantifiers can be greedy and lazy. If a quantifier has to choose between a longer and a shorter string belonging to a regular expression, a lazy quantifier will go for the shorter match, while a greedy one ends up returning the longer string:

const str = 'free from worries'; 
const regexLazy = /fr.+?[es]/; // lazy quantifier 
const regexGreedy = /fr.+[es]/; // greedy quantifier 

console.log(str.match(regexLazy)); // [ 'free' ]
console.log(str.match(regexGreedy)); // [ 'free from worries' ]
 Save
Before moving on to the tasks, let's take a 2 question quiz to help review quantifiers themselves, and the difference between greedy and lazy quantifiers
from datetime import date
from pandas import date_range
from uuid import uuid4
from random import randint


s_date = date(2019, 1, 1)
e_date = date(2019, 1, 30)

stats = {}

for d in date_range(start=s_date, end=e_date):
    d = str(d.date())
    stats[d] = {
        'user_id': str(uuid4()),
        'clicks': randint(0, 1000)
    }


print(stats)
import pyaudio
import numpy as np
import pyqtgraph as pg

# Initialize PyAudio
pa = pyaudio.PyAudio()

# Set up audio stream
stream = pa.open(
    format=pyaudio.paInt16,
    channels=1,
    rate=44100,
    input=True,
    frames_per_buffer=1024
)

# Set up PyQTGraph
app = pg.mkQApp()
win = pg.GraphicsLayoutWidget()
win.show()
plot = win.addPlot(title='Real-time Audio Waveform')
curve = plot.plot()

# Function to update the plot
def update():
    wf_data = np.frombuffer(stream.read(1024), dtype=np.int16)
    curve.setData(wf_data)

# Start the audio stream
timer = pg.QtCore.QTimer()
timer.timeout.connect(update)
timer.start(50)

# Start Qt event loop
pg.mkQApp().exec()

import customtkinter as ctk
import threading


run = True

def task():
    while run:
        print('Task running...')
        if not run:
            print('Task closed')
            return
        
def start_task():
    global run
    run = True
    threading.Thread(target=task).start()


def close_task():
    global run
    run = False

root = ctk.CTk()
root.geometry('500x60')

ctk.CTkButton(root, text='start task', command=start_task).place(x = 20, y = 10)
ctk.CTkButton(root, text='close task', command=close_task).place(x = 220, y = 10)

root.mainloop()
import time
from functools import wraps

def rate_limiter(max_calls, period=60):
    def decorator(func):
        timestamps = []

        @wraps(func)
        def wrapper(*args, **kwargs):
            nonlocal timestamps
            current_time = time.time()
            # Remove timestamps outside of the current period
            timestamps = [t for t in timestamps if current_time - t < period]
            if len(timestamps) < max_calls:
                timestamps.append(current_time)
                return func(*args, **kwargs)
            else:
                print(f"Rate limit exceeded. Try again in {int(period - (current_time - timestamps[0]))} seconds.")
        return wrapper
    return decorator

# Example usage:
@rate_limiter(max_calls=5)
def my_function():
    # Your function implementation here
    print("Function is called")

# Test the rate limiter
for i in range(10):
    my_function()
    time.sleep(1)  # Sleep for demonstration purposes
    Enter any string: www.includehelp.com
    Entered string is: www.includehelp.com

star

Tue Apr 09 2024 02:10:38 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:10:09 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:09:40 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:09:40 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:09:08 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:08:34 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:07:45 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:07:02 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:06:36 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:06:02 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:04:13 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:03:22 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 02:02:04 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 01:59:00 GMT+0000 (Coordinated Universal Time)

@wayneinvein

star

Tue Apr 09 2024 01:30:23 GMT+0000 (Coordinated Universal Time)

@davidmchale #custom #properties

star

Tue Apr 09 2024 01:29:12 GMT+0000 (Coordinated Universal Time)

@davidmchale #random #image #url

star

Mon Apr 08 2024 20:32:59 GMT+0000 (Coordinated Universal Time)

@jamzlego #nodejs

star

Mon Apr 08 2024 16:41:27 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github

@CarlosR

star

Mon Apr 08 2024 16:37:48 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github

@CarlosR

star

Mon Apr 08 2024 15:36:29 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/sv-se/windows/apps/get-started/developer-mode-features-and-debugging#additional-developer-mode-features

@dw

star

Mon Apr 08 2024 15:31:50 GMT+0000 (Coordinated Universal Time)

@jamzlego #nodejs

star

Mon Apr 08 2024 15:30:34 GMT+0000 (Coordinated Universal Time)

@codeing

star

Mon Apr 08 2024 14:38:43 GMT+0000 (Coordinated Universal Time)

@jamzlego #nodejs

star

Mon Apr 08 2024 14:35:20 GMT+0000 (Coordinated Universal Time)

@jamzlego #nodejs

star

Mon Apr 08 2024 11:48:34 GMT+0000 (Coordinated Universal Time)

@Saurabh_Lodhi #swift #inapppurchase

star

Mon Apr 08 2024 11:37:55 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/67715555/big-query-pivot-operator-how-do-i-make-it-work-when-column-data-type-is-string

@flaviobrito

star

Mon Apr 08 2024 10:28:16 GMT+0000 (Coordinated Universal Time) https://www.beleaftechnologies.com/cryptocurrency-exchange-development-company

@Elizebeth #web3 #cryptocurrencyexchange development company #cryptocurrencyexchange software development company #cryptocurrency exchange development services

star

Mon Apr 08 2024 10:27:32 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/63447213/generate-all-combinations

@flaviobrito #sql

star

Mon Apr 08 2024 10:26:05 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/2258735/how-to-create-a-query-to-list-all-combinations-possibilities

@flaviobrito #sql

star

Mon Apr 08 2024 10:25:57 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/2258735/how-to-create-a-query-to-list-all-combinations-possibilities

@flaviobrito #sql

star

Mon Apr 08 2024 09:35:02 GMT+0000 (Coordinated Universal Time) https://www.freecodecamp.org/news/python-code-examples-sample-script-coding-tutorial-for-beginners/

@flaviobrito #python

star

Mon Apr 08 2024 08:30:59 GMT+0000 (Coordinated Universal Time) https://reactrouter.com/en/main/start/tutorial

@mahmoudAli

star

Mon Apr 08 2024 08:28:29 GMT+0000 (Coordinated Universal Time) https://reactrouter.com/en/main/start/tutorial

@mahmoudAli

star

Mon Apr 08 2024 07:51:30 GMT+0000 (Coordinated Universal Time)

@Paloma #js #nuxt

star

Mon Apr 08 2024 05:39:44 GMT+0000 (Coordinated Universal Time) https://twitter.com/SalomeHerr680

@anthonymahssv

star

Mon Apr 08 2024 04:48:40 GMT+0000 (Coordinated Universal Time)

@signup

star

Mon Apr 08 2024 03:37:17 GMT+0000 (Coordinated Universal Time)

@jamzlego #nodejs

star

Sun Apr 07 2024 23:14:30 GMT+0000 (Coordinated Universal Time)

@llight123010

star

Sun Apr 07 2024 22:57:21 GMT+0000 (Coordinated Universal Time) https://tripleten.com/trainer/web/lesson/d18cb983-879a-4bb5-a5bf-1c155032d8e3/task/029e5f21-b597-4818-b455-c755b137caa1/

@Marcelluki

star

Sun Apr 07 2024 20:22:01 GMT+0000 (Coordinated Universal Time)

@amramroo ##python #coding #limiter #decorators

star

Sun Apr 07 2024 20:21:41 GMT+0000 (Coordinated Universal Time) https://www.includehelp.com/c-programs/string-manipulation-programs.aspx

@2233081393

star

Sun Apr 07 2024 19:57:54 GMT+0000 (Coordinated Universal Time)

@harlanecastro

star

Sun Apr 07 2024 19:57:06 GMT+0000 (Coordinated Universal Time)

@harlanecastro

star

Sun Apr 07 2024 19:56:19 GMT+0000 (Coordinated Universal Time)

@harlanecastro

star

Sun Apr 07 2024 19:55:36 GMT+0000 (Coordinated Universal Time)

@harlanecastro

Save snippets that work with our extensions

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