miércoles, 27 de septiembre de 2023

PDF search and sort

pdfgrep -P '\(809|829|849\)\d{7}' VILLA-NAZARET-BAYONA.pdf  | grep -oP '\((809|829|849)\).{10}'


pdfgrep -P '\(809|829|849\)\d{7}' VILLA-NAZARET-BAYONA.pdf | grep -oP '\((809|829|849)\).{10}' | sed 's/[^0-9]//g'






pdfgrep -P '\(809|829|849\)\d{7}' PRM_HATO NUEVO.pdf | grep -oP '\((809|829|849)\).{10}' | sed 's/[^0-9]//g' >  PRM _ MANOGUAYABO.txt

miércoles, 9 de agosto de 2023

domingo, 25 de junio de 2023

find if a word or substring exist based on php array

 <?php



$acctname = array(

    "Nash_paid",

    "Nash_Orange",

    "Sagi_Orange",

    "Sagu_paid",

    "Red_Phone",

    "Main_Paid",

    "Abi_Orange",

    "Abi_paid",

    "Repeated client_",

    "Meni_Road",

    "Meni_Towing",

    "Main_line");



$string="Red_Phone";

foreach($acctname as $substring){

if (stripos($string, $substring) !== false) {


echo  "$substring<br>";

}

}


?>

get the the monday and sunday from a week a go

 <?php

// Get the current date

$currentDate = date('Y-m-d');


// Calculate the previous week's Monday

$previousMonday = date('Y-m-d', strtotime($currentDate . ' -1 week monday'));


// Calculate the previous week's Sunday

$previousSunday = date('Y-m-d', strtotime($currentDate . ' -1 week sunday'));


// Display the results

echo "Previous Week's Monday: " . $previousMonday . "<br>";

echo "Previous Week's Sunday: " . $previousSunday . "<br>";

?>


sábado, 6 de mayo de 2023

html table

<!DOCTYPE html>

<html>

<head>

<style>

* {

    /* Change your font family */

    font-family: sans-serif;

}


.content-table {

    border-collapse: collapse;

    margin: 25px 0;

    font-size: 0.9em;

    min-width: 400px;

    border-radius: 5px 5px 0 0;

    overflow: hidden;

    box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);

}


.content-table thead tr {

    background-color: #009879;

    color: #ffffff;

    text-align: left;

    font-weight: bold;

}


.content-table th,

.content-table td {

    padding: 12px 15px;

}


.content-table tbody tr {

    border-bottom: 1px solid #dddddd;

}


.content-table tbody tr:nth-of-type(even) {

    background-color: #f3f3f3;

}


.content-table tbody tr:last-of-type {

    border-bottom: 2px solid #009879;

}


.content-table tbody tr.active-row {

    font-weight: bold;

    color: #009879;

}



</style>

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>How to Style HTML Tables with CSS</title>

    <link rel="stylesheet" href="css/main.css">

</head>

<body>

    <table class="content-table">

        <thead>

          <tr>

            <th>Rank</th>

            <th>Name</th>

            <th>Points</th>

            <th>Team</th>

          </tr>

        </thead>

        <tbody>

          <tr>

            <td>1</td>

            <td>Domenic</td>

            <td>88,110</td>

            <td>dcode</td>

          </tr>

          <tr class="active-row">

            <td>2</td>

            <td>Sally</td>

            <td>72,400</td>

            <td>Students</td>

          </tr>

          <tr>

            <td>3</td>

            <td>Nick</td>

            <td>52,300</td>

            <td>dcode</td>

          </tr>

        </tbody>

      </table>

</body>

</html>


 https://dcode.domenade.com/tutorials/how-to-style-html-tables-with-css

Dashboarc code

 <!DOCTYPE html>

<html>

<head>

<style>

.grid-container {

  display: grid;

  grid-template-columns: repeat(2, 1fr);

  grid-gap: 20px;

}


.grid-item {

  display: flex;

  justify-content: center;

  align-items: center;

  height: 150px;

  border-radius: 5px;

  box-shadow: 0 2px 4px rgba(0,0,0,.2);

  font-size: 4rem;

}


.red {

  background-color: #FF5252;

  color: white;

}


.blue {

  background-color: #2196F3;

  color: white;

}


.green {

  background-color: #4CAF50;

  color: white;

}


.yellow {

  background-color: #FFC107;

  color: white;

}


i {

  font-size: 1.5rem;

}


</style>

<title>Page Title</title>

</head>

<body>


<div class="grid-container">

  <div class="grid-item red">


    <i class="fas fa-phone">  Active</i>

  </div>

  <div class="grid-item blue">

    <i class="fas fa-phone"> ICC</i>

  </div>

  <div class="grid-item green">

    <i class="fas fa-phone">FFF</i>

  </div>

  <div class="grid-item yellow">

    <i class="fas fa-phone">DD</i>

  </div>

</div>



</body>

</html>


jueves, 27 de abril de 2023

gpt-3.5-turbo API

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

curl_setopt($ch, CURLOPT_HTTPHEADER, [

    'Authorization: Bearer $API_KEY',

    'Content-Type: application/json',

]);



$model="gpt-3.5-turbo";

curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"model\": \"$model\",\n \"messages\": [{\"role\": \"user\", \"content\": \"$argv[1]\"}] \n }");


$response = curl_exec($ch);

 $object=json_decode($response);

$array = json_decode(json_encode($object), true);

//print_r($array);  //uncoment for details

echo $array['choices'][0]['message']['content'];

echo "\n";

curl_close($ch);


?>




curl https://api.openai.com/v1/chat/completions \

  -H "Content-Type: application/json" \

  -H "Authorization: Bearer $OPENAI_API_KEY" \

  -d '{

    "model": "gpt-3.5-turbo",

    "messages": [{"role": "user", "content": "Hello!"}]

  }'

https://platform.openai.com/docs/api-reference/chat/create