Monday, July 17, 2017

Mongo find by id from one collection in other on remove

var id = db.getCollection('first_collection').find({jobClass:"com.example.CleanerJob"}, { _id: 1 }).next()._id;
db.getCollection('second_collection').findOne({"jobId":id});
db.getCollection('first_collection').findOne(id);

Test it on your local. If it is ok, replace all "findOne" with "remove"

RELATED:
quartz and mongo:
org.quartz.JobPersistenceException: Could not load job class [See nested exception: java.lang.ClassNotFoundException:
at com.novemberain.quartz.mongodb.JobConverter.toJobDetail
...
at com.novemberain.quartz.mongodb.MongoDBJobStore.triggersFired
...


Tuesday, July 11, 2017

Все сотовые Украины

Все мобильные операторы Ураины
All Ukraine mobile operators.
Mobile UA codes.


Wednesday, July 5, 2017

Create one class from another with Stream API

public class User {
public User(

public class UserInfo {
public UserInfo(User log) {

List all = service.getUsers();

List infos = all.stream().map(UserInfo::new).collect(Collectors.toList());

Tuesday, July 4, 2017

Rename git branch

Create a new branch from the old one:

git checkout branch_name
git checkout -b new_branch_name
git push --set-upstream origin new_branch_name

Delete the old branch local and remote:

git branch -D branch_name
git push origin --delete branch_name

Possible you want to rebase or squash commits:

git rebase -i master

=happy=

Thursday, June 8, 2017

NoClassDefFoundError LogManager

PROBLEM:
NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager

SOLUTION:
remove:  -Dlog4j.configuration=file:conf/log4j.xml


Docs:
slf4j: https://www.slf4j.org/legacy.html
jars:
commons-logging-1.2.jar
jcl-over-slf4j-1.7.7.jar or jul-to-slf4j-1.7.12.jar
log4j-1.2.18*.jar
slf4j-api-1.7.12.jar
slf4j-log4j12-1.7.12.jar





Wednesday, June 7, 2017

PROBLEM:
Compilation failure
error: cannot access Consumer

SOLUTION:
Upgrade Java 1.7 to Java 1.8

Tuesday, June 6, 2017

Maven: Unable to find valid certification path to requested target

PROBLEM:
[ERROR] Failed to execute goal on project ***:
Could not resolve dependencies for project ***:
Failed to collect dependencies at ***
Failed to read artifact descriptor for ***
Could not transfer artifact *** sun.security.validator.ValidatorException:
PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target

SOLUTION:
Create folder c:\Users\YOUR_NAME\certs\
Put keys *.cer and certs in it
Run:
mvn -Djavax.net.ssl.trustStore="c:\Users\YOUR_NAME\certs\cacerts" -Dmaven.wagon.http.ssl.ignore.validity.dates=true  -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true  clean install

Wednesday, May 31, 2017

Git howto

Clone the master

git clone https://git/com.company.api.core.git
git clone https://git/com.company.api.core.git []

Create a new branch

git checkout -b my_hello_world_branch
git add .
git commit -m "B012345 Fixed Hello World"
git push -u origin my_hello_world_branch

Checkout

git checkout master
git checkout 
git checkout 

Merge a fresh master into your branch

git checkout master
git pull --rebase
git checkout some_fix_bug
git merge master
git push
or
git fetch
git pull origin master
git push
Before push you might need to resolve conflicts, then add and commit them

Stash

Save not staged (not git added changes) changes in local stack storage
git stash
Pop them back
git stash pop

Reset

Reset staged files, to get them back to local (NOTHING LOST).
git reset HEAD

If you have uncommitted changes that you want to discard (you'll LOST ALL UNCOMMITTED), use this:
This removes all the local uncommitted changes.
git reset --hard 
which is equivalent to
git reset --hard HEAD 

If you want to remove some offending commits from your local branch (you'll LOST PREVIOUS COMMIT), try rewinding it:
git reset --hard HEAD^ #moves HEAD back by one commit 
or e.g. (you'll LOST PREVIOUS three COMMITS)
git reset --hard HEAD~3 #moves HEAD back by 3 commits 
Use these with caution, as you won't be able to undo these operations. Once you're done cleaning up your local branch, use git pull to get the latest code.
Then 
git push -f origin 
If you have it in ignore, use 
 git clean -xf.
You can do 
 git clean -df 
but that will also remove un-tracked directories. Use -n for a dry-run.

Delete branches

Delete branch local
git branch -D 
Delete branch remote
git push origin --delete 

Copy a commit

Apply any commit done in the some branch to the local current branch
git cherry-pick c1qwlkjfcnc432289a42d34ab4b23803c9

Show list all

git branch
git tag
git branch -r
git remote show origin

Checkout Tags

After the clone, you can list the tags with 
 git tag -l 
and then checkout a specific tag: 
 git checkout tags/

Diff

Show changes between commits (Diff man )
git diff 4223732fhkjsdve1ffce96563367e8fdc^
git diff HEAD^
git diff HEAD~2

Rename a tag

Here is how to rename a tag old to new:
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags

Show staged diff

You can show changes that have been staged with the --cached flag:
git diff --cached

Show diff latest 10 commit in current folder

git log -10 . | grep commit | sed 's/commit //' | xargs  git diff

Squashing commits with rebase