Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
let TIMES = 1000 * 1000 * 100

console.time("(() => { }) instanceof Function")
for (let i = 0; i < TIMES; i++)
  (() => { }) instanceof Function
console.timeEnd("(() => { }) instanceof Function")

console.time("(async () => { }) instanceof Function")
for (let i = 0; i < TIMES; i++)
  (async () => { }) instanceof Function
console.timeEnd("(async () => { }) instanceof Function")

console.time("(function () { }) instanceof Function")
for (let i = 0; i < TIMES; i++)
  (function () { }) instanceof Function
console.timeEnd("(function () { }) instanceof Function")

console.time("(async function () { }) instanceof Function")
for (let i = 0; i < TIMES; i++)
  (async function () { }) instanceof Function
console.timeEnd("(async function () { }) instanceof Function")

console.time("typeof (() => { }) === 'function'")
for (let i = 0; i < TIMES; i++)
  typeof (() => { }) === 'function'
console.timeEnd("typeof (() => { }) === 'function'")

console.time("typeof (async () => { }) === 'function'")
for (let i = 0; i < TIMES; i++)
  typeof (async () => { }) === 'function'
console.timeEnd("typeof (async () => { }) === 'function'")

console.time("typeof (function () { }) === 'function'")
for (let i = 0; i < TIMES; i++)
  typeof (function () { }) === 'function'
console.timeEnd("typeof (function () { }) === 'function'")

console.time("typeof (async function () { }) === 'function'")
for (let i = 0; i < TIMES; i++)
  typeof (async function () { }) === 'function'
console.timeEnd("typeof (async function () { }) === 'function'")
gives result
(() => { }) instanceof Function: 5490ms
(async () => { }) instanceof Function: 6884ms
(function () { }) instanceof Function: 5408ms
(async function () { }) instanceof Function: 6938ms
typeof (() => { }) === 'function': 1916ms
typeof (async () => { }) === 'function': 1998ms
typeof (function () { }) === 'function': 1976ms
typeof (async function () { }) === 'function': 1972ms
by გიორგი უზნაძე
3 years ago
0
JavaScript
Performance
0
call file_get_content() function with headers
First we create an array with the headers
$opts = [
	"http" => [
		"method" => "GET",
		"header" => 
			"Channel-Name: ".CHANNEL."\r\n" .
			"Authorization: ".AUTHORIZATION."\r\n"
	]
];
// Then we create a stream
$context = stream_context_create($opts);
Then we pass the
$content
to
file_get_contents()
function as the
third
parameter
$result = file_get_contents($url, false, $context);
by Valeri Tandilashvili
3 years ago
0
PHP
functions
1
List cronjobs "crontab -l"
To list all cronjobs we simply run
crontab -l
command Cronjobs will be displayed without edit mode
by Valeri Tandilashvili
3 years ago
0
Linux
Cronjobs
0
Edit cronjobs "crontab -e"
First we open crontab to make changes to jobs by entering
crontab -e
command Then we activate edit mode by clicking
i
letter After editing we need to exit from edit mode by clicking
Esc
button Then we click
:wq
to save the changes
00 21 * * * php /var/www/html/services_cron/job_payments/index.php >> /var/log/job_payments.log 2>&1
By adding the line above, we tell
cronjob
to run the following file every day at
21:00
/var/www/html/services_cron/job_payments/index.php
And write output to the log file
/var/log/job_payments.log
by Valeri Tandilashvili
3 years ago
0
Linux
Cronjobs
0
class A {
    public static function get_self() {
        return new self();
    }

    public static function get_static() {
        return new static();
    }
}

class B extends A {}

echo get_class(B::get_self());  // A
echo get_class(B::get_static()); // B
echo get_class(A::get_self()); // A
echo get_class(A::get_static()); // A
by გიორგი უზნაძე
4 years ago
0
PHP
OOP
0
var controls_string = '{!!json_encode($controls, JSON_HEX_APOS) ?? ""!!}';
controls_string = controls_string.replace(/[\u0000-\u0019]+/g,"");
var controls = JSON.parse(controls_string);
or shorter version
var controls = JSON.parse('{!!json_encode($controls, JSON_HEX_APOS) ?? ""!!}'.replace(/[\u0000-\u0019]+/g,""));
by გიორგი უზნაძე
4 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 გიორგი უზნაძე
4 years ago
0
JavaScript
DOM
script ELEMENT
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 გიორგი უზნაძე
4 years ago
0
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 გიორგი უზნაძე
4 years ago
0
JavaScript
Object
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 გიორგი უზნაძე
4 years ago
0
PHP
0
Results: 1578