Terms of Reference

TL;DR: Tips and tricks to make your life easier - a quick reference guide for Java, Archiva, Redis, Git, SSH, and Scala.

General purpose reference for some of those technology easter eggs. Help yourself with a quick reference guide and troubleshooting steps.

General Commands

Get Neo4j Version

curl --user "neo4j":"password" http://192.168.x.x:7474/db/manage/server/version

Get IP Details

ip -c a

Clear Kafka Messages

# Enable delete.topic.enable=true at config/server.properties
bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --delete --topic TopicName
bin/kafka-topics.sh --zookeeper localhost:2181 --list

Changing Java Version

# Download JDK
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" \
  http://download.oracle.com/otn/java/jdk/8u152-b16/.../jdk-8u152-linux-x64.tar.gz

# Install
sudo mkdir /opt/jdk
sudo tar -zxf jdk-8u152-linux-x64.tar.gz -C /opt/jdk/

# Configure alternatives
sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_152/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_152/bin/javac 1
sudo update-alternatives --config java

# Verify
java -version

Ubuntu Way

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt install oracle-java8-set-default

Dev Setup

SSH Key Copy

ssh-copy-id admin@192.162.0.1

Cassandra User Setup

CREATE USER 'dbuser' WITH PASSWORD 'password';
GRANT ALL ON KEYSPACE keyspace_name TO 'dbuser';

Cassandra Data Export/Import

-- Export
COPY keyspace.table (col1, col2, col3) TO 'export.csv';

-- Import  
COPY keyspace.table (col1, col2, col3) FROM 'import.csv';

Neo4j Password Change

curl -H "Content-Type: application/json" -X POST \
  -d '{"password":"newpassword"}' \
  -u neo4j:neo4j http://localhost:7474/user/neo4j/password

Git Repository Management

# Change remote URL
git remote set-url origin git@repo.example.com:org/project.git

# Verify
git remote -v

Unix Package Clearance

# Check directory size
du -hs /path/to/directory

# Check disk space
df -h

SSH Tunneling

# Local port forwarding
ssh -L local_port:remote_host:remote_port user@ssh_server

# Example: Forward local 8080 to remote Neo4j
ssh -L 8080:localhost:7474 user@production-server

Redis Password Configuration

# redis.conf
requirepass yourpassword

# Client connection
redis-cli -a yourpassword

Cassandra Tombstones

Tombstones are markers for deleted data. To manage:

# Check tombstone ratio
nodetool cfstats keyspace.table | grep Tombstones

# Force compaction to clear tombstones
nodetool compact keyspace table

Note: Be cautious with gc_grace_seconds settings when dealing with tombstones.

Mac OSX Java Certificates

After OSX upgrade, if Java certificates fail:

# Navigate to Java security folder
cd $JAVA_HOME/lib/security

# Import certificates from system keychain
sudo keytool -importkeystore -srckeystore /System/Library/Keychains/SystemRootCertificates.keychain \
  -destkeystore cacerts -srcstoretype SystemRoots

Install Python and PIP on Mac

# Using Homebrew
brew install python

# Verify
python3 --version
pip3 --version

Git SSH Diffie-Hellman Error

If SSH throws diffie-hellman error:

# Add to ~/.ssh/config
Host git.example.com
  KexAlgorithms +diffie-hellman-group1-sha1

Private Key SSH Access

# Generate key pair
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

# Copy public key to server
ssh-copy-id -i ~/.ssh/id_rsa.pub user@server

# Or manually add to ~/.ssh/authorized_keys on server

This reference guide is updated periodically with new tips and troubleshooting steps.