2019-05-27

To Be Find Out: Eclipse .settings



Eclipse .settings

Eclipse:
Eclipse Java EE IDE for Web Developers.
Version: Photon Release (4.8.0)
Build id: 20180619-1200

Might caused to have these xml config as below to be added automatically, right the time after you did Maven > Updates Project.

        <dependent-module archiveName="tss-lib-1.1.9-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/TssLib_Mobile_API/TssLib_Mobile_API">
            <dependency-type>uses</dependency-type>
        </dependent-module>








2019-05-23

Project 'X' is missing required Java project: 'Y'


Google'd: java maven project build path problems is missing required java project

Reference URL:
https://stackoverflow.com/questions/22050194/project-x-is-missing-required-java-project-y

reference above solving by tweaking in project x, but my case i have to tweak from project y

  1. Disable Maven nature for project y.
  2. Re convert to maven project again for project y.

2019-05-14

Enable Spring Security Web Expression(JSTL), customized Spring Security UserDetailsService



Enable Spring Security Web Expression(JSTL), customized Spring Security UserDetailsService



Reference URL:

  1. https://howtodoinjava.com/spring-security/custom-userdetailsservice-example-for-spring-3-security/ (only with JSTL)
  2. https://www.baeldung.com/spring-security-authentication-with-a-database (ONLY with encryption)










Spring 3.0 with JUnit Test 4


Reference URLs:

  1. https://yuangaopeng.com/2018/12/05/Spring%20Testing%20classpath/
  2. https://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#integration-testing-annotations




For JUnit test with spring, either you load context configuration:

  1. manual parse xml [ApplicationContext _ctx = ClassPathXmlApplicationContext( "abc/xyz/spring-context-all.xml" ) ], access beans via _ctx.getBean()
  2. or annotation to let spring auto wired all your attributes of test cases.



And using annotation of @ContextConfiguration, I've preference to use classpath for reasons below:

  1. Spring JUnit test cases able to share xml info.
  2. multi developer environment competible.











Enable Spring Security Web Expression(JSTL)



Reference URL:

  1. https://stackoverflow.com/questions/11594104/spring-security-no-visible-websecurityexpressionhandler-instance-could-be-foun
  2. https://www.codesd.com/item/no-webapplicationcontext-found-no-contextloaderlistener.html




Added bean configuration below into applicationContext.xml to enable Spring EL

<bean id="webexpressionHandler" class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler" />



To have this applicationContext.xml to be pickup, make sure listener has been added into /WEB-INF/web.xml


<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>




2019-05-02

Suspect text editor compare feature kinda buggie in eclipse.




Feels the text editor compare feature kinda buggie for eclipse version since Neon, Oxygen, and even Photon Release (4.8.0) too.

But no printscreen been captured at the moment...

Will look into this later if face this problem again...




2019-04-25

Seems resolved: Code Assists exception, org.eclipse.recommenders.completion.rcp






org.eclipse.recommenders.completion.rcp

With this to extend the timeout, but won't solve

-vmargs -Dorg.eclipse.jdt.ui.codeAssistTimeout=60000


taking this advice:
https://stackoverflow.com/a/1367329/676104

Eclipse Code Recommenders Mylyn Integration makes Mylyn’s task‐focused Java proposals available in Code Recommenders’ intelligent code completion. Install this feature if you want to use the Mylyn Task‐Focused Interface in conjunction with Eclipse Code Recommenders.





Uninstall Code Recommenders Mylyn Integration

But still having the exception message.

















Reference URL: https://blog.csdn.net/u013066244/article/details/69054447


1、点击报错的那个连接`(Window -&gt; preferences -> java -> Editor -> Content Assist -> Advanced)`。
2、再打开的配置了面将`Default Proposal Kinds`栏中`Java Proposals (Code Recommenders)`前面的对勾去掉就可以了。
3、生效后,我的就没有提示,然后又将剩余的两个`Java Proposals`、`Java Proposals(Task-Focused)`打上对勾才正常。
--------------------- 
作者:山鬼谣me 
来源:CSDN 
原文:https://blog.csdn.net/u013066244/article/details/69054447 
版权声明:本文为博主原创文章,转载请附上博文链接!




