Copy the Current Path from Terminal to the Clipboard in Mac OS X


Create a new tab next to current tab + chrome extension

chrome.tabs.query({
        active: !0,
        lastFocusedWindow: !0
    }, function(a) {
        chrome.tabs.create({
            url: gQuery,
            index: a[0].index + 1,
            selected: true
        })

    });

How to remove all docker images stored in a local repository

The following commands can be used to remove all Docker images stored in your local repository. Be aware that you would not be able to undo any of the removed docker images. First, list all your docker images to make sure that there is nothing you want to remove:
# docker images
Using the following command you can obtain image IDs of all your docker images:
# docker images -q
To remove a single docker image simply run docker rmi followed by the image ID. For example:
# docker rmi 9fa0e1f381ad
In order to remove all image at once with a single command we can combine two commands together:
# docker rmi `docker images -q`
The above command will not remove images which are currently being used by containers and the following error message will appear:
Error response from daemon: Conflict, cannot force delete 568f5ffe3905 
because the running container 9fa0e1f381ad is using it, stop it and retry
To remove docker images even if they are used by container use force switch:
# docker rmi -f `docker images -q`

Exclude a file from GIT Diff

git diff -- . ':(exclude)com/watchmouse/rest/utils/abc.java'


git diff -- . ':(exclude)db/irrelevant.php'

DEBUGGING THE DREADED “SEVERE: ERROR LISTENERSTART” AND “SEVERE: ERROR FILTERSTART” TOMCAT ERROR MESSAGES



|
Just a quick post that I hope might benefit others. If you have been developing web applications on tomcat for a while you have likely come the two error messages mentioned in the title.

SEVERE: Error listenerStart

Occurs when an exception is thrown in the contextInitialized method of a ServletContextListener

SEVERE: Error filterStart

Occurs when an exception is thrown in the init method of a Filter
Unfortunately by default, tomcat won’t provide you with any details about the cause of the error. Infact it wont even tell you which filter or listener is failing. This can be big problem in applications of significant size that have many filters and listeners configured. Fortunately there is a solution. In your webapplication’s WEB-INF/classes folder you can create a logging.properties file with the following contents
org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler
Now you will be presented with the stacktrace

Reference: http://blog.trifork.com/2011/03/18/debugging-the-dreaded-severe-error-listenerstart-and-severe-error-filterstart-tomcat-error-messages/

Schedule a job using Quartz

import org.apache.log4j.Logger;
import org.quartz.CronTrigger;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;

import com.ef.monitoring.FeedUpdaterTasklet;

public class FeedBackEmailScheduler implements Job {

private static Logger logger = Logger.getLogger(FeedBackEmailScheduler.class);

private static Scheduler scheduler;

public static void start() throws Exception {

scheduler = StdSchedulerFactory.getDefaultScheduler();

JobDetail jobDetail = new JobDetail("FeedBackEmailScheduler", Scheduler.DEFAULT_GROUP,
FeedBackEmailScheduler.class);

// Run job at each day 10.30 AM and 6.30 PM
CronTrigger cTrigger = new CronTrigger("FeedBackEmailScheduler", "MCC", "0 30 10,18 1/1 * ? *");

scheduler.scheduleJob(jobDetail, cTrigger);

scheduler.start();
}

public void execute(JobExecutionContext context) {
try {
FeedUpdaterTasklet feedUpdaterTasklet = (FeedUpdaterTasklet) SpringApplicationContextProvider
.getBean("feedUpdaterTasklet", FeedUpdaterTasklet.class);
feedUpdaterTasklet.run();
} catch (Exception e) {
logger.error("Error while monitoring the products", e);
}
}

public static void shutdown() {
try {
if (scheduler != null) {
scheduler.shutdown();
}
} catch (Exception ignore) {
}
}
}