https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating_service_account_keys
domingo, 18 de julio de 2021
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
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.
Installing the client library
For more information, see Using PHP on Google Cloud.
composer require google/cloud-speech
Setting up authentication
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.
In the Cloud Console, go to the Create service account key page.
Go to the Create Service Account Key page- From the Service account list, select New service account.
- In the Service account name field, enter a name.
From the Role list, select Project > Owner.
- 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"
Using the client library
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();
martes, 9 de febrero de 2021
Passing parameters to window.open javascript
myu = document.getElementById('cid').value;
myp = document.getElementById('pwd').value;
window.open("http://localhost:8080/login?cid="+ myu +"&pwd="+ myp ,"MyTargetWindowName");