Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
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 გიორგი უზნაძე
3 years ago
0
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 გიორგი უზნაძე
3 years ago
0
PHP
OOP
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
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
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
number_format
The default
thousands_separator
is
,
which is 4th parameter. Without passing something else for the
thousands_separator
parameter, the
latency
was equal to
1,511.68525
The following PHP code caused problem in MySQL
$this->latency = number_format(microtime(1)-$_SESSION['startTime'], 5);
MySQL error:
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'latency' at row 1
Solution to the problem is to specify the 4th parameter as an empty string
""
to get
latency
equal to
1511.68525
$this->latency = number_format(microtime(1)-$_SESSION['startTime'], 5, '.', '');
by Valeri Tandilashvili
3 years ago
0
PHP
functions
0
1)
var data = {!!json_encode($collection, JSON_UNESCAPED_SLASHES|JSON_HEX_APOS)!!};
2)Or use
@json
directive
var data = @json($collection);
by გიორგი უზნაძე
3 years ago
0
0
Select every Nth row
Selects every 5th row of
sdt_prices
table
SELECT *
FROM ( 
    SELECT @row := @row +1 AS rownum, sdt_prices.*
    FROM (
        SELECT @row :=0) r, sdt_prices where token_id = 1 order by id desc
    ) ranked
WHERE rownum %5 = 1
by Valeri Tandilashvili
3 years ago
0
MySQL
ROWNUM
0
failed to open stream: Permission denied
fopen(/var/www/test.sdtokens.com/storage/app/public/images/mesk.webp): failed to open stream: Permission denied
Solution to the problem is running these commands to get the permissions
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

php artisan storage:link
by Valeri Tandilashvili
3 years ago
0
Linux
0
Install Certbot and it’s Nginx plugin with apt:
sudo apt install certbot python3-certbot-nginx
Verifies the syntax of your configuration edits:
sudo nginx -t
Reload Nginx to load the new configuration:
sudo systemctl reload nginx
To see the current setting of firewall:
sudo ufw status
Allows the Nginx Full profile and delete the redundant Nginx HTTP profile allowance:
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
Obtaining an SSL Certificate
sudo certbot --nginx -d example.com
Verifying Certbot Auto-Renewal:
sudo systemctl status certbot.timer
To test the renewal process, you can do a dry run with
certbot
:
sudo certbot renew --dry-run
by Valeri Tandilashvili
3 years ago
0
Linux
HTTPS
0
Results: 1580