lunes, 6 de diciembre de 2021

php get time zome based on current time


$date = new DateTime();

$date->setTimezone(new DateTimeZone('America/Detroit'));

echo $fdate = $date->format('Y-m-d H:i:s');

https://www.php.net/manual/en/timezones.php

https://compass.greatdata.com/areacode/currenttime

lunes, 1 de noviembre de 2021

Javascript confirmaton

 <a href="delete.php?id=22" onclick="return confirm('Are you sure you want to delete?')">Link</a>


miércoles, 27 de octubre de 2021

HTML autoplay

 <head> 

    <title> 

        HTML audio autoplay Attribute

    </title> 

</head> 

  

<body style="text-align: center"> 

  

    <h1 style="color: green"> 

        GeeksforGeeks 

    </h1> 

      

    <h2>HTML audio autoplay Attribute</h2> 

  

    <audio controls autoplay> 

        <source src="GFG.ogg" type="audio/ogg"> 

        <source src="https://www.mboxdrive.com/Alarm-Fast-A1-www.fesliyanstudios.com.mp3" type="audio/mpeg"> 

    </audio> 

</body> 

  

</html>

viernes, 8 de octubre de 2021

pipe drive curl

 <?php

// Content of createDeal.php

    

// Pipedrive API token

$api_token = '659c9fddb16335e48cc67114694b52074e812e03';

    

// Pipedrive company domain

$company_domain = 'theunicorntail';

 

// Deal title and Organization ID

$deal = array(

  'title' => 'Deal title goes here',

  'org_id' => 'Organization ID goes here'

);

 

$url = 'https://' . $company_domain . '.pipedrive.com/api/v1/deals?api_token=' . $api_token;

 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $deal);

 

echo 'Sending request...' . PHP_EOL;

 

$output = curl_exec($ch);

curl_close($ch);

 

// Create an array from the data that is sent back from the API

// As the original content from server is in JSON format, you need to convert it to PHP array

$result = json_decode($output, true);

 

// Check if an ID came back, if did print it out

if (!empty($result['data']['id'])) {

   echo 'Deal was added successfully!' . PHP_EOL;

}

?>

domingo, 3 de octubre de 2021

mysql delete script

 <?php

$link = mysqli_connect("localhost", "root", "", "dialer");


/* check connection */

if (mysqli_connect_errno()) {

    printf("Connect failed: %s\n", mysqli_connect_error());

    exit();

}


$query = " delete from dnc where phone='$_GET[name]'";


if ($result = mysqli_query($link, $query)) {


 header("Location:./dnc.php");



    /* free result set */

    mysqli_free_result($result);

}


else {


 printf("Error: %s\n", mysqli_error($link));


}



/* close connection */

mysqli_close($link);

?>


sábado, 25 de septiembre de 2021

dynamically-add-or-remove-form-input-fields-using-jquer

 https://bootstrapfriendly.com/blog/dynamically-add-or-remove-form-input-fields-using-jquery/


https://www.formget.com/how-to-dynamically-add-and-remove-form-fields-using-javascript/


http://demos.codexworld.com/add-remove-input-fields-dynamically-using-jquery/

lunes, 13 de septiembre de 2021

php disk space

 


<?php
    $bytes 
disk_free_space(".");
    
$si_prefix = array( 'B''KB''MB''GB''TB''EB''ZB''YB' );
    
$base 1024;
    
$class min((int)log($bytes $base) , count($si_prefix) - 1);
    echo 
$bytes '<br />';
    echo 
sprintf('%1.2f' $bytes pow($base,$class)) . ' ' $si_prefix[$class] . '<br />';
?>

domingo, 12 de septiembre de 2021

Sucess Modal




<!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">

<title>Bootstrap Elegant Success Modal</title>

<link href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round" rel="stylesheet">

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<style>

    body {

font-family: 'Varela Round', sans-serif;

}

.modal-confirm {

color: #434e65;

width: 525px;

margin: 30px auto;

}

.modal-confirm .modal-content {

padding: 20px;

font-size: 16px;

border-radius: 5px;

border: none;

}

.modal-confirm .modal-header {

background: #47c9a2;

border-bottom: none;   

        position: relative;

text-align: center;

margin: -20px -20px 0;

border-radius: 5px 5px 0 0;

padding: 35px;

}

.modal-confirm h4 {

text-align: center;

font-size: 36px;

margin: 10px 0;

}

.modal-confirm .form-control, .modal-confirm .btn {

min-height: 40px;

border-radius: 3px; 

}

.modal-confirm .close {

        position: absolute;

top: 15px;

right: 15px;

color: #fff;

text-shadow: none;

opacity: 0.5;

}

.modal-confirm .close:hover {

opacity: 0.8;

}

.modal-confirm .icon-box {

color: #fff;

width: 95px;

height: 95px;

display: inline-block;

border-radius: 50%;

z-index: 9;

border: 5px solid #fff;

padding: 15px;

text-align: center;

}

.modal-confirm .icon-box i {

font-size: 64px;

margin: -4px 0 0 -4px;

}

    .modal-confirm .btn {

        color: #fff;

        border-radius: 4px;

background: #eeb711;

text-decoration: none;

transition: all 0.4s;

        line-height: normal;

border-radius: 30px;

margin-top: 10px;

padding: 6px 20px;

        border: none;

    }

.modal-confirm .btn:hover, .modal-confirm .btn:focus {

background: #eda645;

outline: none;

}

.modal-confirm .btn span {

margin: 1px 3px 0;

float: left;

}

.modal-confirm .btn i {

margin-left: 1px;

font-size: 20px;

float: right;

}

