composer require symfony/process
-----------------analyse_string.py---------------------
# analyse_string.py
#!/usr/bin/python
import sys
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyser = SentimentIntensityAnalyzer()
print(str(analyser.polarity_scores(sys.argv[1])))
-------------------------- Laravel Code---------------------------
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
$text = 'The text you are desperate to analyze :)";
$process = new Process("python3 /Path/To/analyse_string.py \"{$text}\"");
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
// Result (string): {'neg': 0.204, 'neu': 0.531, 'pos': 0.265, 'compound': 0.1779}
You can also pass array to python using json string
$process = new Process("python3 /Path/To/analyse_json.py {$json}");
and inside python retrieve it like this
x=sys.argv[1]
data=json.loads(x)
for item in data:
#do whatever u want
bash /root/path/scripts/laravel_path_permissions.sh
set -e
set -x
# DETERMINE THE PROJECT BASE PATH ASSUMING THIS SCRIPT WAS
# STORED WITHIN THE /project_root_directory/scripts
BASE_PATH="$(dirname -- $(cd -P -- "$(dirname -- "$0")" && pwd -P))"
LOG_FILE="$BASE_PATH/storage/logs/laravel.log"
if [ ! -f ${LOG_FILE} ]; then
echo "CREATING LOG FILE: storage/logs/laravel.log "
touch ${LOG_FILE}
echo "SETTING LOG FILE PERMISSIONS:"
sudo chmod 665 ${LOG_FILE}
sudo chown $USER:www-data ${LOG_FILE}
echo "SETTING LOG FILE PERMISSIONS OK!"
else
echo "LOG_FILE ALREADY SETUP!"
fi
if [[ ! -d $BASE_PATH/vendor && -d $BASE_PATH/bootstrap && -d $BASE_PATH/storage ]]; then
echo "DEFINE THE WRITABLE AND EXECUTABLE PERMISSION FOR THE WEBSERVER OWNER AND GROUP ..."
sudo chmod 775 $BASE_PATH/bootstrap/cache
sudo chmod 775 $BASE_PATH/storage/framework/cache
sudo chmod 775 $BASE_PATH/storage/framework/cache/data
sudo chmod 775 $BASE_PATH/storage/framework/sessions
sudo chmod 775 $BASE_PATH/storage/framework/views
sudo chmod 775 $BASE_PATH/storage/logs
echo "CHANGE THE PERMISSIONS GROUP FOR THE WEBSERVER USER ..."
sudo chgrp www-data $BASE_PATH/bootstrap/cache
sudo chgrp www-data $BASE_PATH/storage/framework/cache
sudo chgrp www-data $BASE_PATH/storage/framework/cache/data
sudo chgrp www-data $BASE_PATH/storage/framework/sessions
sudo chgrp $USER $BASE_PATH/storage/framework/views
sudo chgrp www-data $BASE_PATH/storage/logs
echo "PERMISSIONS DONE!"
else
echo "PERMISSIONS ALREADY SETUP!"
fi
window.location.hash: "#2"
window.location.host: "localhost:4200"
window.location.hostname: "localhost"
window.location.href: "http://localhost:4200/landing?query=1#2"
window.location.origin: "http://localhost:4200"
window.location.pathname: "/landing"
window.location.port: "4200"
window.location.protocol: "http:"
window.location.search: "?query=1"
JSON_HEX_APOS
as the second parameter which will convert all single quotes '
to \u0027
. :
var t = <?php echo json_encode($data, JSON_HEX_APOS);?>;
Then use encode ()
and decode ()
javascript functions to convert the text from each array entry back to readable text like this examplesource_dir
to destination_dir
cp -r /home/user/source_dir/. /var/www/html/destination_dir/
-r
- copies recursively (with subfolders and files)
.
- copies all files and folders inside the folderposition: fixed
always fixates an element to some position within its scrolling container. no matter how you scroll its container..
position: sticky
basically acts like position: relative
until an element is scrolled beyond a specific offset, in which case it turns into position: fixed
html {
scroll-behavior: smooth;
}
The scroll-behavior CSS property sets the behavior for a scrolling box
As default it's auto
but if we use scroll-behavior: smooth; the scroll will be animated and smooth.
In HTML
<div class="main" id="section1">
<h2>Section 1</h2>
<a href="#section2">Click Me to Smooth Scroll to Section 2 Below</a>
</div>
Div's must have specified id="someid"
which will be passed in a href attribute.
<a href="#someid">1</a>
With Jquery we can make it more manageable. We can specify exact pixels and positions.
let id = $(this).closest('li').attr('id');
$('html, body').animate({
scrollTop: $('div#section-content-'+id).offset().top - 200
}, 1000);