Is there a way to operate with decimals in Bash? Trading, obviously. I have tried with let
, but it always throws me an error with the decimal part.
Thank you very much.
Is there a way to operate with decimals in Bash? Trading, obviously. I have tried with let
, but it always throws me an error with the decimal part.
Thank you very much.
I am working with migrations in Laravel and I have a partners table that has a type attribute of type enum with the following values:
$table->enum('type', ['cliente', 'proveedor', 'empleado', 'transportadora'])->nullable();
What I need is the following: Create another migration so that I can modify the partners table, adding one more value to the enum so that the database looks like this:
['cliente', 'proveedor', 'empleado', 'transportadora', 'nuevo_dato']
What I tried so far was the following:
Schema::table('partners', function ($table) {
DB::statement("ALTER COLUMN 'type' ADD VALUE 'nuevo_dato' AFTER 'cliente'");
});
And I also tried:
Schema::table('partners', function ($table) {
$table->enum('type', ['cliente', 'proveedor', 'empleado', 'transportadora', 'nuevo_dato'])->change();
});
Y...
DB::statement("ALTER TABLE 'partners' MODIFY COLUMN 'type' enum('nuevo_dato') NOT NULL AFTER `transportadora`");
Without reaching the expected result. I would be very grateful if you help me with this. (PS: I'm using PostgreSQL)
Well, my problem is that I'm using PHP from a template that I bought to make a form, but I can't figure out how to modify it so that when the user sends their query, it doesn't just reach the receiving mail, but a copy is sent to other emails.
I leave the PHP that I am using
From already thank you very much!
<?php
$to = '[email protected]';
$name = $_POST['name'];
$tel = $_POST['tel'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
// Email Submit
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($email) && isset($name) && isset($tel) && isset($subject)
&& isset($message) && filter_var($email, FILTER_VALIDATE_EMAIL) ) {
// detect & prevent header injections
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
$body = <<<EMAIL
ASUNTO : $subject
HOLA MI NOMBRE ES, $name.
$message
DE : $name
TEL : $tel
MAIL : $email
EMAIL;
$header = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>' . "\r\n" .
'Reply-To: ' . $_POST["email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//
// mail( $to , $_POST['subject'], $_POST['message'], $headers );
mail($to, $subject, $body, $header);
// ^
// Replace with your email
}?>
I have an application to randomly play YouTube videos using the YouTube API, to get a random video id and play the video I have a button called nextVideo, but when I press it it does not allow the methods of youtubePlayer to be invoked:
public void siguienteVideo(View v){
youTubePlayer.loadVideo(videoId);
youTubePlayer.play();
}
Nor use public api methods like:
public void cueVideo (String videoId){
youTubePlayer.loadVideo(videoId);
youTubePlayer.play();
}
public void siguienteVideo(View v){
cueVideo(idVideoFinal);
}
I get this exception:
java.lang.IllegalStateException: Could not execute method for android:onClick
Initialization:
//Método para comprobar si fue bien
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
//Si fue bien entonces carga y reproduce el video
if(!b){
youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
//Carga y reproduce directamente el video
youTubePlayer.loadVideo("DRS_PpOrUZ4");
youTubePlayer.play();
}
}
//Método para comprobar si algo fue mal
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
//Si existió algún error al inicializar muestra un dialog con el error
if(youTubeInitializationResult.isUserRecoverableError()){
youTubeInitializationResult.getErrorDialog(this, 1).show();
}
//Si YT no sabe cual es el error enviará este mensaje
else{
Toast.makeText(getApplicationContext(), "Error al inializar YouTube "+youTubeInitializationResult.toString(), Toast.LENGTH_LONG).show();
}
}
The youtubePlayer that doesn't work for me is the one with the next buttonVideo(View v)
SOLUTION
I have found a solution to the problem:
As a global variable I have a variable of type YoutubePlayer
private YouTubePlayer youTubePlayer1;
And when initializing:
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
//Si fue bien entonces carga y reproduce el video
if(!b){
youTubePlayer1=youTubePlayer;
youTubePlayer1.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
//Carga y reproduce directamente el video
youTubePlayer1.loadVideo("DRS_PpOrUZ4");
youTubePlayer1.play();
}
}
And so it can be used anywhere:
public void siguienteVideo(View v){
youTubePlayer1.loadVideo("ZsUMwahBvh8");
youTubePlayer1.play();
}