Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
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
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
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 გიორგი უზნაძე
3 years ago
0
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 გიორგი უზნაძე
3 years ago
0
JavaScript
URL
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 გიორგი უზნაძე
3 years ago
0
Laravel
Linux
0
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 გიორგი უზნაძე
3 years ago
0
Laravel
0
$context = stream_context_create(
    array(
        "http" => array(
            "header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
        )
    )
);

echo file_get_contents("www.google.com", false, $context);
by გიორგი უზნაძე
3 years ago
0
PHP
0
old way
function shallowClone(obj) {
    var clone = Object.create(Object.getPrototypeOf(obj));

    var props = Object.getOwnPropertyNames(obj);
    props.forEach(function(key) {
        var desc = Object.getOwnPropertyDescriptor(obj, key);
        Object.defineProperty(clone, key, desc);
    });

    return clone;
}
In ES2017
function shallowClone(obj) {
    return Object.create(
        Object.getPrototypeOf(obj), 
        Object.getOwnPropertyDescriptors(obj) 
    );
}
by გიორგი უზნაძე
3 years ago
0
JavaScript
Object
0
Detect tab focus and blur on all browsers and run callbacks
var hidden, visibilityState, visibilityChange;
        
            if (typeof document.hidden !== "undefined") {
                hidden = "hidden", visibilityChange = "visibilitychange", visibilityState = "visibilityState";
            }
            else if (typeof document.mozHidden !== "undefined") {
                hidden = "mozHidden", visibilityChange = "mozvisibilitychange", visibilityState = "mozVisibilityState";
            }
            else if (typeof document.msHidden !== "undefined") {
                hidden = "msHidden", visibilityChange = "msvisibilitychange", visibilityState = "msVisibilityState";
            }
            else if (typeof document.webkitHidden !== "undefined") {
                hidden = "webkitHidden", visibilityChange = "webkitvisibilitychange", visibilityState = "webkitVisibilityState";
            }
        
            document.addEventListener(visibilityChange, function(event){
                switch (document[visibilityState]) {
                    case "visible":
                        // tab is focused
                        break;
                    case "hidden":
                        // tab is blurred 
                        break;
                }
            });
by გიორგი უზნაძე
3 years ago
0
0
This Boolean attribute is set to indicate to a browser that the script is meant to be executed after the document has been parsed, but before firing DOMContentLoaded. Scripts with the defer attribute will prevent the DOMContentLoaded event from firing until the script has loaded and finished evaluating This attribute must not be used if the src attribute is absent (i.e. for inline scripts), in this case it would have no effect.
by გიორგი უზნაძე
3 years ago
0
JavaScript
DOM
script ELEMENT
0
Results: 1580