.trigger-btn {

display: inline-block;

margin: 100px auto;

}

</style>

</head>

<body>

<!-- load modal on page load -->

<script type="text/javascript">

    $(window).on('load', function() {

        $('#myModal').modal('show');

    });

</script>



<div class="text-center">

<!-- load modal on click-->

<a href="#myModal" class="trigger-btn" data-toggle="modal">Click to Open Success Modal</a>

</div>


<!-- Modal HTML -->

<div id="myModal" class="modal fade">

<div class="modal-dialog modal-confirm">

<div class="modal-content">

<div class="modal-header">

<div class="icon-box">

<i class="material-icons">&#xE876;</i>

</div>

<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

</div>

<div class="modal-body text-center">

<h4>Great!</h4>

<p>Your account has been created successfully.</p>

<a href="http://155.138.223.92/AdminLTE-3.1.0/pages/layout/create_cp1.php" class="btn btn-success"> Go back</a>



<!--<button class="btn btn-success" data-dismiss="modal"><span>Go Back</span> <i class="material-icons">&#xE5C8;</i></button> -->




</div>

</div>

</div>

</div>     

</body>

</html>  



https://www.tutorialrepublic.com/snippets/preview.php?topic=bootstrap&file=elegant-success-modal

https://www.tutorialrepublic.com/snippets/preview.php?topic=bootstrap&file=elegant-error-modal

domingo, 5 de septiembre de 2021

convert a literal date to unix time and then to MYSQL time

 <?php


echo $dt=strtotime("09/06/2021 3:01 AM");


echo "<br>";


echo $today = date("Y-m-d H:i:s",$dt);


?>

1630911660
2021-09-06 03:01:00


domingo, 29 de agosto de 2021

-datatable-data-to-excel-csv-pdf-copy-print

 https://techarise.com/export-jquery-datatable-data-to-excel-csv-pdf-copy-print/


https://www.phpzag.com/export-jquery-datatable-data-to-pdfexcelcsv-copy-with-php/

domingo, 22 de agosto de 2021

Html table

 <head>

<style>

* {

  font-family: sans-serif; /* Change your font family */

}


.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>

</head>


<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>


https://dev.to/dcodeyt/creating-beautiful-html-tables-with-css-428l

domingo, 18 de julio de 2021

Google creating a key

 https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating_service_account_keys

viernes, 4 de junio de 2021

Quickly Show All PHP Errors

 

The quickest way to display all php errors and warnings is to add these lines to your PHP code file:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

domingo, 16 de mayo de 2021

get day of the week name

 <?php

//Our YYYY-MM-DD date string.
$date = "2002-12-02";

//Convert the date string into a unix timestamp.
$unixTimestamp = strtotime($date);

//Get the day of the week using PHP's date function.
$dayOfWeek = date("l", $unixTimestamp);

//Print out the day that our date fell on.
echo $date . ' fell on a ' . $dayOfWeek;

sábado, 3 de abril de 2021

Get current URL

 $_SERVER['REQUEST_URI']

For more details on what info is available in the $_SERVER array, see the PHP manual page for it.

If you also need the query string (the bit after the ? in a URL), that part is in this variable:

$_SERVER['QUERY_STRING']

miércoles, 24 de febrero de 2021

how-to-install-a-specific-version-of-package-using-composer

 composer require vendor/package:version

for example:

composer require refinery29/test-util:0.10.2

https://stackoverflow.com/questions/40914114/how-to-install-a-specific-version-of-package-using-composer

miércoles, 17 de febrero de 2021

Speech-to-Text Client Libraries

 

Speech-to-Text Client Libraries

This page shows how to get started with the Cloud Client Libraries for the Speech-to-Text API. Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

For more information, see Using PHP on Google Cloud.

composer require google/cloud-speech

To run the client library, you must first set up authentication by creating a service account and setting an environment variable. Complete the following steps to set up authentication. For other ways to authenticate, see the GCP authentication documentation.

  1. In the Cloud Console, go to the Create service account key page.

    Go to the Create Service Account Key page
  2. From the Service account list, select New service account.
  3. In the Service account name field, enter a name.
  4. From the Role list, select Project > Owner.

  5. Click Create. A JSON file that contains your key downloads to your computer.

Provide authentication credentials to your application code by setting the environment variable GOOGLE_APPLICATION_CREDENTIALS. Replace [PATH] with the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.

export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

For example:

export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json"

The following example shows how to use the client library.

# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';

# Imports the Google Cloud client library
use Google\Cloud\Speech\V1\SpeechClient;
use Google\Cloud\Speech\V1\RecognitionAudio;
use Google\Cloud\Speech\V1\RecognitionConfig;
use Google\Cloud\Speech\V1\RecognitionConfig\AudioEncoding;

# The name of the audio file to transcribe
$gcsURI
= "gs://cloud-samples-data/speech/brooklyn_bridge.raw";

# set string as audio content
$audio
= (new RecognitionAudio())
   
->setUri($gcsURI);

# The audio file's encoding, sample rate and language
$config
= new RecognitionConfig([
   
'encoding' => AudioEncoding::LINEAR16,
   
'sample_rate_hertz' => 16000,
   
'language_code' => 'en-US'
]);

# Instantiates a client
$client
= new SpeechClient();

# Detects speech in the audio file
$response
= $client->recognize($config, $audio);

# Print most likely transcription
foreach ($response->getResults() as $result) {
    $alternatives
= $result->getAlternatives();
    $mostLikely
= $alternatives[0];
    $transcript
= $mostLikely->getTranscript();
    printf
('Transcript: %s' . PHP_EOL, $transcript);
}

$client
->close();