Skip to content

Instantly share code, notes, and snippets.

View detj's full-sized avatar
🖥️
deep into work

Debjeet Biswas detj

🖥️
deep into work
View GitHub Profile
@detj
detj / current-git-tag.sh
Created August 31, 2025 16:21
current git tag
#!/usr/bin/env bash
git describe --tags --abbrev=0
@detj
detj / rclone-remote-mount.sh
Created July 27, 2025 19:27
mount a remote S3 compatible bucket with caching with rclone
rclone mount <remote-name>:<bucket-name> <local-dir> \
--daemon \
--devname <device-name> \
--allow-other \
--vfs-cache-mode full \
--vfs-cache-max-size 10G \
--log-level INFO \
--log-file /tmp/rclone-vfs-remote-mount.log
@detj
detj / base64-sha256.sh
Created June 11, 2025 04:08
base64 encoded sha256 hash of text
# "test" is the input
printf "test" | openssl dgst -sha256 -binary | openssl base64
# output - n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=
@detj
detj / brew-list-installed-on-request.sh
Created January 21, 2025 11:40
List brew packages installed by hand
brew list --installed-on-request
@detj
detj / gh-repo-createdAt.sh
Created January 13, 2025 11:10
Get a repo's creation date
# syntax
# gh repo view <repo> --json createdAt
# example
gh repo view measure-sh/measure --json createdAt
@detj
detj / clickhouse-mgmt-queries.sql
Last active October 24, 2024 10:20
ClickHouse Management Queries
--------------
-- query cache
--------------
-- see full details of query cache entries
SELECT
substring(query, 1, 30),
result_size,
tag,
stale,
@detj
detj / agrind-filter.sh
Last active October 23, 2024 23:26
use angle grinder to filter certain log lines
# syntax - assuming a `docker-compose.yml` file is present at $(PWD)
docker compose logs --no-log-prefix -f <compose-service-name> | agrind '(*) AND NOT ("string-one" OR "string-two")'
# example
docker compose logs --no-log-prefix -f my-compose-service | agrind '(*) AND NOT ("ping" OR "traces export")'
# combine angle grinder with tailspin
docker compose logs --no-log-prefix -f my-compose-service | agrind '(*) AND NOT ("ping" OR "traces export")' | tspin -ce
@detj
detj / munge.sh
Last active September 7, 2024 02:44
Munging data on terminal
# Manipulating data by combining various modern terminal utilities like fd, dasel, rg and so on.
# Working with single files. Let's assume there is a `data.json` file with the following contents.
# [
# {
# "id": "some-id-1",
# "attribute": {
# "some-key-1": "some-value-1",
# "some-key-2": "some-value-2",
# "some-key-3": "some-value-3"
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
#!/usr/bin/env bash
# Syntax
# awk '{gsub("\\n", "\n"}; print' <file>
# Example
awk '{gsub("\\n", "\n"}; print' some-file.txt