Shorts
0 articles found
Git – “blame” a deleted line
Solution
If you know the contents of the line:
$ git log -S <string> path/to/file
Get the last n lines in a very large file
Solution
$ echo "$(tail -n path/to/large-file)" > path/to/output-file
Return empty array from aggregate in Prostgres
When you want to avoid NULL for the result of JSONB_AGG and instead you want to get an empty array.
Solution
Use COALESCE and '[]'::JSONB.
SELECT
COALESCE(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', role.id,
'name', role.name
)
) FILTER (WHERE role.id IS NOT NULL),
'[]'::JSONB
) AS "adminRoles",
FROM ...Download or open in new tab S3 files
The request to S3 must contain ResponseContentDisposition with either “view”, when you want to see the file in browser, or “download”, if you want to download it.
s3.getSignedUrlPromise('getObject', {
Bucket,
Key,
ResponseContentDisposition: 'view' || 'download',
});