<?php
function pass($var){
return $var>=70;
}
$notas=array("Jose"=>90,"Ambiorix"=>100,"Maria"=>65,90);
print_r(array_filter($notas,"pass"));
?>
Array
(
[Jose] => 90
[Ambiorix] => 100
[0] => 90
)
<?php
function pass($var){
return $var>=70;
}
$notas=array("Jose"=>90,"Ambiorix"=>100,"Maria"=>65,90);
print_r(array_filter($notas,"pass"));
?>
Array
(
[Jose] => 90
[Ambiorix] => 100
[0] => 90
)
DELIMITER //
CREATE TRIGGER ProductSellPriceUpdateCheck
AFTER UPDATE
ON Products FOR EACH ROW
BEGIN
IF NEW.SellPrice <= NEW.BuyPrice THEN
INSERT INTO Notifications(Notification,DateTime)
VALUES(CONCAT(NEW.ProductID,' was updated with a SellPrice of ', NEW.SellPrice,' which is the same or less than the BuyPrice'), NOW());
END IF;
END //
DELIMITER //
CREATE TRIGGER ProductSellPriceInsertCheck
AFTER INSERT
ON Products FOR EACH ROW
BEGIN
IF NEW.SellPrice <= NEW.BuyPrice THEN
INSERT INTO Notifications(Notification,DateTime)
VALUES(CONCAT('A SellPrice same or less than the BuyPrice was inserted for ProductID ', NEW.ProductID), NOW());
END IF;
END //
DELIMITER //
CREATE TRIGGER NotifyProductDelete
AFTER DELETE
ON Products FOR EACH ROW
INSERT INTO Notifications(Notification, DateTime)
VALUES(CONCAT('The product with a ProductID ', OLD.ProductID,' was deleted'), NOW());
END //
DELIMITER ;
https://dev.mysql.com/doc/refman/8.4/en/
To get the comments for a Page post, send a GET
request to the /page_post_id/comments
endpoint with the fields
parameter set to a comma-separated list that includes the message
field, to get the content for the comment and the from
field, to get the Page-scoped ID (PSID) for the person or Page who commented on the post, if you would like to @mention the person or Page in the comment.
curl -i -X GET "https://graph.facebook.com/page_post_id/comments?fields=from,message"
On success, your app receives the following JSON response with the commentor's name, PSID, message and the comment ID:
{ "data": [ { "created_time": "2020-02-19T23:05:53+0000", "from": { "name": "commentor_name", "id": "commentor_PSID" }, "message": "comment_content", "id": "comment_id" } ], "paging": { "cursors": { "before": "MQZDZD", "after": "MQZDZD" } }
}
https://developers.facebook.com/docs/pages-api/comments-mentions/
I've been playing around with the Twitter API lately and, as you know, Tweets can only be 140 characters long. I wanted to use a textarea element, not an input type="text", so I couldn't just use maxchars to limit the number of characters. Additionally, I get annoyed when my text is chopped off when pasting. So, what to do? Well, I thought, why not make a little character counter like the one you find on the actual Twitter?
The first step is to create the JavaScript function. I placed mine in a file called count-chars.js and it looks like this:
function countChars(textbox, counter, max) { var count = max - document.getElementById(textbox).value.length; if (count < 0) { document.getElementById(counter).innerHTML = "<span style=\"color: red;\">" + count + "</span>"; } else { document.getElementById(counter).innerHTML = count; } }
textbox and counter are the IDs of the elements of the textarea we're counting and the span where the count is going to go, respectively.
There's lots you can customize there. You could disable the form if too many characters are entered or you could automatically truncate the text. But, I prefer to just have the warning show up in red text.
The next step is to write the HTML itself:
<script type="text/javascript" src="/js/count-chars.js"></script> <form action="#" method="POST"> <p>Tweet Something: <span id="char_count"></span><br><textarea name="tweet" id="textbox" class="form-control" rows="3" cols="60" onFocus="countChars('textbox','char_count',140)" onKeyDown="countChars('textbox','char_count',140)" onKeyUp="countChars('textbox','char_count',140)"></textarea></p> <p><input type="submit" class="btn btn-primary" value="Tweet" /></p> </form>
https://nanonets.com/blog/chat-with-pdfs-using-chatgpt-and-openai-gpt-api/
https://cloud.google.com/text-to-speech/docs/audio-profiles
To generate an audio file, make a POST
request and provide the appropriate request body. The following shows an example of a POST
request using curl
. The example uses the access token for a service account set up for the project using the Google Cloud Platform Cloud SDK. For instructions on installing the Cloud SDK, setting up a project with a service account, and obtaining an access token, see the Quickstarts.
The following example shows how to send a request to the text:synthesize
endpoint.
curl \
-H "Authorization: Bearer "$(gcloud auth print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
--data "{
'input':{
'text':'This is a sentence that helps test how audio profiles can change the way Cloud Text-to-Speech sounds.'
},
'voice':{
'languageCode':'en-us',
},
'audioConfig':{
'audioEncoding':'LINEAR16',
'effectsProfileId': ['telephony-class-application']
}
}" "https://texttospeech.googleapis.com/v1beta1/text:synthesize" > audio-profile.txt
If the request is successful, the Text-to-Speech API returns the synthesized audio as base64-encoded data contained in the JSON output. The JSON output in the audio-profiles.txt
file looks like the following:
{
"audioContent": "//NExAASCCIIAAhEAGAAEMW4kAYPnwwIKw/BBTpwTvB+IAxIfghUfW.."
}
To decode the results from the Cloud Text-to-Speech API as an MP3 audio file, run the following command from the same directory as the audio-profiles.txt
file.
sed 's|audioContent| |' < audio-profile.txt > tmp-output.txt && \ tr -d '\n ":{}' < tmp-output.txt > tmp-output-2.txt && \ base64 tmp-output-2.txt --decode > audio-profile.wav && \ rm tmp-output*.txt