Seems settings in redbox above is working...










2019-04-22

Resolved: The import org.hibernate.annotations.CreationTimestamp cannot be resolved





By refering to: https://stackoverflow.com/questions/32090921/deploying-maven-project-throws-java-util-zip-zipexception-invalid-loc-header-b

Solve by delete the .m2\repository\org\hibernate\hibernate-core\5.3.3.Final
And did a Maven Update.


Awaiting to verify: might triggered by migrated from Oracle JDK to AdoptOpenJDK





Initially thought was causing by Builders of Spring(Spring Project Builder& Spring Boot Validations Builder) was not there.

Project Natures also missing Spring relevant component.



Then the import org.hibernate.annotations.CreationTimestamp cannot be resolved





Found exists in Maven Dependency.




But when double click the CreationTimestamp.class, it shows invalid LOC header (bad signature).
java.util.zip.ZipException: invalid LOC header (bad signature)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:734)
at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:434)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(Util.java:531)
at org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(Util.java:697)
at org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeFactory.rawReadTypeTestForExists(BinaryTypeFactory.java:170)
at org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeFactory.rawReadType(BinaryTypeFactory.java:137)
at org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeFactory.readType(BinaryTypeFactory.java:132)
at org.eclipse.jdt.internal.core.ClassFile.getJarBinaryTypeInfo(ClassFile.java:233)
at org.eclipse.jdt.internal.core.ClassFile.getBinaryTypeInfo(ClassFile.java:188)
at org.eclipse.jdt.internal.core.ClassFile.buildStructure(ClassFile.java:75)
at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:265)
at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:593)
at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:323)
at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:309)
at org.eclipse.jdt.internal.core.Openable.getBuffer(Openable.java:295)
at org.eclipse.jdt.internal.core.AbstractClassFile.getBuffer(AbstractClassFile.java:218)
at org.eclipse.jdt.internal.core.AbstractClassFile.getSourceRange(AbstractClassFile.java:344)
at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.probeInputForSource(ClassFileEditor.java:789)
at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInput(ClassFileEditor.java:688)
at org.eclipse.ui.texteditor.AbstractTextEditor$5.run(AbstractTextEditor.java:3165)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:437)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:353)
at org.eclipse.ui.internal.WorkbenchWindow$14.run(WorkbenchWindow.java:2212)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:71)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2208)
at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3183)
at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3208)
at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:362)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:342)
at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:1005)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:970)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:137)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:412)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:331)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:190)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:105)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:56)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:1012)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:672)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:778)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:749)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:743)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:727)
at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1277)
at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.lambda$0(LazyStackRenderer.java:72)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:233)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:144)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4567)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:212)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:36)
at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:201)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:196)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:52)
at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:60)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:174)
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:634)
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:598)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:788)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:401)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1238)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3277)
at org.eclipse.ui.internal.WorkbenchPage.access$26(WorkbenchPage.java:3192)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:3174)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:71)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3169)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3133)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3123)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:373)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:179)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:284)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:249)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:271)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:249)
at org.eclipse.jdt.internal.ui.navigator.OpenAndExpand.run(OpenAndExpand.java:50)
at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:216)
at org.eclipse.ui.navigator.CommonNavigatorManager$1.open(CommonNavigatorManager.java:180)
at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:46)
at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:850)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil.lambda$0(JFaceUtil.java:44)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173)
at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:847)
at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1162)
at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:451)
at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:273)
at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:268)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:308)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4118)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3931)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3534)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1170)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1059)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:667)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:597)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:656)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:592)
at org.eclipse.equinox.launcher.Main.run(Main.java:1498)






Another Case:
7 build path entries are missing.
# Fixed build path entries are missing.

