Thursday, January 30, 2020

CREATE IMAGE BACKUP WINDOWS 10 CREATION FAILS DUE TO CORRUPTED VOLUME


>PROBLEM

Attempt to create a Windows system image using Windows native tool returns an error message like this:

Failed to create image due to corrupted volume \\{9834834138743...}


>SOLUTION

Restart the machine using the Windows Repair/Rescue disk of the same version of the system that requires repair. Do not use different a version even though it seems to work fine.

Select the option "Windows Memory Diagnostic Tool"

I know, it seems awkward because the first thing that triggers our minds is something about the RAM memories itself.







Windows Cannot Find a System Image on This Computer


>PROBLEM


Windows 10 Fails to Find System Image Backup

Attempt to restore a system image fails because the Repair/Rescue disk is not able to present the backup list, unlike the image below, the fields always return blank, without result.

An attempt to select a system image (radio option above to the buttons) returns an empty list.


NOTE - POST EXTENDED
Other issues and additional solutions are available here (an extension of this post), including the download of the Windows Rescue/Repair iso image to create a bootable CD or pen drive.


>SOLUTION


Supposing the source HDs where the images were saved are NOT corrupted, try another Repair/Rescue disk created by the same version of Windows that created the system images.

This issue may happen when an image is created with a different version of Windows than the Windows version that created the Repair/Rescue disk.

If you do not have another machine, try to find somebody who has a Windows system similar to your system, then create the rescue disk.





Wednesday, January 22, 2020

node.js: TypeError: Router.use() requires a middleware function but got a Object


>PROBLEM

Running node.js/express application, returns error:

TypeError: Router.use() requires a middleware function but got a Object


>SOLUTION

Go to the router files and check if module.export sttm is present.
Example:

module.exports = router;

>ENV

node.js v12.4.0
Express
Windows 10


Monday, January 20, 2020

node.js: req.body.PARAM_NAME fails returning undefined


Many times a failure comes from subtle things.

Both app.post/app.get  and  router.post/router.get accepts req.body.PARAM_NAME.

Example:

app.get('/', function(req,res){
 var email = req.body.email;
 var password = req.body.passwd;
 console.log('email: ' + email);
 console.log('pass: ' + password);
 res.render("index");
});

router.get('/alo/', function(req, res, next) {
 var email = req.body.email;
 var password = req.body.passwd;
 console.log('email: ' + email);
 console.log('pass: ' + password);
 res.render('alo', { title: 'Alo Express!' });
});

When using router and req.body returns undefined values, check if the code is well implemented, if not missing module.exports clause.

Follow by the example.

app.js file:
..
const indexRouter = require('./routes/indexRouter');
app.use('/', indexRouter);
..
module.exports = app;
 
indexRouter.js file:
..
const router = express.Router();
..
router.get('/alo/', function(req, res, next) {
  res.render('alo', { title: 'Alo Express!' });
});
..
module.exports = router;
Naturally the dependencies and app's configuration must be implemented, for example:
const express = require('express');
const bodyParser = require('body-parser');
const cookeParser = require('cookie-parser');
const app = express();
const passport = require('passport');
const { check, validationResult } = require('express-validator');
const session = require('express-session')
const hbs = require('express-hbs');
const flash = require('flash');
const router = express.Router();
const view_path = __dirname + '/views/';
const public_path = __dirname + '/public/';
app.use(express.static(view_path))
app.use(express.static(public_path));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(cookeParser());
app.use(passport.initialize());
app.use(passport.session());
app.set('view engine', 'html');
app.engine('html', require('hbs').__express);
 
@SEE:
Usando middlewares

 

Friday, January 17, 2020

Maven compilation asm issue: nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class




>PROBLEM


A deployable file is created using:

  mvn clean install


Attempt to run fails:

  java -jar myfile.war

generating the following message (snippets):

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL 
[jar:file:/L:/work/dev/java/projects/tpzapp/parent/sisgit2/sisgit2-2.0.war!/WEB-INF/classes!/br/net/telespazio/sisgit2/app/Sisgit2App.class]; 
nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
 at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:311) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
 at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:272) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
 at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:135) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
...
Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
 at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_112]
 at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_112]
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_112]



>SOLUTION


Switched maven's compilation plugins configuration as follows:


>>BEFORE


