sudo easy_install pip
Exclude a file from GIT Diff
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px 'Andale Mono'; color: #29f914; background-color: #000000} span.s1 {font-variant-ligatures: no-common-ligatures} 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 listenerStartOccurs when an exception is thrown in the contextInitialized method of a ServletContextListenerSEVERE: Error filterStartOccurs when an exception is thrown in … Continue reading 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 = … Continue reading Schedule a job using Quartz
SEVERE: Exception sending context initialized event to listener instance of class + Null Pointer Exception
If at all you are trying to load the bean before, use like below. This is also useful when you try to get a bean in @weblistener as well.@Overridepublic void contextInitialized(ServletContextEvent sce) { WebApplicationContextUtils .getRequiredWebApplicationContext(sce.getServletContext()) .getAutowireCapableBeanFactory() .autowireBean(this); //your code goes here}
Scheduler Job using Java8, Better than TimerJob
import java.time.Duration;import java.time.LocalDateTime;import java.time.ZoneId;import java.time.ZonedDateTime;import java.util.concurrent.Executors;import java.util.concurrent.ScheduledExecutorService;import java.util.concurrent.TimeUnit;import javax.servlet.ServletContextEvent;import javax.servlet.ServletContextListener;import javax.servlet.annotation.WebListener;import org.springframework.web.context.support.WebApplicationContextUtils;@WebListenerpublic class BackgroundJobManager implements ServletContextListener { private ScheduledExecutorService scheduler; @Override public void contextInitialized(ServletContextEvent event) { LocalDateTime localNow = LocalDateTime.now(); ZoneId currentZone = ZoneId.of("America/New_York"); ZonedDateTime zonedNow = ZonedDateTime.now(currentZone); ZonedDateTime zonedNext1030AM = zonedNow.withHour(11).withMinute(49).withSecond(0); ZonedDateTime zonedNext630PM = zonedNow.withHour(11).withMinute(50).withSecond(2); System.out.println(zonedNow); System.out.println(zonedNext1030AM); System.out.println(zonedNext630PM); System.out.println(localNow); Duration duration1030AM = Duration.between(zonedNow, zonedNext1030AM); … Continue reading Scheduler Job using Java8, Better than TimerJob
Git + How to list all the files in a commit?
git show --pretty="" --name-only bd61ad98
show tables like in mysql
SHOW TABLES WHERE Tables_in_mydbname LIKE '%reward%'suppose mydbname is 'blogposts'SHOW TABLES WHERE Tables_in_blogposts LIKE '%reward%'
Firefox ignores option selected=“selected”, Selected = ‘"
This behaviour is hard coded in FF.Add autocomplete="off" HTML attribute to the respective select tag.
git commit get fatal error “fatal: CRLF would be replaced by LF in”
The usual fix is to convert those files yourself, with dos2unix or Swiss File Knife.I have always preferred to keep core.autocrlf to false, which means:git config --global core.autocrlf false