Manual remove all classpathentry in eclipse config, .classpath
Suppose Alt + F5 , or Maven Update Project will be able to generate these automatically.



















2019-04-17

My Belgium visitors mostly using Unix and Firefox...


My Belgium visitors mostly using Unix and Firefox...
















2019-04-10

Original tomcat.service





[billson@virtual-jenkins ~]$ sudo yum info tomcat
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.nus.edu.sg
 * extras: mirror.nus.edu.sg
 * updates: mirror.nus.edu.sg
Installed Packages
Name        : tomcat
Arch        : noarch
Version     : 7.0.76
Release     : 9.el7_6
Size        : 303 k
Repo        : installed
From repo   : updates
Summary     : Apache Servlet/JSP Engine, RI for Servlet 3.0/JSP 2.2 API
URL         : http://tomcat.apache.org/
License     : ASL 2.0
Description : Tomcat is the servlet container that is used in the official Reference
            : Implementation for the Java Servlet and JavaServer Pages technologies.
            : The Java Servlet and JavaServer Pages specifications are developed by
            : Sun under the Java Community Process.
            :
            : Tomcat is developed in an open and participatory environment and
            : released under the Apache Software License version 2.0. Tomcat is intended
            : to be a collaboration of the best-of-breed developers from around the world.



/usr/lib/systemd/system/tomcat.service


# Systemd unit file for default tomcat
#
# To create clones of this service:
# DO NOTHING, use tomcat@.service instead.