<packaging>war</packaging>
<plugin>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-maven-plugin</artifactid>
</plugin>
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-surefire-plugin</artifactid>
</plugin>

         

>>AFTER


<packaging>jar</packaging>
<plugin>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-maven-plugin</artifactid>
</plugin>


>ENV

Windows 10
Java 8
Maven 3.x

Saturday, January 11, 2020

Vim editor – Commands’ Summary (Cheat Sheet)


MINI TUTORIAL - MINIMAL KNOWLEDGE


This post intends to give you the very initial steps to begin using Vim, supplying a Cheat Sheet collected from many sources across the years.

To begin, let's create a hello text file.
Using the console (prompt), type the following:

vim hello.txt
Type I (i) to get into "insert mode".
Type: hello world!
Type ESC to exit.
Type colon (:) then x to save:
:x
Use enter to exit.

That's it. You are "initiated" - simple like that.




Vim editor has "modes" - commands' contexts.

When you open the editor you may issue a set of commands.
See basic navigation below.

To enter into edit mode, use insert key or the I(i) key.
To exit from insert mode, use ESC.

On ESC mode, if you type colon (:), you get a command line at the bottom that enables another set of commands. For instance, if you desire to add line numbers, you do: 

Type ESC.
Type colon (:).
Type "set nu"
Type ESC to exit from the command line.

Now the lines have sequential numbers.

Vim is a super editor, having everything you wonder or you even never supposed to.

It worths to get acquainted to it because it is the default editor on most *nix systems, like AIX, Unix and flavors of Linux.

When using console (SSH connection), Vim is the ubiquitous solution - everywhere has a "vim" command available for you.

Although the documentation turns into something scaring it is not a big deal if you dive into its resources by section of interests.
For instance, what do you want to do?
Find a string, replace text, mark a point on the text to get there fast, split windows, compare files, etc.


I know, I know - it is very strange to alternate between insert mode and command mode. Do not complain - it is just a matter of habit. You'll see!  :-)

Advantage of that: you have extra power while having to modes.

Vim, my old friend...


BASIC NAVIGATION (NOT ON INSERT MODE)

NOTE:  the behavior depends upon the keyboard type.
If not working, try the Fn key plus the shortcut.
Example: Fn + k

  • k – navigate upwards
  • j – navigate downwards
  • l – navigate right side
  • h – navigate left side
  • 0 – go to the starting of the current line.
  • ^ – go to the first non blank character of the line.
  • $ – go to the end of the current line.
  • g_ – go to the last non blank character of the line.
  • H – Go to the first line of current screen.
  • M – Go to the middle line of current screen.
  • L – Go to the last line of current screen.
  • ctrl+f – Jump forward one full screen.
  • ctrl+b – Jump backwards one full screen
  • ctrl+d – Jump forward (down) a half screen
  • ctrl+u – Jump back (up) one half screen
  • e – go to the end of the current word.
  • E – go to the end of the current WORD.
  • b – go to the previous (before) word.
  • B – go to the previous (before) WORD.
  • w – go to the next word.
  • W – go to the next WORD.
  • { – Go to the beginning of the current paragraph. By pressing { again and again move to the previous paragraph beginnings.
  • } – Go to the end of the current paragraph. By pressing } again and again move to the next paragraph end, and again.
  • N% – Go to the Nth percentage line of the file.
  • NG – Go to the Nth line of the file.
  • G – Go to the end of the file.
  • `” – Go to the position where you were in NORMAL MODE while last closing the file.
  • `^ – Go to the position where you were in INSERT MODE while last closing the file.
  • g – Go to the beginning of the file.
  • % – Go to the matching braces, or parenthesis inside code.
  • Use ‘.’ to repeat the last command.
    The command will be repeated considering the current caret position.

MORE DETAILED INFORMATION, SEE:

Wednesday, January 8, 2020

Docker: Hardware assisted virtualization and data execution protection must be enable in the BIOS


>PROBLEM

Docker fails to start, returning the following message:

Hardware assisted virtualization and data execution protection must be enabled in the BIOS
See https://docs.docker.com/docker-for-windows/troubleshoot/#virtualization-must-be-enabled







>SOLUTION

Turn on hyper-v.
As Administrator, issue the command:

   bcdedit /set hypervisorlaunchtype auto start

Restart the machine.

*** IMPORTANT NOTE:

