-
Archives
- March 2019
- March 2018
- June 2017
- May 2017
- November 2016
- September 2016
- July 2016
- June 2016
- May 2016
- April 2016
- March 2016
- February 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- April 2015
- December 2014
- October 2014
- September 2014
- May 2014
- April 2014
- March 2014
- January 2014
- November 2013
- October 2013
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
-
Meta
Category Archives: Uncategorized
MongoDB Notes
When using MongoDB to store files, we have 2 collections: 1. The place where MongoDB store the file metadata: store.files 2. Ans place where MongoDB store the file content: store.chunks Depending on the size of the file, one entry in … Continue reading
Posted in Uncategorized
Leave a comment
Assorted postgres queries
Get table sizes: SELECT relname AS objectname, relkind AS objecttype, reltuples AS “#entries”, pg_size_pretty(relpages::bigint*8*1024) AS size FROM pg_class WHERE relpages >= 8 ORDER BY relpages DESC;
Posted in Uncategorized
Leave a comment
VirtualBox – Imporving usability on guest OS
GUEST OS: Centos 6.7 final HOST OS: Windows 7 Virtualbox version: 5.0.4 1yum install gcc kernel-devel kernel-headers dkms make bzip2 perl
Posted in Uncategorized
Leave a comment
RedHat or CentOS 6 iptables adding an open port
iptables –line -vnL iptables -I INPUT 5 -p tcp –dport 80 -m state –state NEW,ESTABLISHED -j ACCEPT service iptables save
Posted in Uncategorized
Leave a comment
Ant Junit debugging
Sometime we want to debug why ant build failed when executing a certain JUnit Make sure your ant junit task look like the following 1234<junit printsummary="withOutAndErr" haltonfailure="yes"> : : </junit> and not like 1234<junit printsummary="yes" haltonfailure="yes"> : : </junit>
Posted in Uncategorized
Leave a comment
Using grep as highlighter
1$ grep –color -E ‘^|pattern1|pattern2’ file name
Posted in Uncategorized
Leave a comment
TCL programming
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186#!/usr/bin/expect -f # TCL script. Beware whitespace matter! # To set multi-line comments do the following # set comment { # your multi-line comment # } # ################################################### # ALL functions Start # ################################################### if {[llength $argv] == … Continue reading
Posted in Uncategorized
Leave a comment
Multithreading in Java using ThreadPoolExecutor
ThreadWorker is your custom class. 123456789try { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(MAX_THREAD_SIZE); for (int i = 1; i Random randomGenerator = new Random(); executor.submit(new ThreadWorker("worker" + i, randomGenerator.nextInt(10))); LOG.info(i); } } catch (Exception e) { LOG.error("Hmm something is not right.", … Continue reading
Posted in Uncategorized
Leave a comment
Getting the caller method details using Java
12345678910 public static String getCallerClassName() { StackTraceElement[] stElements = Thread.currentThread().getStackTrace(); for (int i=1; i<stElements.length; i++) { StackTraceElement ste = stElements[i]; if … Continue reading
Posted in Uncategorized
Leave a comment
Compare File Permission Recussively on Linux Directories
Scan 12345678910111213141516171819202122#!/usr/bin/perl use File::Find; my $directory1 = ‘/root/rpmbuild/RPMSX’; my $directory2 = ‘/root/rpmbuild/RPMSX.bak’; find(\&hashfiles, $directory1); sub hashfiles { my $file1 = $File::Find::name; (my $file2 = $file1) =~ s/^$directory1/$directory2/; return(0) if (! -f $file2) ; … Continue reading
Posted in Uncategorized
Leave a comment