Thursday, December 29, 2016

Dummy Email Server For Developers

Dummy Email Servers for Developers, Testers for Testing purpose </br>
These test emails will not go outside the network, but provide basic functionality for testing purpose.
I have tested PaperCut and FakeSMTP Server, both are working fine.


FakeSMTP Server

Wednesday, November 2, 2016

Metadata from mp3 files, Apache TIKA

Today's Discussion: Get Metadata ()Artist, Album, Creator) from MP3 files for Android Music Player

This Java program will retrieve all mp3 files from the given directory (inside nested directories or files) and display Album, Artist, 
Creator etc metadata (tags). The same can be used in sorting and display in Android Music Player for playing mp3 files. The same program 
will list out if there are Duplicate Files too in other directories. This uses "Apache Tika" Framework. 
Apache TIKA is used for:  Language detection mechanism and MIME detection mechanism. So it requires input as video (mp4, mkv etc), 
audio (mp3), pdf. It provides parser libraries which parses the input files and provides Metadata Extracts like:

mp3: Artist, Album, Title, Name, Creator etc.
mp4: FileTypes
pdf: Language (ge- german) etc.

package dmodi.mp3;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

//Jars required: tika-core-1.3.jar, tika-parsers-1.3.jar
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.Parser;
import org.apache.tika.parser.mp3.Mp3Parser;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.DefaultHandler;

public class DEMO_AudioParser {
    static String temp="";
    static int fileCount=1;
    static String fileLocation = "E:\\Personal\\Audio Songs";  //Provide your directory location
    static Set<String> albumSet = new HashSet<String>();
    static Map<String, Integer> fileMap = new HashMap<String, Integer>();

    public static void main(String[] args) {
        File folder = new File(fileLocation);

    public static void listFilesForFolder(final File folder) {
        String fileName = "";
        String albumName = "";

        InputStream input = null;
        ContentHandler handler = new DefaultHandler();
        Metadata metadata = new Metadata();
        Parser parser = new Mp3Parser();
        ParseContext parseCtx=new ParseContext();

        for (final File fileEntry : folder.listFiles()) {  //File[] listOfFiles = folder.listFiles();
            if (fileEntry.isDirectory()) {
                //System.out.println("*************Reading files under the Directory: "+fileEntry);
            } else {
                if(fileEntry.isFile()) {
                    temp = fileEntry.getName();
                    if((temp.substring(temp.lastIndexOf('.') + 1, temp.length()).toLowerCase()).equals("mp3")) {  //Will take only mp3 files
                        fileName = fileEntry.getName();
                        if(fileMap.containsKey(fileName)){   //Duplicate File Check
                            fileMap.put(fileName, fileMap.get(fileName)+1);
                            System.out.println("Duplicate folder: "+fileEntry+", fileName: "+fileName);
                            fileMap.put(fileName, 1);

                        try {
                            input = new FileInputStream(fileEntry);
                            parser.parse(input, handler, metadata, parseCtx);

                            /*String[] metadataNames = metadata.names();
                            for(String name : metadataNames){
                                System.out.println(name + ": " + metadata.get(name));  //audioCompressor, releaseDate, title, author, album, creator, audio/mpeg etc.
                            albumName = metadata.get("xmpDM:album");    //This you can get from above metadata for loop
                                albumName = albumName.trim();
                            System.out.println("FileName: "+fileEntry+", Album : "+albumName+", Count: "+fileCount);
                        catch(Exception e){
                            System.out.println("ERROR: fileName: "+fileName);

//Sample output:
FileName: E:\Personal\Audio Songs\MixSongs5\Kaddu Kaddu.mp3, Album : title, Count: 1
FileName: E:\Personal\Audio Songs\MixSongs5\Kagaz Ki Kashti.mp3, Album : Unknown Album (9/17/2005 10:26:39 PM), Count: 2
FileName: E:\Personal\Audio Songs\MixSongs5\KAHIN DEP JALE.mp3, Album : null, Count: 3
FileName: E:\Personal\Audio Songs\MixSongs5\Khalbali (Papuyaar[1].com).mp3, Album : Rang De Basanti @, Count: 4
FileName: E:\Personal\Audio Songs\MixSongs5\khamoshi3(, Album : Khamoshi, Count: 5
FileName: E:\Personal\Audio Songs\MixSongs5\khattameetha01(, Album : Khatta Meetha, Count: 6


Tuesday, September 27, 2016

Android Applications: Contacts, Calculator, Email App

Android DEMO_Contact App
DEMO_Contact App

Android DEMO_Calculator App
DEMO_Calculator App

Android Email App
DEMO_Email App


Tuesday, September 6, 2016

Change Date in Ubuntu

Change Date in Ubuntu:
root@XXX:/home/dmodi# sudo date --set="2016-09-06 15:02:30"
Tue Sep 6 15:02:30 IST 2016

Monday, August 22, 2016

JBOSS Security Password Generator

Ever struggling to generate Encrypted password using JBOSS Security Login Module ??
Here is how you can do it, go to JBOSS_INSTALLATION directory.

Run below command in Unix (some jars are required, locate that and give proper path in below command):
dmodi__Jboss$ java -cp ./DEPLOY_NAME/lib/jboss-common.jar:./DEPLOY_NAME/lib/jboss-jca.jar:./DEPLOY_NAME/lib/jbosssx.jar PASSWORD
Encoded password: 5f78dc15b9a559cbdf8592078de921bc

//That's it. You are done with. But do you see any problem here, yes people KNOW what is PASSWORD, when you set this in PRODUCTION environment, where many people were present.
To hide that, you need to write a Shell Script, assume file name is ""

echo "Enter Password to Encrypt for followed by Enter:"
stty -echo
read pass
stty echo
java -cp ./DEPLOY_NAME/lib/jboss-common.jar:./DEPLOY_NAME/lib/jboss-jca.jar:./DEPLOY_NAME/lib/jbosssx.jar $pass
echo 'Done'

//EXIT now=>   :wq

Run Now:

dmodi__Jboss$    sh
Enter Password to Encrypt for followed by Enter:   ( I entered same PASSWORD, but it will not be visible in console)
Encoded password: 5f78dc15b9a559cbdf8592078de921bc

//Now this password you need to put into Databse security Domain files. That you can see in many links. 
For reference:

Thursday, August 4, 2016

Search a string in a file or recursively in a directory in windows. For Unix, shell scripting is awesome but windows
we always curse Microsoft. But we too have command prompt too.

Below program will search a string in a directory (all files recursively). Copy the code in a file called "LogSearch.bat".
And run as below, this will give all the file names where WARNING_MESSAGE is present.

LogSearch.bat WARNING_MESSAGE D:\server_logs\

@echo off
echo 'Enter_String_To_Search Directory_Name_To_Search'
set arg1=%1
set arg2=%2
pushd %arg2%
findstr /s /m %arg1% *