Vagrant with VirtualBox require to turn off hyper-v:

  bcdedit /set hypervisorlaunchtype off

That way, if you have both installed, once their configurations are conflicting, it is not possible to have both working at the same time.





>ENV

Windows 10
Vagrant v2.2.6
VirtualBox 6.0

>SEE

Vagrant: The box you're attempting to add doesn't support the provider you requested

Vagrant: There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox


Vagrant: There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox


>PROBLEM

Starting vagrant:

    vagrant up

Causes the follwing issue:

There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox. 
The command and stderr is shown below.

Command: ["startvm", "01748371-61a5-4c0e-a279-9077bab91aaf", "--type", "headless"]
Stderr: VBoxManage.exe: error: Call to WHvSetupPartition failed: ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole


>SOLUTION

Turn off  hyper-v.
As administrator, issue the comand:

    bcdedit /set hypervisorlaunchtype off

Restart machine.


*** IMPORTANT NOTE:

Docker requires hyper-v on:

   bcdedit /set hypervisorlaunchtype auto start

So, after the environment is restarted, docker will stop working.
Docker and Vagrant/VirtualBox requires conflicting environment configuration.




Vagrant: The box you're attempting to add doesn't support the provider you requested


>PROBLEM

Starting Vagrant using VirtualBox as follows:

   vagrant up

Fails to start returning this message:

The box you're attempting to add doesn't support the provider you requested. 
Please find an alternate box or use an alternate provider. 
Double-check your requested provider to verify you didn't simply misspell it.

If you're adding a box from HashiCorp's Vagrant Cloud, make sure the box is
released.

Name: ubuntu/trusty64
Address: https://vagrantcloud.com/ubuntu/trusty64
Requested provider: [:hyperv]


If you force, using:

  vagrant up --provider virtualbox

vagrant then returns the following:

Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:
4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0

The provider 'virtualbox' that was requested to back the machine
'mongod-m103' is reporting that it isn't usable on this system. The
reason is shown below:

Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:

4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0

          A Vagrant update may also be available that adds support for the version
        you specified. Please check www.vagrantup.com/downloads.html to download
        the latest version.


>SOLUTION

Download a version of VirtualBox compatible with Vagrant's version.
For instance, if vagrant v2.2.6, use vitualbox 6.0.