[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
Environment="NAME="
EnvironmentFile=-/etc/sysconfig/tomcat
ExecStart=/usr/libexec/tomcat/server start
SuccessExitStatus=143
User=tomcat

[Install]
WantedBy=multi-user.target





/usr/lib/systemd/system/tomcat@.service

# Systemd unit file for tomcat instances.
#
# To create clones of this service:
# 0. systemctl enable tomcat@name.service
# 1. create catalina.base directory structure in
#    /var/lib/tomcats/name
# 2. profit.

[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
Environment="NAME=%I"
EnvironmentFile=-/etc/sysconfig/tomcat@%I
ExecStart=/usr/libexec/tomcat/server start
ExecStop=/usr/libexec/tomcat/server stop
SuccessExitStatus=143
User=tomcat

[Install]
WantedBy=multi-user.target





2019-04-09

ps -ef grep -v multi


Google'ed by: ps -ef grep -v multi




Reference URL: https://stackoverflow.com/a/13330924/676104


Use a separated list of of processes:
#!/bin/bash
PROC="nginx mysql ..."
for p in $PROC
do
  ps cax | grep $p > /dev/null

  if [ $? -eq 0 ]; then
    echo "Process $p is running."
  else
    echo "Process $p is not running."
  fi

done
If you simply want to see if either one of them is running, then you don't need loo. Just give the list to grep:
ps cax | grep -E "Nginx|mysql|etc" > /dev/null



To exclude by using:


ps -ef | grep -vE "grep|vim |tail " | grep tomcat








2019-04-03

Access Fail2ban Database, /var/lib/fail2ban/fail2ban.sqlite3






vim ~/.sqliterc

.mode column
.headers on
.nullvalue NULL
attach "/var/lib/fail2ban/fail2ban.sqlite3" as fail2ban;





ls -lrth /var/lib/fail2ban/fail2ban.sqlite3

sudo chown :SystemAdmin /var/lib/fail2ban/fail2ban.sqlite3
sudo chmod g+r /var/lib/fail2ban/fail2ban.sqlite3

assign yourself into group: SystemAdmin


sqlite3















sqlite> .databases
seq  name             file
---  ---------------  ----------------------------------------------------------
0    main
2    fail2ban         /var/lib/fail2ban/fail2ban.sqlite3
sqlite> .tables
fail2ban.bans        fail2ban.jails
fail2ban.fail2banDb  fail2ban.logs





sqlite> SELECT jail, ip, strftime('%Y-%m-%d %H:%M:%S', timeofban, 'unixepoch' ) AS 'DateTime of ban', timeofban FROM fail2ban.bans ORDER BY timeofban DESC LIMIT 3;

jail|ip|DateTime of ban|timeofban
sshd|xxx.xx.xxx.xxx|2019-04-03 09:05:21|1554282321
sshd|xxx.xx.xxx.xxx|2019-04-03 09:04:01|1554282241
sshd|xx.xxx.xx.xx|2019-04-03 09:03:48|1554282228




Ban perform by month


sqlite> SELECT strftime('%Y-%m', timeofban, 'unixepoch' ) AS 'Date', COUNT( 1 ) FROM fail2ban.bans GROUP BY strftime('%Y-%m', timeofban, 'unixepoch' );

Date|COUNT( 1 )
2019-01|6078
2019-02|10906
2019-03|2428
2019-04|571


Ban performed by week of the year


sqlite> SELECT strftime('%W', timeofban, 'unixepoch' ) AS 'Week of Year', strftime('%Y-%m', timeofban, 'unixepoch' ) AS 'Date', COUNT( 1 ) FROM fail2ban.bans GROUP BY strftime('%Y-%m', timeofban, 'unixepoch' ), strftime('%W', timeofban, 'unixepoch' );
Week of Year  Date        COUNT( 1 )
------------  ----------  ----------
01            2019-01     1074
02            2019-01     1502
03            2019-01     2005
04            2019-01     1497
04            2019-02     1218
05            2019-02     1490
06            2019-02     3719
07            2019-02     3272
08            2019-02     1207
08            2019-03     229
09            2019-03     1258
10            2019-03     941
13            2019-04     577

Ban performed on current month of the year


2019-Apr-05_am105521
sqlite> SELECT strftime('%W', timeofban, 'unixepoch' ) AS 'Week of Year', strftime('%Y-%m-%d', timeofban, 'unixepoch' ) AS 'Date', COUNT( 1 ) FROM fail2ban.bans WHERE strftime('%Y-%m', timeofban, 'unixepoch' ) = strftime('%Y-%m', DATE('now') ) GROUP BY strftime('%Y-%m-%d', timeofban, 'unixepoch' ), strftime('%W', timeofban, 'unixepoch' );
Week of Year  Date        COUNT( 1 )
------------  ----------  ----------
13            2019-04-01  205
13            2019-04-02  290
13            2019-04-03  174
13            2019-04-04  13
13            2019-04-05  5






List of ip with count of banned.


SELECT ip, COUNT( 1 ) FROM fail2ban.bans GROUP BY ip  ORDER BY COUNT( 1 ) DESC;






List of ip with count of banned more than twice.


SELECT ip, COUNT( 1 ) FROM fail2ban.bans GROUP BY ip HAVING COUNT( 1 ) > 2 ORDER BY COUNT( 1 );



List of Top 50 ip with most count of banned.


SELECT ip, COUNT( 1 ) FROM fail2ban.bans GROUP BY ip HAVING COUNT( 1 ) > 2 ORDER BY COUNT( 1 ) DESC LIMIT 50;





Total count for distinct ip

SELECT COUNT( 1 ) FROM (SELECT DISTINCT( ip ) FROM fail2ban.bans );






.quit






















2019-04-01

Most common init systems for CentOS/others.


Reference URL: https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples


PostedAugust 19, 2015



  • System V is the older init system:
    • Debian 6 and earlier
    • Ubuntu 9.04 and earlier
    • CentOS 5 and earlier
  • Upstart:
    • Ubuntu 9.10 to Ubuntu 14.10, including Ubuntu 14.04
    • CentOS 6
  • systemd is the init system for the most recent distributions featured here:
    • Debian 7 and Debian 8
    • Ubuntu 15.04 and newer
    • CentOS 7




















2019-03-26

batch script to kill skype WIndows 10


Google'ed by: batch script to kill skype


Reference URL: https://superuser.com/questions/346591/is-there-a-one-click-way-to-quit-skype-in-windows-7



in file: kill_skypes.bat



taskkill.exe /IM skypeapp.exe /T
taskkill.exe /IM skypebackgroundhost.exe /f
taskkill.exe /IM skypebridge.exe /T





double click "kill_skypes.bat" to kill skype...













Windows Command line get disk space in GB, export to a file.



Reference URL: https://superuser.com/a/924992



Debug mode to understand this script.

del diskspace.log & for /f "tokens=1-3" %a in ('WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V "Name"') do @echo wsh.echo "%b" ^& " Free=" ^& FormatNumber^(cdbl^(%a^)/1024/1024/1024, 2^)^& " GiB"^& " Size=" ^& FormatNumber^(cdbl^(%c^)/1024/1024/1024, 2^)^& " GiB"^& " Used=" ^& FormatNumber^(cdbl^(%c^-%a^)/1024/1024/1024, 2^)^& " GiB" > %temp%\tmp.vbs & more %temp%\tmp.vbs & @if not "%c"=="" @echo( & @cscript //nologo %temp%\tmp.vbs >> diskspace.log & more diskspace.log




Production script:

del diskspace.log & for /f "tokens=1-3" %a in ('WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V "Name"') do @echo wsh.echo "%b" ^& " Free=" ^& FormatNumber^(cdbl^(%a^)/1024/1024/1024, 2^)^& " GiB"^& " Size=" ^& FormatNumber^(cdbl^(%c^)/1024/1024/1024, 2^)^& " GiB"^& " Used=" ^& FormatNumber^(cdbl^(%c^-%a^)/1024/1024/1024, 2^)^& " GiB" > %temp%\tmp.vbs & @if not "%c"=="" @echo( & @cscript //nologo %temp%\tmp.vbs >> diskspace.log

more diskspace.log








2019-03-21

javax.mail.MessagingException: Could not convert socket to TLS;


https://stackoverflow.com/questions/16115453/javamail-could-not-convert-socket-to-tls-gmail

javax.mail.MessagingException: Could not convert socket to TLS;

Solved by: props.put("mail.smtp.ssl.trust", "smtp.gmail.com");


openjdk.java.net vs jdk.java.net



edited 6 months ago from 2019-Mar-21_pm034301


Note that while both openjdk.java.net (the OpenJDK project) and jdk.java.net (OpenJDK builds by Oracle) are run by Oracle, jdk.java.net is not an OpenJDK website.











OpenJDK vs AdoptOpenJDK


Updates@2019-Apr-01_pm040305:

I'm using OpenJDK8U-jdk_x64_linux_hotspot_8u202b08
https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u202b08.tar.gz

from: https://adoptopenjdk.net/releases.html?variant=openjdk8&jvmVariant=hotspot#x64_linux



Seems previous finding

https://billson.blogspot.com/2019/03/openjdk-variants-vs-each-other-and-vs.html


  1. OracleJDK
  2. OpenJDK
    1. from Oracle
    2. from other providers




jdk_ri-8u40-b25-windows-i586-10_feb_2015>bin\java.exe -version
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b25)
OpenJDK Client VM (build 25.40-b25, mixed mode)

OpenJDK8U-jre_x86-32_windows_hotspot_8u202b08\bin\java.exe -version
openjdk version "1.8.0_202"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_202-b08)
OpenJDK Server VM (AdoptOpenJDK)(build 25.202-b08, mixed mode)




Reference from stackoverflow
Difference between OpenJDK and AdoptOpenJDK
https://stackoverflow.com/questions/52431764/difference-between-openjdk-and-adoptopenjdk


In short:
  • OpenJDK has multiple meanings and can be referred as:
    • free and open source implementation of the Java Platform, Standard Edition (Java SE)
    • open source repository - the Java source code aka OpenJDK project
    • prebuilt OpenJDK binaries provided by Oracle
  • AdoptOpenJDK prebuilt OpenJDK binaries provided by community



    Explanation:
    Prebuilt OpenJDK (or distribution) - binaries, built from http://hg.openjdk.java.net/, provided in a zip or installer, offered for various platforms, with a possible support contract.
    OpenJDK, the source repository (also called OpenJDK project) - is a Mercurial-based open source repository, hosted at [http://hg.openjdk.java.net]. The Java source code. The vast majority of Java features (from the VM and the core libraries to the compiler) are based solely on this source repository. Oracle have an alternate fork of this.
    OpenJDK, the distribution (see the list of providers below) - is free as in beer and kind of free as in speech, but, you do not get to call Oracle if you have problems with it. There is no support contract. Furthermore, Oracle will only release updates to any OpenJDK (the distribution) version if that release is the most recent Java release (including LTS). The day oracle releases OpenJDK (the distribution) version 12.0, even if there's a security issue with OpenJDK (the distribution) version 11.0, Oracle shall not release an update for 11.0. Maintained solely by Oracle.
    AdoptOpenJDK, the distribution - very similar to Oracle's OpenJDK distribution (in that it is free, and it is a build produced by compiling the sources from the OpenJDK source repository). AdoptOpenJDK as an entity will not be backporting patches, i.e. there won't be an AdoptOpenJDK 'fork/version' that is materially different from upstream (except for some build script patches for things like Win32 support). Meaning, if members of the community (Oracle or others, but not AdoptOpenJDK as an entity) backport security fixes to updates of OpenJDK LTS versions, then AdoptOpenJDK will provide builds for those. Maintained by OpenJDK community.
    There's also OracleJDK - another distribution, starting with JDK12 there will be no free version of this. Oracle's JDK distribution offering intended for commercial support. You pay for this, but then you do get to rely on Oracle for support. Unlike Oracle's OpenJDK offering, the OracleJDK offering does come with longer support for LTS versions. As a developer you can get a free license for personal/development use only of this particular JDK, but that's mostly a red herring, as 'just the binary' is basically the same as the OpenJDK binary. I guess it means you can download security-patched versions of LTS JDKs from Oracle's websites as long as you promise not to use them commercially.
    Note. It maybe best to call the OpenJDK builds by Oracle, the "Oracle OpenJDK builds".
    Donald Smith, Java product manager at Oracle writes:
    Ideally, we would simply refer to all Oracle JDK builds as the "Oracle JDK," either under the GPL or the commercial license depending on your situation. However, for historical reasons while the small remaining differences exist, we will refer to them separately as Oracle’s OpenJDK builds, and the Oracle JDK.

    OpenJDK Providers and Comparison

    ---------------------------------------------------------------------------
    |     Provider      | Free Builds | Free Binary   | Extended | Commercial |
    |                   | from Source | Distributions | Updates* | Support    |  
    |-------------------------------------------------------------------------|               
    | AdoptOpenJDK      |    Yes      |    Yes        |   Yes    |   No       |
    | Azul              |    No       |    Yes        |   Yes    |   Yes      |
    | IBM               |    No       |    No         |   Yes    |   Yes      |
    | Mercurial         |    Yes      |    Yes        |   No     |   No       |
    | Oracle            |    No       |    Yes        |   No**   |   Yes      |
    | RedHat            |    Yes      |    Yes        |   Yes    |   Yes      |
    | SapMachine        |    Yes      |    Yes        |   Yes    |   Yes      |
    | Amazon – Corretto |    Yes      |    Yes        |   Yes    |   No       |
    ---------------------------------------------------------------------------
    
    * Extended Updates - Public Updates beyond the 6-month release lifecycle
    ** Oracle provides extended updates (and support) to paying customers, i.e. Oracle JDK only

    Additional information
    Time to look beyond Oracle's JDK by Stephen Colebourne
    Java Is Still Free by Java Champions community (published on September 17, 2018)
    Java is Still Free 2.0.0 by Java Champions community (published on March 3, 2019)






Google Referrals