Author Archives: ronaldpringadi

Using grep as highlighter

1$ grep –color -E ‘^|pattern1|pattern2’ file name

Posted in Bash, Linux | Comments Off on Using grep as highlighter

TCL programming

A reusable expect dispatcher I kept around for running the same kind of operation across a list of servers — untar an index, restart a service, patch a config file. The trick is that the script reads the first command-line … Continue reading

Posted in Linux, TCL/Expect | Comments Off on TCL programming

Simple unit test is bash file

Consider the following 3 files: 1. shellTestFramework.sh 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#!/bin/bash # Copyright (c) Ronald Pringadi # Before each Test function setUpTest(){     #"Please overwrite this function on your unit test. Something that need to be done before each test"     … Continue reading

Posted in Bash | Comments Off on Simple unit test is bash file

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 java | Comments Off on Multithreading in Java using ThreadPoolExecutor

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 java | Comments Off on Getting the caller method details using Java

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 Linux | Comments Off on Compare File Permission Recussively on Linux Directories

Linux find files and total their size

1find ./ -type f -newerct "1 May 2015" ! -newerct "1 Jul 2015" -print0 | du –files0-from=- -hc| tail -n1

Posted in Bash, Linux | Comments Off on Linux find files and total their size

Wireshark filters

Filter by ip dst or source using wildcard on the last 3 digits: (ip.dst == 192.168.0.0/24) || (ip.src == 192.168.0.0/24)

Posted in Linux | Comments Off on Wireshark filters

MSBuild common errors and how to fix them

Building with MSBuild produced an error or warning Run MSBuild with (d)etailed verbose mode and capture the output to a file: 1msbuild someproject.csproj /t:Clean;Build;Transfer /p:OutputPath=bin\autobuild;BuildNumber=-1;Configuration=Debug /v:d >build.txt Open build.txt and search for the MSBxxxx error or warning code. For example: … Continue reading

Posted in C# | Tagged | Comments Off on MSBuild common errors and how to fix them

Allowing a linux/unix user all sudo access without password

/etc/sudoers yourusername ALL=(ALL) NOPASSWD:ALL

Posted in Linux | Tagged , | Comments Off on Allowing a linux/unix user all sudo access without password