Download here (change the url's version suffix for the one desired):

https://www.virtualbox.org/wiki/Download_Old_Builds_6_0


>ENV

Windows 10
Vagrant v2.2.6
VirtualBox 6.0

Sunday, January 5, 2020

git Changes not staged for commit remove message



>PROBLEM

git status command returns the following message:

  git Changes not staged for commit remove message


>SOLUTION

This kind of problem may be originated when a folder is added to .gitignore without adding and committing the repository before .gitignore inclusion and committing after.
A straightway is to move the folder that contains the inconsistency to a temporary folder. Then add and commit again.

Example, supposing the following project structure:

+-- myProjectRoot
+--folder1
+--folder2
+--folderWithIssue

To fix, do:

cd /home/myProjectRoot
- windows:
cd C:\myProjectRoot

git add *
git commit -am "my message here"

mv /home/myProjectRoot/folderWithIssue /home/temp
- windows:
move folderWithIssue C:\temp

git add *
git commit -am "my message here"
git push

mv /home/temp/folderWithIssue .
- windows:
move C:\temp\folderWithIssue .

git add *
git commit -am "my message here"
git push


node.js: morgan deprecated default format: use combined format



>PROBLEM

The server throws the following server's message:
  morgan deprecated default format: use combined format

>SOLUTIONS

>>POSSIBILITY #1 ----------------------------------

BEFORE:
app.use(logger);


AFTER:
app.use(logger('combined'));


@FROM:
stackoverflow.com/questions/36397812/morgan-deprecated-expressjs/36398066


>>POSSIBILITY #2 ----------------------------------

BEFORE:
app.use(logger(process.env.AMBIENTE));
...
require('dotenv').config();


AFTER:
require('dotenv').config();
..
app.use(logger(process.env.AMBIENTE));

Friday, December 27, 2019

WordPress fails to update plugins, Posts or Sign in


NOTE: 
Although the examples concern to Linux env, an analogy may be done to other environments converting the commands and paths.
In the examples below, replace "mysite" by the name of your site folder.

>ATTEMPT #1 - FILES' PERMISSION

Check the owner of your data, if www-data, do:

chown www-data -R /home/mySite/public_html
chgrp www-data -R /home/mySite/public_html

>ATTEMPT #2 - PLUGIN'S ISSUE

CHECKING ONE BY ONE BEGINNING BY THE LAST ONES

If the issue happens after plugins' update or a new plugin installation, it is necessary to identify the plugin that causes the issue.
In this case, just remove the plugin by moving its code to a temporary folder.
If the issue disappears, the last removal indicates the responsible.
Example:

mv /home/mysite/public_html/wp-content/plugins/do-something /home/temp/plugins


REMOVING ALL AND REINSERTING ONE BY ONE 

Another method removes all and insert one by one (or small groups) until the issue comes up, identifying the cause.
Example reinserting a group of three:

mv /home/mysite/public_html/wp-content/plugins /home/temp
mkdir /home/mysite/public_html/wp-content/plugins
mv /home/temp/plugins/do-something /home/mysite/public_html/wp-content/plugins
mv /home/temp/plugins/do-something2 /home/mysite/public_html/wp-content/plugins
mv /home/temp/plugins/do-something3 /home/mysite/public_html/wp-content/plugins
chown www-data -R /home/mySite/public_html/plugins
chgrp www-data -R /home/mySite/public_html/plugins
#Go to the site, menu, plugins and activate the inserted plugins, then test.
#If the issue returns, one of the new three plugins is the responsible.
#To discover the one, repeate the operation removing the three ones and inserting one by one.
More details at:


>ATTEMPT #2 - WORDPRESS FILES' ISSUE

If the attempt one is ineffective, then it may be a major problem like Wordpress corruption, considering that any other procedure above was successful.

>PROBLEM

The site fails to update post.
Attempt to update a plugin works differently, redirecting to another page retuning a detailed log like wordpress upgrade - unusual since upgrade is done on the same page - the plugins' page.
After log off, login also fails.
The problem comes apparently from nothing.

>SOLUTION

Rename the current site to preserve its content.
Performed a new Wordpress installation but preserving its current database.
The new installation is connected to the previous database.
The configurations and contents from the previous installation are copied to the new one, including plugins, uploads and other key folders.

Example:

- database backup, just in case:
  mysqldump --all-databases --routines  --triggers -uroot -proot > dump.sql

- creating a new mysite directory to install a new wordpress:
  mv /home/mysite /home/mysite_
  mkdir /home/mysite
  chown root:root -R /home/mysite
  chmod 755 -R /home/mysite
  mkdir /home/mysite/public_html

- set permissions required by wordpress running by apache2:
  chown www-data -R /home/mysite/public_html

- create log dir:
  mkdir /home/mysite/public_html/logs

- installing the new site:
  cd /home/backup/wordpress
  unzip wordpress-5.3.2-en_GB.zip
  mv wordpress/* /home/mysite/public_html
  chown www-data -R /home/mysite/public_html
  chmod 755 -R /home/mysite/public_html

- create a symlink on apache2's /var/www folder:
  cd /var/www
  ln -s /home/ipstuff/public-html mysite

- point to mysite:  
  http://ultering.com/mysite/

- get the database information
database name: mysite
username: mysite
password: secret
host: localhost

- after the initial login, the key folders are copied from previous intallation to preserve configuration and content:

  rm -Rf /home/mysite/public_html/wp-content/plugins
  cp -R /home/temp/mysite/plugins /home/mysite/public_html/wp-content
  chown www-data -R /home/mysite/public_html
  chmod 755 -R /home/mysite/public_html

  cp -R /home/mysite_/public_html/wp-content/themes/* /home/mysite/public_html/wp-content/themes

   cd /home/mysite

- backup from previous content, just in case:   
   tar czvf itstuf_temp.tar.gz /home/mysite/public_html

- copying key folders containing content and configuration:
  cp -R /home/mysite_/public_html/wp-content/uploads /home/mysite/public_html/wp-content
  cp -R /home/mysite_/public_html/wp-content/w3tc-config /home/mysite/public_html/wp-content
  cp -R /home/mysite_/public_html/wp-content/wflogs /home/mysite/public_html/wp-content
  cp -R /home/mysite_/public_html/wp-content/nfwlog /home/mysite/public_html/wp-content
  cp -R /home/mysite_/public_html/wp-content/.tmb /home/mysite/public_html/wp-content
  cp -R /home/mysite_/public_html/wp-content/.quarantine /home/mysite/public_html/wp-content
  cp -R /home/mysite_/public_html/wp-content/mu-plugins /home/mysite/public_html/wp-content
  cp -R /home/mysite_/public_html/wp-content/wp-link-status-salt.php /home/mysite/public_html/wp-content
  cp -R /home/mysite_/public_html/wp-content/index.php /home/mysite/public_html/wp-content

- moving the backup to a temp dir to be downloaded and removed:  
  mv /home/mysite/public_html/wp-content/uploads /home/temp



Tuesday, August 20, 2019

ECLIPSE - Cannot change version of project facet Dynamic Web Module to 3.1




>PROBLEM

Attempt to switch Web Module version in "Project Facets" is denied, not allowed, returning a message like this:

Cannot change version of project facet Dynamic Web Module to 3.1. sisgit2 line 1 Maven Java EE Configuration Problem



>SOLUTION

Go to the eclipse's project root directory at:

$ECLIPSE_PROJECT_ROOT\.settings\org.eclipse.wst.common.project.facet.core.xml


Change here:
From:
<installed facet="wst.jsdt.web" version="1.0"></installed>
To:
<installed facet="jst.web" version="3.1"></installed>

>ENV

Windows 10
Eclipse 2019


@FROM:
stackoverflow.com/questions/18122336/cannot-change-version-of-project-facet-dynamic-web-module-to-3-0

Sunday, August 18, 2019

VSCODE: EDITOR: Number of Opened Tabs Setup


To set the number of opened tabs on the editor, go to the menu, File, Preferences, Settings.
Follow by the images, yellow arrows.






Sunday, August 11, 2019

node.js: flash: a req.session is required!



>PROBLEM


a req.session is required!
AssertionError [ERR_ASSERTION]: a req.session is required!
    at L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\flash\index.js:6:5
    at Layer.handle [as handle_request] (L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\express\lib\router\index.js:317:13)
    at L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\express\lib\router\index.js:335:12)
    at next (L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\express\lib\router\index.js:275:10)
    at logger (L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\morgan\index.js:144:5)
    at Layer.handle [as handle_request] (L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\express\lib\router\index.js:317:13)
    at L:\work\devcli_\javascript\node\projects\tellme4\tellme4\node_modules\express\lib\router\index.js:284:7


>SOLUTION

>>WRONG:

//*** wrong place of flash configuration, before session:

app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use(session({
  secret: "fd34s@!@dfa453f3DF#$D&W",
  resave: false,
  saveUninitialized: true,
  cookie: { secure: !true }
}));


>>RIGHT:

app.use(passport.initialize());
app.use(passport.session());
app.use(session({
  secret: "fd34s@!@dfa453f3DF#$D&W",
  resave: false,
  saveUninitialized: true,
  cookie: { secure: !true }
}));
//*** right place after session:
app.use(flash());


>ENV
w10
node.js

Tuesday, September 11, 2018

Spring: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ...: Unsatisfied dependency expressed through field


>PROBLEM
Starting the application, it stops working throwing the following exception:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ulteringController': Unsatisfied dependency expressed through field 'stateSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'estadoSvc': Unsatisfied dependency expressed through field 'estadoRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'estadoRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Could not create query metamodel for method public abstract br.com.ultering.model.State br.com.ultering.model.repository.EstadoRepository.findBySigla(java.lang.String)!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]


>SOLUTION

@Autowired
private StateSvc stateSvc;

ORIGINAL

@Service("estadoSvc")
@Transactional
public class StateSvcImpl extends AbstractSvc implements StateSvc {

FIXED

@Service("stateSvc")
@Transactional
public class StateSvcImpl extends AbstractSvc implements StateSvc {


>ENV
Windows
Spring Boot

Saturday, June 16, 2018

git: Resolving .gitignore issue in a messy project

PROBLEM
There many different .gitignore files into your project.
The ".gitignore" seams not working at all.
Your pull like commands comes with "ignored files".
SOLUTION
  1. Create a .gitignore pattern.
  2. Fix your repository's .gitignore file into master, at least.
    Same to develop or another very used branch.
  3. After updating or merging your local stuff, check the .gitignore content.
    If the local .gitignore file is not like the pattern, just overwrite it with the pattern file.
    If your project is too messy,  simply overwrite local using the pattern as a "just after procedure", to make sure.
  4. Avoid having more than one .gitignore file.
    Set just one under the project's root dir.
    In most of all usual cases, is enough.

.gitignore Example of a Java Project With Sonar and Docker files.

# Add any directories, files, or patterns you don't want to be tracked by version control
# ECLIPSE'S
**/target
**/.settings
**/.apt_generated
**/.metadata
*.classpath
*.factorypath
*.project
*.class
*.tern-project
# PROJECT'S STUFF
*.Jenkinsfile
*.JenkinsfileTeste
*.arquivoPdf.txt
*.arquivoPng.txt
*.arquivoXls.txt
*.axis.log
# TO BE USED TO LOG REPORTS AND MAINTENANCE

#WHY .GITIGNORE SEEMS TO FAIL

Follow the figures below.




After fixing .gitignore file:




Another reason when .gitignore fails is caused by a "conflicting state".



*.log.out
 @FROM: my alternative site

Wednesday, April 25, 2018

Maven exception "Fatal error compiling: invalid target release:..."

>PROBLEM
When running "mvn clean install" you get:
  Fatal error compiling: invalid target release:


>SOLUTION
Set JAVA_HOME envvar or include it into the script which runs maven.
  export JAVA_HOME="/home/portables_d/jdk1.8.0_144"

>ENV
linux/debian

Maven fails to load spring references



>PROBLEM
Maven fails to load spring references

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from http://maven.repository.redhat.com/ga/ was cached in the local repository, resolution will not be reattempted until the update 
 interval of redhat-ga-repository has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to redhat-ga-repository (http://
 maven.repository.redhat.com/ga/): maven.repository.redhat.com





>SOLUTION
Check the repository location into ".m2\settings.xml".

For instance:
C:\Users\YourLogin\.m2\settings.xml

In this case the localRepository was configured with linux's location and not windows as it was supposed to be:

***WRONG:
/home/portables_d/mvnlibs

+++RIGHT:
${env.LOCAL}\portables_d\mvnlibs



>ENV
windows
eclipse
java8

Tuesday, March 6, 2018

Remove dashboard bar to a profile from WordPress site


METHOD #1 - Plugin

Suppose that you have a site that you desire to supress the dashboard bar and admin bar to the users except the administrators.

Use "Editor Menu And Widget Access" plugin and just set the configuration like this:




-----------------------------------------------------------------------------------------------------------
METHOD #2 - Coding

@DEPRECATED:
In recent versions using others themes, the solution was not effective anymore, requiring more code digging. A better alternative solution was adopted above.


Suppose that you have a site that you desire to supress the dashboard bar and admin bar to the "subscriber" profile.
Follow the example.

1. Go to the themes' function.php file.
For instance, if the active theme is named "vale", edit:
$SITE_DIR/public_html/wp-content/themes/vale/function.php

2. Add the following

// This file is not called from WordPress. We don't like that.
! defined( 'ABSPATH' ) and exit;

add_action( 'init', 'fb_remove_admin_bar', 0 );
function fb_remove_admin_bar() {
if ( current_user_can('subscriber') || current_user_can('assinante') ) {
wp_deregister_script( 'admin-bar' );
wp_deregister_style( 'admin-bar' );
remove_action( 'init', '_wp_admin_bar_init' );
remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
// maybe also: 'wp_head'
foreach ( array( 'admin_head' ) as $hook ) {
add_action(
$hook,
create_function(
'',
"echo '';"
)
);
}
}
}


Adapted from:
https://wordpress.stackexchange.com/questions/77639/disable-the-admin-bar/77648#77648

Remove excert from WordPress standard search



The standard search box generates by default a list of titles and excerpts.

The bold text is the title, the other (smaller characters) is the excerpt.

To exclude the excerpt from the default search, check the theme the site is using.
In this example is TwentyFifteen.
Go to the theme's folder and follow the procedure below.



1. Edit content-search.php.
This file is at:

/home/mynumbers/public_html/wp-content/themes/twentyfifteen/content-search.php


2. Remove the entry in orange:

 <header class="entry-header">
  <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
 </header><!-- .entry-header -->

 <div class="entry-summary">
  <?php the_excerpt(); ?>
 </div><!-- .entry-summary -->

 <?php if ( 'post' == get_post_type() ) : ?>
NOTE: always take note of a reference from where the code was remove in order to rollback, just in case.

After this procedure, just the bold title shall appear.


Saturday, November 25, 2017

MySQL server fails to start

>PROBLEM

After server reboot MySQL fails to start.
For instance:
  /etc/init.d/mysql restart
or
  service mysql stop
  service mysql start
 
Returns "failed" message.


>SOLUTION

1. Create data backup:
  cp -R /var/lib/mysql /var/lib/mysql_171115

2. Run the following cmds:
  chown -R mysql:mysql /var/lib/mysql
  mysql_install_db --user=mysql -ldata=/var/lib/mysql/

The last cmd output may show you the reason.
- Example:
  root@setgetsrv:/home/alsdias/dev/scripts# mysql_install_db --user=mysql -ldata=/var/lib/mysql/
  Installing MySQL system tables...
  171125 12:02:54 [Warning] The syntax '--log' is deprecated and will be removed in a future release. Please use '--general-log'/'--general-log-file' instead.
  171125 12:02:54 [Warning] The syntax '--log' is deprecated and will be removed in a future release. Please use '--general-log'/'--general-log-file' instead.
  171125 12:02:54 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
  171125 12:02:54 [Note] /usr/sbin/mysqld (mysqld 5.5.55-0+deb7u1-log) starting as process 12458 ...
  171125 12:02:54 [ERROR] /usr/sbin/mysqld: unknown variable 'log_slow_verbosity=query_plan'
  171125 12:02:54 [ERROR] Aborting

3. Solving.
- The output shows issue with:
log_slow_verbosity = query_plan
- then, comment the line:
#log_slow_verbosity = query_plan

>ENV
debian whezzy
MySQL 5.X

Friday, October 13, 2017

Spring Boot: the client fails to find the service returning 404.


>PROBLEM

The application starts successfully, but the client fails to access the service getting 404.

Controller's original code:
@RestController
@RequestMapping("/api")
@CrossOrigin("*")
public class HelloController {

    @Autowired
    IHelloRepository helloRepository;

    @GetMapping("/hellos")
    public List getAllHellos() {
        Sort sortByCreatedAtDesc = new Sort(Sort.Direction.DESC, "createdAt");
        return helloRepository.findAll(sortByCreatedAtDesc);
    }



>SOLUTION

***WRONG:     @GetMapping("/hellos")
***RIGHT:        @GetMapping("/hellos/")

@RestController
@RequestMapping("/api")
@CrossOrigin("*")
public class HelloController {

    @Autowired
    IHelloRepository helloRepository;

    @GetMapping("/hellos/")
    public List getAllHellos() {
        Sort sortByCreatedAtDesc = new Sort(Sort.Direction.DESC, "createdAt");
        return helloRepository.findAll(sortByCreatedAtDesc);
    }


>ENV

Java 1.8
SpringBoot 1.5.6

Sunday, October 1, 2017

node.js: Error: Cannot find module .. bin/www


>PROBLEM

When the server is started using:
  npm start app.js
it returns the following error message:

  Error: Cannot find module 'L:\work\devcli_\javascript\node\work\ndprj01\ndprj01\bin\www'
      at Function.Module._resolveFilename (module.js:489:15)
      at Function.Module._load (module.js:439:25)
      at Function.Module.runMain (module.js:609:10)
      at startup (bootstrap_node.js:158:16)
      at bootstrap_node.js:598:3
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! ndprj01@0.0.0 start: `node ./bin/www "app500c6sql"`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the ndprj01@0.0.0 start script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


>SOLUTION

Edit "package.json" file.
The error tell at:
  Error: Cannot find module 'L:\work\devcli_\javascript\node\work\ndprj01\ndprj01\bin\www'
that it is a problem concerning "bin\www".
Find "bin\www" and take it out.

- Before:

{
  "name": "ndprj01",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "async": "^2.5.0",
    "bluebird": "^3.5.0",

- After:
{
  "name": "ndprj01",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node "
  },
  "dependencies": {
    "async": "^2.5.0",
    "bluebird": "^3.5.0",






>ENV
windows
node.js

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...