Commands used in personal/professional Experience
Java
JShell
Multiple dependencies using maven local repos, use JAR files : (colon) separated
jshell --class-path ./jackson-databind-2.12.4.jar:./jackson-core-2.12.4.jar:./jackson-annotations-2.12.4.jar
JVM Arguments
Hibernate enable SQL generation/logging
-Dspring.jpa.show-sql=true \
-Dspring.jpa.properties.hibernate.format_sql=true \
-Dlogging.level.org.hibernate.SQL=DEBUG \
-Dlogging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
Golang
Tests
Test Coverage display on UI
go tool cover -html=cover.out
go get
To add a dependency for a package or upgrade it to its latest version:
go get example.com/pkg
To upgrade or downgrade a package to a specific version:
go get example.com/pkg@v1.2.3
To remove a dependency on a module and downgrade modules that require it:
go get example.com/mod@none
Go - Misc
AI-generated
# Format and vet every package in the module.
go fmt ./...
go vet ./...
# Explain why a package is in the module graph.
go mod why example.com/module
# Remove unused requirements and add missing ones.
go mod tidy
# List available updates without changing go.mod.
go list -m -u all
Makefile
AI-generated
Keep targets small, declare non-file targets as phony, and use the same commands locally and in CI.
.PHONY: fmt lint test build
fmt:
go fmt ./...
lint:
go vet ./...
test:
go test -race ./...
build:
go build ./...
Recipe lines must begin with a tab unless the Makefile changes .RECIPEPREFIX.
Databases / SQL
MS SQL Server
Running procedure
SELECT
object_name(st.objectid) as ProcName
FROM
sys.dm_exec_connections as qs
CROSS APPLY sys.dm_exec_sql_text(qs.most_recent_sql_handle) st
WHERE
object_name(st.objectid) is not null;
Currently Running queries
SELECT sqltext.TEXT,
req.session_id,
req.status,
req.start_time,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext;
PostgreSQL
random number b/w a and b (inclusive):
select floor(random()*(b-a+1)) + a;
Git
Remove files from remote after adding in .gitignore:
git rm -r --cached .
Then git add, commit and push
Delete all untracked files:
git ls-files -z -o --exclude-standard | xargs -0 rm
Removing staged files:
git reset file
Unix Commands
Process stats
top -p <pid>
top -i
Run a shell as another user:
sudo -u <username> -s
Filesystem and directory disk usage:
df -h
du -sh <directory>
Networking
Get open ports where applications are listening
netstat -ap tcp | grep -i "listen"
lsof -Pn -i4
lsof -Pn -i4 | grep LISTEN
sudo lsof -PiTCP -sTCP:LISTEN
All services listening on ports
netstat -tunlp
Local DNS
/etc/hosts
AWK
less image-processing.log | sed -E -e "s/Img//g" | awk '{print $6".jpeg"}' | xargs -I '{}' sudo mv ./tmp/{} ./temp-images/
less nginx_access.log | sed -E -e "s/(\?|\&)([^=]+)\=([^&]+)//g" | awk '{print $2 "\t" $10}' | sort -k1n
less nginx_access.log | grep status=502 | sed -E -e "s/(\?|\&)([^=]+)\=([^&]+)//g" | awk '{arr[$10]++}END{for(a in arr) print arr[a], "\t" a}' | sort -k1n
Command fragments explained
AI-generated
sort -k1,1nsorts numerically by only the first field.-k1nstarts at the first field but does not explicitly end there.xargs -I '{}' command '{}'replaces each{}incommandwith one input line. Quote the placeholder when filenames may contain spaces.sed -E -e 'expression'enables extended regular expressions and supplies one editing expression.- In
awk,arr[key]++counts occurrences. AnEND { ... }block runs once after all input has been consumed and is a convenient place to print totals.
Prefer null-delimited filenames (find ... -print0 | xargs -0 ...) when names can
contain spaces or newlines.
Nginx
nginx -s reload|reopen|quit|stop
conf files with server specifications: /etc/nginx/sites-available/*.conf
/etc/nginx/sites-enabled/<---->
HDFS
hadoop fs <command>
Grepping across multiple files in HDFS
Recursive LS on a directory
- GREP files
- capture/awk file names (after 8th char)
- get 1 input
- use caret to be replaced by input
- 10 multiple processes
- execute bash script for hadoop fs -cat
Impl:
hadoop fs -ls -R /user/asdacd_account/feedFiles/2019/08/ | grep .csv | awk '{print $8}' | \
xargs -n 1 -I ^ -P 10 bash -c \
"hadoop fs -cat ^ | grep -q 961412 && echo ^"
Kafka Debugging
To find the last 10 records
kafkacat \
-b <bootstrap-servers> \
-G lpv-kafkacat-consumer \
-t asda-storeinventory \
-o -10 \
-C \
-f '\nKey (%K bytes): %k\t\nValue (%S bytes): %s\nTimestamp: %T\tPartition: %p\tOffset: %o\n--\n'
To find the latest offset in a topic
kafka-run-class kafka.tools.GetOffsetShell \
--broker-list <bootstrap-servers> \
--topic asda-recipes-etl --time -1 \
| awk -F ":" '{sum += $3} END {print sum}'
To find earliest offset in a topic
kafka-run-class kafka.tools.GetOffsetShell \
--broker-list <bootstrap-servers> \
--topic asda-recipes-etl \
--time -2 \
| awk -F ":" '{sum += $3} END {print sum}'
To find offset of topic at a particular epoch-time
kafka-run-class kafka.tools.GetOffsetShell \
--broker-list <bootstrap-servers> \
--topic ukgr-recipe-hearst-etl-prod \
--time 1583298000000
Scala
Scala reading from a file:
val source: String = Source.fromFile("/Users/lpv/Desktop/categoryHierarchy.json")(Codec.UTF8).getLines.mkString
Sonatype
Reliability note
AI-generated
Manual review
The publishing steps below describe the legacy OSSRH/Jira/staging workflow. Maven Central ended support for the legacy deployment protocol on June 30, 2025. Keep this section only as historical context; verify any real release against the current Central Publisher Portal documentation.
Current publishing direction
AI-generated
- Create an account at the Central Publisher Portal.
- Verify the namespace used by the artifact coordinates.
- Sign release artifacts and provide the required POM metadata.
- Use a current Maven- or Gradle-compatible Central publishing plugin.
- Upload, validate, and publish a deployment through the portal or its API.
Source: Maven Central publishing guide.
Create sonatype account
- Same passwords for
issues.sonatype.org(JIRA),oss.sonatype.org,central.sonatype.org - Raise a jira request to open a repository.
- They will ask you to verify a domain/groupid.
Signing
- Create key using “gpg” and save passphrase.
gpg --list-secret-keys
- Set short code (last 8 chars of key), passphrase, secret ring file path in gradle’s global properties (set in maven is using maven)
- Distribute it to “central keystores” (ubuntu, etc.)
gpg --keyserver hkp://pool.sks-keyservers.net --send-keys <key last 8 chars are fine>gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys <key>
- Generate a secret key
gpg --export-secret-keys >~/.gnupg/secring.gpg
Publish
- Use gradle’s
maven-publishor some other plugin for maven if using maven. - Don’t forget to add credentials to
buildscript(publishscript)
Sonatype release
- “close” published sonatype
"staging"repo, you can check the content. - Release it.
- If first release (promote), comment on the jira ticket.