tag:blogger.com,1999:blog-47648311699869487522024-03-20T23:22:34.420-07:00Kim Kenneth Moes blogNotes about Java, JEE and related subjects.Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.comBlogger112125tag:blogger.com,1999:blog-4764831169986948752.post-72441986490755735192023-01-06T04:45:00.004-08:002023-01-06T04:45:29.650-08:00Folder size in terminalsudo du -h -d 1
-h : human read
-d : depth
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-74271358368941556092022-12-05T03:42:00.004-08:002022-12-05T03:45:21.442-08:00Get user in Spring<pre>SecurityContextHolder.getContext().authentication.name</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-67230143710463274522022-01-17T05:22:00.004-08:002022-01-17T05:22:49.532-08:00Use of DateTimeFormatterUse DateTimeFormatter instead of SimpleDateFormat
<pre>
DateTimeFormatter.ofPattern("yyyyMMdd_HHmm").format(LocalDateTime.now()));
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-50508480725238182492022-01-17T05:15:00.001-08:002022-01-17T05:15:27.781-08:00@SuppressWarnings not working with checkstyleRemember to add SuppressWarningsHolder insite the TreeWalker as:<br>
<br>
<pre>
<module name="TreeWalker">
.
.
.
<module name="SuppressWarningsHolder" />
</module>
</pre>
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-34060017513943364072021-11-22T03:50:00.002-08:002021-11-22T04:03:37.711-08:00ssh, scp to Virtualbox<p></p><div class="separator" style="clear: both; text-align: left;">Under Network -> Advanced -> Port Forwarding</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzD1f8IqtSlR19JHHBAPyYM3wTEj_F8nGnG3HyLB3qP8qJ0N_AUJeY9PnkYlXOJom1VEkf1062P06_3ra7Pjl3pfvjtnooa3eSQarbW9HwSGX0vm4PmnA4YoMm4wv2IoOczJz_gb0n2kkb/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="574" data-original-width="740" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzD1f8IqtSlR19JHHBAPyYM3wTEj_F8nGnG3HyLB3qP8qJ0N_AUJeY9PnkYlXOJom1VEkf1062P06_3ra7Pjl3pfvjtnooa3eSQarbW9HwSGX0vm4PmnA4YoMm4wv2IoOczJz_gb0n2kkb/" width="309" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">Name: ssh</div><div class="separator" style="clear: both; text-align: left;">Protocol: TCP</div><div class="separator" style="clear: both; text-align: left;">Host Port: 3022</div><div class="separator" style="clear: both; text-align: left;">Guest Port: 22</div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFw4E_uhxsdD4NTDakx_NCZObGV0lYrUZngTUFFcpYPjDD3sr6tYoVV0l6mt-1Lm7fdVJXXZzSWyZw62sp7clpmzDOaR1Fb4HREHf9_iY4ICQtLVHJstBKix3jNcwovRwkf9oLpd1PGEtL/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="493" data-original-width="682" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFw4E_uhxsdD4NTDakx_NCZObGV0lYrUZngTUFFcpYPjDD3sr6tYoVV0l6mt-1Lm7fdVJXXZzSWyZw62sp7clpmzDOaR1Fb4HREHf9_iY4ICQtLVHJstBKix3jNcwovRwkf9oLpd1PGEtL/" width="320" /></a></div><br /><br /></div><b>Start client from terminal</b><br /><br /><div>VBoxManage startvm "<name>" --type headless<br /><div><b><br /></b></div><div><b>SSH from host to client</b><p></p><p>ssh -p 3022 kim@127.0.0.1</p><p><b>SCP from host to client</b></p><p>scp -P 3022 vpn_config.zip 127.0.0.1:.</p><p><br /></p><p><br /></p></div></div>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-82084557422100276592021-11-18T01:14:00.004-08:002021-11-18T01:14:33.548-08:00Change the ll commandadd to .bashrc
<br>
<pre>alias ll='ls -la --color=auto'</pre>
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-65859766448135813472021-11-03T02:14:00.003-07:002021-11-03T02:14:38.593-07:00Automatically adds Jira key to commit messageFile named <i>prepare-commit-msg</i> in dir <i>~/projects/ab-tools/install-instructions/githooks</i>
<div class="code">
<br>
#!/bin/bash<br>
#<br>
# Automatically adds Jira key to commit message<br>
#<br>
# To automatically prepend any commit massage with the branch name, ie. [TEST-xxxx], run:<br>
# ```<br>
# git config --global core.hooksPath ~/projects/ab-tools/install-instructions/githooks/<br>
# ```<br>
#<br>
<br>
if [ -z "$BRANCHES_TO_SKIP" ]; then<br>
BRANCHES_TO_SKIP=(master develop)<br>
fi<br>
<br>
BRANCH_NAME=$(git symbolic-ref --short HEAD)<br>
BRANCH_NAME="${BRANCH_NAME##*/}"<br>
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")<br>
BRANCH_JIRA_KEY=$(echo $BRANCH_NAME | grep -E -o '^([A-Z]+-[0-9]+)')<br>
<br>
if ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $(cat "$1") == "$BRANCH_JIRA_KEY"* ]] && ! [ -z "$BRANCH_JIRA_KEY" ]; then<br>
echo "[$BRANCH_JIRA_KEY] $(cat "${1}")" > "$1"<br>
fi<br>
<br>
<br>
</div>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-72482364517349934742020-05-06T00:28:00.002-07:002020-05-06T00:34:27.499-07:00maven-enforcer-pluginTo ensure dependencies
<br />
<pre>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforcer</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<dependencyConvergence/>
<requireReleaseDeps>
<onlyWhenRelease>true</onlyWhenRelease>
</requireReleaseDeps>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</pre>
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-35823135395445735692020-04-21T03:29:00.000-07:002020-04-21T03:29:10.697-07:00How to download certificate with the new FirefoxI don't like Firefox's new Certificates Viewer then downloading certificates. <div>
<br /></div>
<div>
To disable go to: </div>
<div>
about:config </div>
<div>
security.aboutcertificate.enabled </div>
<div>
<br /></div>
<div>
and all is like : the old days :)</div>
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-4513828235209976652020-03-06T12:56:00.003-08:002020-03-06T12:56:28.141-08:00How to remove Quarantine from file permissions in OS X
<pre>
sudo xattr -r -d com.apple.quarantine ~/opt/jdk-13.0.2+8
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-45918703505131068882020-03-03T06:44:00.000-08:002020-03-03T06:44:26.900-08:00Access host from virtualboxTo access host from virtualbox use ip : 10.0.2.2<br />
<br />
Optionally add<br />
<br />
<pre>10.0.2.2 sm-develop</pre><br />
to c:\windows\system32\drivers\etc\hosts
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-91118154597418533782020-02-13T05:27:00.000-08:002020-05-14T23:03:56.741-07:00JXplorerMy JXplorer didt'n show the full tree.
<br />
<br />
Options -> Advanced Options -> Search Limits -> Set 'LDAP Limit' to : 10.000
<br />
<br />
Fixed it<br />
<br />
<br />
When open remember to rigth click and select 'Refresh' on eg. World/dk/zeed to see full treeKimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com1tag:blogger.com,1999:blog-4764831169986948752.post-75723465011758618802019-12-13T02:00:00.001-08:002019-12-13T02:00:38.530-08:00Browse AD with normal windowsstifinder -> <br />
netværk -><br />
Søg i Active Directory<br />
<br />
<br />
Note: Man kan se hvem der er i hvilken gruppe ikke hvilke grupper man er medlem afKimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-29909558022588177122019-11-18T02:08:00.000-08:002019-11-18T02:08:18.889-08:00Change password expiry in Linux<div align="justify" style="background-color: white; box-sizing: inherit; color: #222831; font-family: lato, sans-serif; font-size: 16px;">
“chage” is the command to list & change the password aging information for Linux user account. The chage command changes the number of days between password expiry and the current date. Here’s a real quick on how to show the expiration date of a particular linux user account.</div>
<div align="justify" style="background-color: white; box-sizing: inherit; color: #222831; font-family: lato, sans-serif; font-size: 16px;">
</div>
<h4 style="background-color: white; box-sizing: inherit; color: #222831; font-family: oswald; font-size: 1.5rem; font-weight: 400; line-height: 1.1; margin-bottom: 0.5rem; margin-top: 0px;">
<span style="box-sizing: inherit; font-weight: bolder;">Listing password aging for user</span>:</h4>
<div style="background-color: white; box-sizing: inherit; color: #222831; font-family: lato, sans-serif; font-size: 16px; margin-bottom: 1rem;">
chage command with option -l shows the password expiry details of a user. In this example, the user’s last password change was on Dec 25th 2017 and it expires in 90 days. The user will be notified within login 7 days before expiry.</div>
<pre style="background-color: white; box-sizing: inherit; color: #222831; font-family: Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace; font-size: 14.4px; margin-bottom: 1rem; overflow: auto;"> [root@centos01 ~]# <span style="box-sizing: inherit; font-weight: bolder;">chage -l demouser</span>
<span style="box-sizing: inherit; font-weight: bolder;">Last password change : Dec 25, 2017</span>
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
<span style="box-sizing: inherit; font-weight: bolder;">Maximum number of days between password change : 90
Number of days of warning before password expires : 7</span>
[root@centos01 ~]#</pre>
<h4 style="background-color: white; box-sizing: inherit; color: #222831; font-family: oswald; font-size: 1.5rem; font-weight: 400; line-height: 1.1; margin-bottom: 0.5rem; margin-top: 0px;">
<span style="box-sizing: inherit; font-weight: bolder;">Change the number of days to expire</span>:</h4>
<div style="background-color: white; box-sizing: inherit; color: #222831; font-family: lato, sans-serif; font-size: 16px; margin-bottom: 1rem;">
Use -M option and provide the number of days for expiry.</div>
<pre style="background-color: white; box-sizing: inherit; color: #222831; font-family: Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace; font-size: 14.4px; margin-bottom: 1rem; overflow: auto;"> [root@centos01 ~]# <span style="box-sizing: inherit; font-weight: bolder;">chage -M 120 demouser</span>
[root@centos01 ~]# chage -l demouser
Last password change : Jan 25, 2018
Password expires : May 25, 2018
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 120
Number of days of warning before password expires : 7
[root@centos01 ~]#</pre>
<h4 style="background-color: white; box-sizing: inherit; color: #222831; font-family: oswald; font-size: 1.5rem; font-weight: 400; line-height: 1.1; margin-bottom: 0.5rem; margin-top: 0px;">
<span style="box-sizing: inherit; font-weight: bolder;">Change the password to never expire</span>:</h4>
<div style="background-color: white; box-sizing: inherit; color: #222831; font-family: lato, sans-serif; font-size: 16px; margin-bottom: 1rem;">
You can use chage to make the password never expire with the below options. This sets password and the account to never expire.</div>
<pre style="background-color: white; box-sizing: inherit; color: #222831; font-family: Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace; font-size: 14.4px; margin-bottom: 1rem; overflow: auto;"> [root@centos01 ~]# <span style="box-sizing: inherit; font-weight: bolder;">chage -m 0 -M 99999 -I -1 -E -1 demouser</span>
[root@centos01 ~]# chage -l demouser
Last password change : Jan 25, 2018
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@centos01 ~]#</pre>
<h4 style="background-color: white; box-sizing: inherit; color: #222831; font-family: oswald; font-size: 1.5rem; font-weight: 400; line-height: 1.1; margin-bottom: 0.5rem; margin-top: 0px;">
<span style="box-sizing: inherit; font-weight: bolder;">Change account expiry to specific date:</span></h4>
<div style="background-color: white; box-sizing: inherit; color: #222831; font-family: lato, sans-serif; font-size: 16px; margin-bottom: 1rem;">
You can set the account to expire on specific day or +N number of days from the current date. Here are the examples using chage -E option.</div>
<pre style="background-color: white; box-sizing: inherit; color: #222831; font-family: Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace; font-size: 14.4px; margin-bottom: 1rem; overflow: auto;">[root@dev01 ~]# <span style="box-sizing: inherit; font-weight: bolder;">chage -E 2019-05-12 demouser</span>
or
[root@dev01 ~]# <span style="box-sizing: inherit; font-weight: bolder;">chage -E $(date -d +180days +%Y-%m-%d) demouser</span>
[root@dev01 ~]# chage -l demouser
Last password change : never
Password expires : never
Password inactive : never
<span style="box-sizing: inherit; font-weight: bolder;">Account expires : May 12, 2019</span>
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@dev01 ~]#</pre>
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-84337028107441477772019-11-05T01:30:00.002-08:002020-05-06T01:18:13.776-07:00Shortcuts to serversvi ~/.ssh/config
<br />
<pre>Host jenkins
Hostname 198.234.12.434
User geaddev
Host test
Hostname v-x-e-4ewf.edfer.facb
User geaddev
</pre>
<br />
vi ~/.bash_aliases
<br />
<pre>alias jenkins='ssh jenkins'
alias tst='ssh test'
alias sta='ssh staging'
</pre>
<br />
Add key to server
<br />
<pre>
ssh-copy-id -i ~/.ssh/id_rsa.pub tst
</pre>
Change color
<pre>
alias sta="printf %b '\e]11;#FDA50F\a' && ssh staging"
alias prod="printf %b '\e]11;#770000\a' && ssh prod"
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-7300553957868026932019-10-11T02:19:00.000-07:002019-10-11T02:19:49.801-07:00Use input parameter with mock
<pre>
@SpringBean
MyClass myClass = Stub {
method(_) >> {
Integer id -> map.get(id)
}
}
-------- or --------
@SpringBean
MyClass myClass = Mock()
given:
myClass.method(_) >> {
Integer id -> map.get(id)
}
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-5781607068961341642019-09-09T03:25:00.000-07:002019-09-09T03:25:43.235-07:00Firefox setup<pre>
about:profiles
</pre>
is your friendKimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-61765541055862943222019-08-26T03:25:00.002-07:002019-08-26T03:25:09.894-07:00Automatically adds Jira key to commit message with githooksRun:<br />
git config --global core.hooksPath ~/projects/tools/install-instructions/githooks/<br />
<br />
File:
prepare-commit-msg :
<br />
<pre>#!/bin/bash
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
BRANCH_JIRA_KEY=$(echo $BRANCH_NAME | grep -E -o '^([A-Z]+-[0-9]+)')
if ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $(cat "$1") == "$BRANCH_JIRA_KEY"* ]] && ! [ -z "$BRANCH_JIRA_KEY" ]; then
echo "[$BRANCH_JIRA_KEY] $(cat "${1}")" > "$1"
fi
</pre>
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-81561041037257250582019-05-23T05:38:00.002-07:002019-05-23T05:47:25.813-07:00Validate with java & Spring <pre>
import javax.validation.constraints.NotNull;
public class Car {
@NotNull
private String name;
}
</pre>
<pre>
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
@Service
@Validated
public class CarService {
public save(@Valid Car car) {
// TODO
}
}
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-52711640732930437292019-03-14T06:08:00.000-07:002019-03-14T06:09:58.708-07:00Lambda in Angular (typescript)<pre>return books.bar.filter(function (x) {
return x.id === null;
}).length;
</pre>
<br />
change to<br />
<br />
<pre>return books.bar.filters(b => b.id === null).length;
</pre>
Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-41312190450838274932019-02-24T23:23:00.001-08:002019-02-24T23:24:07.274-08:00<pre>
@Slf4j
@RequiredArgsConstructor
@Configuration
public class SslConfig {
private final SslSettings sslSettings;
@PostConstruct
void init() {
String truststore = sslSettings.getTruststore();
if (truststore != null) {
log.info("Setting truststore: {}", truststore);
System.setProperty("javax.net.ssl.trustStore", truststore);
} else if (System.getProperty("javax.net.ssl.trustStore") != null) {
log.info("Using provided truststore: {}", System.getProperty("javax.net.ssl.trustStore"));
} else {
throw new IllegalStateException("No truststore found!");
}
}
}
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-28024839027261545162019-02-15T01:08:00.000-08:002019-02-15T01:08:43.949-08:00Upload from Jenkinsfile to Artifactory (Declarative Pipeline)<pre>
#!groovy
pipeline {
agent any {
stages {
stage('Clone') {
steps {
echo 'Clone...'
git branch: 'master'
credentialsId: 'jenkins-ssh',
url: 'ssh://git@bitbucket.ccc.net:7999/xxx/test.git'
}
}
stage('Build')
steps {
echo 'Build...'
script {
def server = Artifactory.server 'AFN' // Setup in Jenkins : Manage Jenkins -> Configure System -> Artifactory (Server ID)
def buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true
def rtMaven = Artifactory.newMavenBuild()
rtMaven.tool = 'M3' // Setup in Jenkins :
rtMaven.deployer releaseRepo:'libs-release-local', snapshotRepo: 'libs-snapshot-local', server: server
rtMaven.resolver releaseRepo:'libs-release', snapshotRepo: 'libs-snapshot', server: server
rtMaven.run pom: 'pom.xml', goals: 'clean install', buildInfo: buildInfo
buildInfo.retention maxBuilds: 10, maxDays: 7, deleteBuildArtifacts: true
server.publishBuildInfo buildInfo
}
}
}
}
post {
success {
archiveArtifacts artifacts: '**target/*.jar', fingerprint: true
}
}
}
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-78112193646468724872019-02-07T05:08:00.001-08:002019-02-07T05:08:19.712-08:00firewall for ubuntuSee https://help.ubuntu.com/community/UFW
ufw Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-25910543009557529392019-01-17T23:13:00.000-08:002019-01-17T23:15:02.679-08:00timeout<pre>
setTimeout(() = > {<br />
this.valueField.nativeElement.focus();<br />
}, 1);
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0tag:blogger.com,1999:blog-4764831169986948752.post-51862376569614399712019-01-16T07:01:00.005-08:002019-01-17T23:22:14.989-08:00Stop many call to backend<pre>
private saveTimer;
saveSettings() {
if(this.saveTimer) {
clearTimeout(this.saveTimer);
}
this.saveTimer = setTimeout(() => {
// Call service...
.....
}, 500);
}
</pre>Kimhttp://www.blogger.com/profile/07554101065552217594noreply@blogger.com0