Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
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
by გიორგი უზნაძე
4 years ago
0
Laravel
0
Place this file within the `scripts` folder within your project. usage
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
by გიორგი უზნაძე
4 years ago
0
Laravel
Linux
0
Javascript get current url
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"
by გიორგი უზნაძე
4 years ago
0
JavaScript
URL
0
You need to use the json_encode constant
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 example
by გიორგი უზნაძე
4 years ago
0
0
Receive root permissions
To receive root permissions, we run the following command
sudo -i
Note: after running the above command, we need to enter the user's password
by Valeri Tandilashvili
4 years ago
0
Linux
0
Copy all files and folders to another directory
Copies all files and folders from
source_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 folder
by Valeri Tandilashvili
4 years ago
0
Linux
1
Basic authentication
Postman request
Authorization type: Basic Auth
Username: usr
Password: pwd
PHP cURL request
curl_setopt($ch, CURLOPT_USERPWD, "usr:pwd");
by Valeri Tandilashvili
4 years ago
0
PHP
Postman
0
http / https
If the URL starts with
https
it will make a request on
443
$ch = curl_init("https://xdatavpn.example.com/Bank");
If it starts with
http
the request will use
80
port
$ch = curl_init("http://xdatavpn.example.com/Bank");
by Valeri Tandilashvili
4 years ago
0
PHP
1
position: 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
by Luka Tatarishvili
4 years ago
0
CSS
HTML
Animation
0
Dinamic scroll
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);
by Luka Tatarishvili
4 years ago
0
CSS
HTML
animation
0
Results: 1578