Saturday, December 14, 2019


I met an issue related to "could not create Vfs.Dir from url, no matching UrlType was found" and the solution I applied was by adding change logs class to DatabaseConfiguration.



This is the error.

org.reflections.ReflectionsException: could not create Vfs.Dir from url, no matching UrlType was found [file:/home/jhipster/app.war] either use fromURL(final URL url, final List urlTypes) or use the static setDefaultURLTypes(final List urlTypes) or addDefaultURLTypes(UrlType urlType) with your specialized UrlType. at org.reflections.vfs.Vfs.fromURL(Vfs.java:109) at org.reflections.vfs.Vfs.fromURL(Vfs.java:91) at org.reflections.Reflections.scan(Reflections.java:240) at org.reflections.Reflections.scan(Reflections.java:202) at org.reflections.Reflections.(Reflections.java:123) at org.reflections.Reflections.(Reflections.java:168) at org.reflections.Reflections.(Reflections.java:141) at com.github.mongobee.utils.ChangeService.fetchChangeLogs(ChangeService.java:50) at com.github.mongobee.Mongobee.executeMigration(Mongobee.java:169) at com.github.mongobee.Mongobee.execute(Mongobee.java:156) at com.github.mongobee.Mongobee.afterPropertiesSet(Mongobee.java:126) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1753) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1690) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:548) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at com.novanus.platform.masternodectrl.MasternodeCtrlApp.main(MasternodeCtrlApp.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58) 2019-12-14 09:37:06.243 INFO 1 --- [ main] com.github.mongobee.Mongobee : Mongobee is releasing process lock. 2019-12-14 09:37:06.251 INFO 1 --- [ main] com.github.mongobee.Mongobee : Mongobee has finished his job. 2019-12-14 09:37:07.441 WARN 1 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.

Just add class under <app_package>.config.dbmigrations

@ChangeLogpublic class DatabaseChangelog {
}

And the annoying error was gone.



Wednesday, January 17, 2018

Standalone Selenium Driver Log Level

Standalone Selenium Driver Log Level

I had too much trouble today trying to minimise selenium driver logs, only to find out you only need to pass environment option upon starting selenium just like below. Just sharing this one for others sake. :)

# Log levels are the following to choose from: OFF, SEVERE, WARNING, INFO, DEBUG, FINE, FINER, FINEST, ALL

java -jar -Dselenium.LOGGER.level=WARNING /opt/selenium/selenium-server-standalone.jar


You can also set log file like:

java -jar -Dselenium.LOGGER=/tmp/my_file.log /opt/selenium/selenium-server-standalone.jar

You can do more experiments if needed. Play around. Enjoy!

Sunday, December 20, 2015

Angular variable with HTML containing directives compiled via custom directive

This is a code snippet that allows one to compile a scope variable value who contains both HTML and angular directives.

Simple way to deal with it is through this script...

On html:

<div ng-bind-html-compile="someVariable"></div>

On angular controller:

$scope.personName="Mark";
$scope.someVariable="<b>Hello, </b> {{personName}} !!!";

On angular directive:

app.directive('ngBindHtmlCompile', ['$compile', function ($compile) {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            scope.$watch(function () {
                return scope.$eval(attrs.bindHtmlCompile);
            }, function (value) {
                element.html(value && value.toString());
                var compileScope = scope;
                if (attrs.bindHtmlScope) {
                    compileScope = scope.$eval(attrs.bindHtmlScope);
                }
                $compile(element.contents())(compileScope);
            });
        }
    };
}]);

Thursday, October 15, 2015

Java - Finding Frequent Phrases in a Large File Effeciently

October 15, 2015 - I was bored so I went to play around with Java and solve some simple problem or exercise below to energize my playful mind.

Given a large file that does not fit in memory (say 10GB), find the top 100000 most frequent phrases. The file has 50 phrases per line separated by a pipe (|). Assume that the phrases do not contain pipe.

Example line may look like: 

Foobar Candy | Olympics 2012 | PGA | CNET | Microsoft Bing ….
The above line has 5 phrases in visible region.

Java - Finding K-complementary Pairs in Array of Integers

October 15, 2015 - I was bored so I went to play around with Java and solve some simple problem or exercise below to energize my playful mind.

Write an efficient algorithm to find K-complementary pairs in a given array of integers. Given Array A, pair (i, j) is K- complementary if K = A[i] + A[j];


Java - Check if a String is a Palindrome

October 15, 2015 - I was bored so I went to play around with Java and solve some simple problem or exercise below to energize my playful mind.

Write an efficient algorithm to check if a string is a palindrome. A string is a palindrome if the string matches the reverse of string.

Example: 1221 is a palindrome but not 1121.


MySQL - Overlapping Date Range Filter

October 15, 2015 - I was bored so I went to play around with MySQL and solve some simple problem or exercise below to energize my playful mind.

I have a table for bugs from a bug tracking software; let’s call the table “bugs”. The table has four columns (id, open_date, close_date, severity). On any given day a bug is open if the open_date is on or before that day and close_date is after that day. For example, a bug is open on “2012-01-01”, if it’s created on or before “2012-01-01” and closed on or after “2012-01-02”. I want a SQL to show number of bugs open for a range of dates.

CREATE TABLE bugs (
  id INT,
  severity INT,
  open_date DATE,
  close_date DATE
);

INSERT INTO bugs VALUES
  (
    1, 1,
    STR_TO_DATE('2011-12-31', '%Y-%m-%d'),
    STR_TO_DATE('2011-12-31', '%Y-%m-%d')
  ),
  (
    2, 1,
    STR_TO_DATE('2012-01-01', '%Y-%m-%d'),
    STR_TO_DATE('2012-01-02', '%Y-%m-%d')
  ),
  (
    3, 1,
    STR_TO_DATE('2012-01-03', '%Y-%m-%d'),
    STR_TO_DATE('2012-01-03', '%Y-%m-%d')
  ),
  (
    4, 1,
    STR_TO_DATE('2012-01-03', '%Y-%m-%d'),
    STR_TO_DATE('2012-01-04', '%Y-%m-%d')
  ),
  (
    5, 1,
    STR_TO_DATE('2012-01-06', '%Y-%m-%d'),
    STR_TO_DATE('2012-01-07', '%Y-%m-%d')

  );