Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
Example provoking a corrupt image to be download in a controller 4
public function downloadImage($post_id) {
    $post = Post::find($post_id);
    $file = public_path()."/uploads/Koala.jpg";
    $headers = array('Content-Type' => ' image/jpeg');
    return Response::download($file,'Koala.jpg',$headers);
}
If I remove the first line of the function it works. The only way I found to fix this issue was to modify the code this way:
public function downloadImage($post_id) {
    $post = Post::find($post_id);
    $file = public_path()."/uploads/Koala.jpg";
    $headers = array('Content-Type' => ' image/jpeg');
    $response = Response::download($file,'Koala.jpg',$headers);
    ob_end_clean();
    return $response;
}
by გიორგი უზნაძე
3 years ago
0
Laravel
PHP
Download
File
Images
0
Comparing two double numbers
The following code executes the
else
statement because the
float
numbers are different
if (strval(0.000000000035436064) == strval(0.000000000035436064000001)) {
    echo 'if';
} else {
    echo 'else';
}
But if we add one
0
in front of the last digit of the second number, then
if
statement will be executed
if (strval(0.000000000035436064) == strval(0.0000000000354360640000001)) {
    echo 'if';
} else {
    echo 'else';
}
Note:
The above code is one of the best solutions to compare float numbers
by Valeri Tandilashvili
3 years ago
0
PHP
1
Export all table except ...
Exports all table from
dbname
except the two table:
table1
and
table2
mysqldump -u root -p --ignore-table=dbname.table1 --ignore-table=dbname.table2 dbname > dbname.sql
by Valeri Tandilashvili
3 years ago
0
Linux
MySQL
0
Show table sizes
Shows all the tables with their sizes in MB with descending order
SELECT 
    table_name AS `Table`, 
    round(((data_length + index_length) / 1024 / 1024), 2) AS MB_size 
FROM information_schema.TABLES 
WHERE table_schema = "database_name"
order by MB_size desc
by Valeri Tandilashvili
3 years ago
0
MySQL
1
Error log file address
Error log file location:
/var/www/website.com/storage/logs/laravel.log
by Valeri Tandilashvili
3 years ago
0
Laravel
0
Make javascript array unique
var arr = [55, 44, 65,1,2,3,3,34,5];
var unique = [...new Set(arr)]
by Luka Tatarishvili
3 years ago
0
JavaScript
array
1
$str_time = "23:12:95";

$str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time);

sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);

$time_seconds = $hours * 3600 + $minutes * 60 + $seconds;
And if you don't want to use regular expressions:
$str_time = "2:50";

sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);

$time_seconds = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
by გიორგი უზნაძე
3 years ago
0
PHP
Date
Regexp
2
File & folder sizes
Shows files and folders with their sizes in the current directory
du -h --max-depth=1
by Valeri Tandilashvili
3 years ago
0
Linux
0
Delete binary logs
Deletes binary logs created before the specified date
purge binary logs before ‘2022-03-03’;
by Valeri Tandilashvili
3 years ago
0
MySQL
0
UNIQUE several columns combined
Columns
token_id
and
base_price_pair
combined will be in the table
ALTER TABLE sdtokens.sdt_prices_unique
ADD UNIQUE (token_id, base_price_pair);
by Valeri Tandilashvili
3 years ago
0
MySQL
1
Results: 1578