mutt is a terminal-based e-mail client for Unix-like systems . For more info read this
==> install mutt as
$ sudo apt-get install mutt
==> Edit .muttrc file in home directory
$vi ~/.muttrc
## and paste the below contents and edit the necessary .
set imap_user="USER@GMAIL_APPS_DOMAIN" ##anmoldeep0123
set imap_pass="PASSWORD"
set ssl_force_tls=yes
set smtp_url="smtp://USER@GMAIL_APPS_DOMAIN@smtp.gmail.com:587/"
##set smtp_url="smtp://anmoldeep0123@smtp.gmail.com:587/"
set smtp_pass="PASSWORD"
set folder="imaps://imap.gmail.com:993"
set spoolfile="+INBOX"
set imap_check_subscribed
set hostname=gmail.com
set mail_check=120
set timeout=300
set record="+[Gmail]/Sent Mail"
set postponed="+[Gmail]/Drafts"
set beep=no
set realname="YOUR NAME"
set from="USER@GMAIL_APPS_DOMAIN" ##anmoldeep0123@gmail.com
set use_from=yes
set use_envelope_from=yes
set sort=threads
set arrow_cursor
set header_cache=~/.mail/cache/headers
set message_cachedir=~/.mail/cache/bodies
set certificate_file=~/.mail/certificates
set implicit_autoview
auto_view text/html
set mailcap_path="~/.mailcap"
bind index ' ' next-page
bind index '-' previous-page
bind index c mail
bind index g change-folder
bind index x sync-mailbox
bind pager ' ' next-page
bind pager '-' previous-page
bind pager c mail
bind pager g change-folder
color index blue default "~C USER" # to or cc USER
color index red default ~D # deleted
color index green default ~U # unread
color index yellow default ~T # tagged
color indicator black yellow
color message black red
color quoted1 cyan black
color quoted2 yellow black
color quoted3 red black
color quoted4 green black
color quoted5 blue black
color quoted6 green black
color signature blue black
color status blue black
color tree cyan black
==> Run mutt
$mutt
Saturday, August 29, 2015
Wednesday, August 26, 2015
Morphia FAQ's helper links etc
JavaDoc
MongoDB javaDoc
Reference
http://www.javabeat.net/using-morphia-java-library-for-mongodb/
https://dzone.com/articles/using-morphia-map-java-objects
http://sleeplessinslc.blogspot.in/2010/10/mongodb-with-morphia-example.html
MongoDB javaDoc
Reference
http://www.javabeat.net/using-morphia-java-library-for-mongodb/
https://dzone.com/articles/using-morphia-map-java-objects
http://sleeplessinslc.blogspot.in/2010/10/mongodb-with-morphia-example.html
Wednesday, July 15, 2015
URL based class loading in Java and dynamically adding directories to java classpath @ runtime
1. How to load a class dynamically at runtime by using URLClassLoader .
// Main Method
try {
URL url = new URL("file:///<path to my jar file>.jar");
URLClassLoader urlClassLoader = new URLClassLoader(
new URL[] { url });
Class clazz = urlClassLoader
.loadClass("org.sample.package.ClassName");
Object obj = clazz.newInstance();
System.out.println(obj.toString());
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
Explanation:
Create a URL object of the jar file
Pass the URL object to the URLClassLoader
Call loadCLass on the URLClassLoader object , specifying the class name with the package hierarchy , as argument.
Create a new Instance of the loadedClass
Refer to newInstance()for more details.
Use the obj of the loaded class to call a method.
Exceptions to be handled:
IllegalAccessException - if the class or its nullary constructor is not accessible.
InstantiationException - if this Class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
ClassNotFoundException - If the class was not found
MalformedURLException - if an unknown protocol is specified.
###########################################
2. How to dynamically add directories from a fileSystem to Java ClassPath @ Runtime
// Main Method
try {
File file = new File("absolute/path/to/the/directory");
Method method = URLClassLoader.class.getDeclared
Method("addURL", new Class[] { URL.class});
method.setAccessible(true);
method.invoke(ClassLoader.getSystemClassLoader(),
new Object[] { file.toURI().toURL() });
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
Explanation:
Create a file object for the directory to be added to the classpath.
Get the method object of addUrl method of the class URLClassLoader
For more details see this.
Reflected object should suppress Java language access Checking when it is used , hence the setAccessible(true).
Invoke the method , the first argument is the class invoking the method and the following arguments are sent as arguments to the invoked method in orderly fashion.
Exceptions to be handled:
NoSuchMethodException - if a matching method is not found.
SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
Refer this
MalformedURLException - if an unknown protocol is specified.
// Main Method
try {
URL url = new URL("file:///<path to my jar file>.jar");
URLClassLoader urlClassLoader = new URLClassLoader(
new URL[] { url });
Class clazz = urlClassLoader
.loadClass("org.sample.package.ClassName");
Object obj = clazz.newInstance();
System.out.println(obj.toString());
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
Explanation:
Create a URL object of the jar file
Pass the URL object to the URLClassLoader
Call loadCLass on the URLClassLoader object , specifying the class name with the package hierarchy , as argument.
Create a new Instance of the loadedClass
Refer to newInstance()for more details.
Use the obj of the loaded class to call a method.
IllegalAccessException - if the class or its nullary constructor is not accessible.
InstantiationException - if this Class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
ClassNotFoundException - If the class was not found
MalformedURLException - if an unknown protocol is specified.
###########################################
2. How to dynamically add directories from a fileSystem to Java ClassPath @ Runtime
// Main Method
try {
File file = new File("absolute/path/to/the/directory");
Method method = URLClassLoader.class.getDeclared
Method("addURL", new Class[] { URL.class});
method.setAccessible(true);
method.invoke(ClassLoader.getSystemClassLoader(),
new Object[] { file.toURI().toURL() });
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
Explanation:
Create a file object for the directory to be added to the classpath.
Get the method object of addUrl method of the class URLClassLoader
For more details see this.
Reflected object should suppress Java language access Checking when it is used , hence the setAccessible(true).
Invoke the method , the first argument is the class invoking the method and the following arguments are sent as arguments to the invoked method in orderly fashion.
Exceptions to be handled:
NoSuchMethodException - if a matching method is not found.
SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
Refer this
MalformedURLException - if an unknown protocol is specified.
I hope you learned something new today .
Saturday, July 11, 2015
How to install Sublime text editor using apt-get on Linux using PPA
Sublime Text is one of the most popular editors and my favorite for writing computer Programs in various languages . Now if you are windows user , its not pretty difficult to download and install this editor simply click here and download the required version and install.
Also this link can help you download the Linux binaries but guess what you are not the unzip candidate who wants to keep binaries in a directory and add that to you unix / linux PATH . You are the apt-get guy .
So what to do then , simply follow these steps
So what to do then , simply follow these steps
### add sublime ppa to repository ###
sudo add-apt-repository ppa:webupd8team/sublime-text-2
Repository maintained by webupd8 team.
### update ###
sudo apt-get update
### install ###
sudo apt-get install sublime-text
### check installed version ###
anmol@anmol-Studio-1555:~/sw$ sublime-text -v
Sublime Text 2 Build 2221
Enjoy
Also this link can help you download the Linux binaries but guess what you are not the unzip candidate who wants to keep binaries in a directory and add that to you unix / linux PATH . You are the apt-get guy .
So what to do then , simply follow these steps
So what to do then , simply follow these steps
### add sublime ppa to repository ###
sudo add-apt-repository ppa:webupd8team/sublime-text-2
Repository maintained by webupd8 team.
### update ###
sudo apt-get update
### install ###
sudo apt-get install sublime-text
### check installed version ###
anmol@anmol-Studio-1555:~/sw$ sublime-text -v
Sublime Text 2 Build 2221
Enjoy
How to install / upgrade to JAVA 8 (JDK 8u45) on Ubuntu & LinuxMint using PPA
Oracle JAVA 8 Stable release has been released on Mar,18 2014 and can be downloaded and installed from Oracle Java downloads . Oracle Java PPA for Ubuntu and LinuxMint is being maintained by WebUpd8 .
Read about the new features about Java 8 here .
This article will help you to Install Oracle JAVA 8 (JDK/JRE 8u25) on Ubuntu 14.04 LTS, 12.04 LTS and 10.04 and LinuxMint systems using PPA File.
Installing Java 8 on Ubuntu
Add the webupd8team Java PPA repository in your system and install Oracle Java 8 using following set of commands.
anmol@anmol-Studio-1555:~$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Configuring Java Environment
In Webupd8 ppa repository also providing a package to set environment variables, Install this package using following command.
https://launchpad.net/~webupd8team/+archive/ubuntu/java
http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html
Read about the new features about Java 8 here .
This article will help you to Install Oracle JAVA 8 (JDK/JRE 8u25) on Ubuntu 14.04 LTS, 12.04 LTS and 10.04 and LinuxMint systems using PPA File.
Installing Java 8 on Ubuntu
Add the webupd8team Java PPA repository in your system and install Oracle Java 8 using following set of commands.
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
Verify Installed Java Version
After successfully installing oracle Java using above step verify installed version using following command.anmol@anmol-Studio-1555:~$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Configuring Java Environment
In Webupd8 ppa repository also providing a package to set environment variables, Install this package using following command.
$ sudo apt-get install oracle-java8-set-default
References :https://launchpad.net/~webupd8team/+archive/ubuntu/java
http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html
Saturday, June 20, 2015
A Stock Management Software - I call it stockIT
Well this one is more of a blog which will be a memory than a web hit . Today 20-06-2015 , ohh well lets go few days back , so starting last Tuesday , i started trading on my DMAT account , invested slowly , slowly till i became all crazy about it and started investing more , and guess what 3K in 4 days , that's what i could make , with an initial investment of 40K .
Well , well , well , which bank in this small world gives such an interests , practically none . Anyways , that;s not the point . Now i ended up buying more and more shares of different companies and i felt that i need a SHARES management system for myself local on my desktop , i don't want to login to my trading account and keep seeing my investment , reports and profits.
So what i decide to write my own stock buying and selling management system , started early morning and i have the back end ready by now . Yet i need to write the UX . Well who knows if this ends up great , i might end up sharing it publicly on github or somewhere.
Next is , should i write the UX as a desktop application or a web application , that decision is still to be taken .
Ohh let me share , the backend is Java and database used is OrientDB a nosql graph database , ah i might have talked about it a lot in my previous blogs .
So as of today , as i sleep , the software i wrote in morning , add the stock i bought to the database , adds the stocks i sold to the database , keeping a relation between the bought stock and the sold stock of the same company , and well yeah it generates a report in the form of a db table / vertex here , that tells me each companies' share i bought and sold , total investment , total sales , profit or loss .
More to be implemented . I don't know if you read this entire blog or not , but if you did i really appreciate it , keep reading .
-@nmol
Thursday, June 18, 2015
How to deal with FindBugs in your project
FindBugs is a google project which many of the companies use in their product development lifecycle to findBugs in a java project . Well this can be used as a command line tool or as a plugin to a build automation framework , lets take Gradle for example .
Well findBugs hunts your code very effectively to find stupid coding mistakes which one would not take care of much while coding .
Lets take a look at what does find bug hunt for . Well this is it : BugCodes.
I am not here to talk about findBugs , neither i am here to talk about gradle .
What i am gonna share is how i got messed up with findBugs BugCode : RV .
A situation where i had to ignore the return value of function and also call that function for something to work in background . Well i really got fed up with findBugs to catch my error everytime and keep failing the build.
Well how to supress this warning and go ahead with the build.
-> If you are not a gradle expert do not try this , in build.gradle , in
findbugsMain {
}
you need to give excludeFilter and a file which specifies the format of the classes and the methods and Bug Code to ignore. Well this was a nightmare and i could not achieve it. Check if you can here .
-> Well if you are a java expert which you i hope you are , all you need to do is add this dependecy in your project build file and use the Annotation
@SupressFBWarnings(value = "bug-code") -- well value is an array so you can send in a string array .
OR
if you are not using a build automation framework like ant , maven or gradle , all you need to do is download the annotations.jar from - here and include it in your project library.
Well there you go and you have succeeded in suppressing findBugs warnings and your build has not failed at this point .
Happy Coding
-@nmol
Well findBugs hunts your code very effectively to find stupid coding mistakes which one would not take care of much while coding .
Lets take a look at what does find bug hunt for . Well this is it : BugCodes.
I am not here to talk about findBugs , neither i am here to talk about gradle .
What i am gonna share is how i got messed up with findBugs BugCode : RV .
A situation where i had to ignore the return value of function and also call that function for something to work in background . Well i really got fed up with findBugs to catch my error everytime and keep failing the build.
Well how to supress this warning and go ahead with the build.
-> If you are not a gradle expert do not try this , in build.gradle , in
findbugsMain {
}
you need to give excludeFilter and a file which specifies the format of the classes and the methods and Bug Code to ignore. Well this was a nightmare and i could not achieve it. Check if you can here .
-> Well if you are a java expert which you i hope you are , all you need to do is add this dependecy in your project build file and use the Annotation
@SupressFBWarnings(value = "bug-code") -- well value is an array so you can send in a string array .
OR
if you are not using a build automation framework like ant , maven or gradle , all you need to do is download the annotations.jar from - here and include it in your project library.
Well there you go and you have succeeded in suppressing findBugs warnings and your build has not failed at this point .
Happy Coding
-@nmol
Subscribe to:
Posts (Atom)