Author Archives: ronaldpringadi

MongoDB Notes

If you’re storing binary files inside MongoDB, the convention is called GridFS. It splits each logical file into two collections: a metadata document and a sequence of binary chunks. This post is a cheat sheet for inspecting and tweaking those … Continue reading

Posted in Database | Leave a comment

CentOS 6 repo Settings

To fix repo settings in CentOS 6 1. make sure there is no proxy or funny settings in vi /etc/yum.conf 2. There are a couple of files within /etc/yum.repos.d/. Make sure the url are correct (accessible) and enabled=1 ll /etc/yum.repos.d/ … Continue reading

Posted in Linux | Leave a comment

Show Linux Partition Tree Mountpoint and If SSD

1lsblk -o TYPE,NAME,KNAME,UUID,MOUNTPOINT,SIZE,ROTA

Posted in Linux | Leave a comment

Setting log4j log level programmatically

Sometimes you don’t want to ship a log4j.properties file — you want to spin up logging in code. Useful inside unit tests, one-off debug runs, or anywhere you want to flip log levels at runtime. Here’s a self-contained setupLog4j() that … Continue reading

Posted in java | Leave a comment

Print java stack trace from anywhere

Need to know which code calls a specific location? Dump the stack trace: 1234import org.apache.commons.lang3.exception.ExceptionUtils; // …somewhere in your method: LOG.trace(ExceptionUtils.getStackTrace(new Throwable())); You’re constructing a Throwable just to capture the current stack — you’re not throwing it. ExceptionUtils.getStackTrace turns the … Continue reading

Posted in java | Leave a comment

Knowing your exception class name

You’re staring at a generic catch (Exception e) and you don’t know which actual exception is being thrown. The trick is to log the runtime class so you can replace the generic catch with a specific one: 12345} catch (Exception … Continue reading

Posted in java | Tagged | Leave a comment

SELinux directory permission

To check SELinux directory permission you need to -z for example 1ls -Z /var/www/html If something is incorrect you can re-adjust some of the directory permission: 1chcon -R -t httpd_sys_content_t /var/www/html

Posted in Linux, Operating System | Leave a comment

RedHat / Centos Firewall

To add an exception to firewall In RedHat/CentOS 6 12345iptables –line -vnL iptables -A INPUT -p tcp –dport 80 -m state –state NEW,ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 192.168.0.0/16 -j ACCEPT iptables -D INPUT -p tcp -s … Continue reading

Posted in Linux, Operating System | Leave a comment

Bash string comparison

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465#!/bin/bash function test(){ echo "" echo "TEST $1" echo "VAR_1: $VAR_1 VAR_2: $VAR_2 " if [ "$VAR_1" = "false" ]; then echo " VAR_1 is false"; fi if [ "$VAR_2" = "false" ]; then echo " VAR_2 is false"; fi … Continue reading

Posted in Bash, Linux | Leave a comment

Show postgres lock

You’re staring at a query that won’t finish, or a deploy that hangs on a migration, or a UI request that just sits there. Postgres is almost certainly waiting on a lock that another transaction holds. The classic query for … Continue reading

Posted in Database, PostgreSQL | Leave a comment