Git Add user to local repository

user@Sys208:~/works/Project1/data-entry/Data-entry-tool$ git add -A && git commit -m “Initial Commit.”

*** Please tell me who you are.

Run

git config –global user.email “you@example.com”
git config –global user.name “Your Name”

to set your account’s default identity.
Omit –global to set the identity only in this repository.

fatal: unable to auto-detect email address (got ‘user@Sys208.(none)’)

To set the user local to the repository navigate to the working directory and open a terminal and issue the following commands

user@Sys208:~/works/Project1/data-entry/Data-entry-tool$ git config user.email “abc@hiplind.com”
user@Sys208:~/works/Project1/data-entry/Data-entry-tool$ git config user.email
abc@hiplind.com
user@Sys208:~/works/Project1/data-entry/Data-entry-tool$

 

 

Samples on Play

http://ics-software-engineering.github.io/play-example-mysql/

http://pedrorijo.com/blog/play-slick/

 

https://github.com/daxyonis

https://alexgaribay.com/2014/06/16/authentication-in-play-framework-using-java/

Chat Application

http://matthiasnehlsen.com/blog/2013/06/23/angularjs-and-play-framework/

Reactive, real-time log search with Play, Akka, AngularJS and Elasticsearch

Forums built with Play

https://github.com/hakandilek/publicplay

https://devhub.io/repos/eljaydub-play2-crud

http://www.programcreek.com/java-api-examples/index.php?source_dir=play2-crud-master/project-code/app/play/utils/crud/views/Utils.java#showField-FieldMetadata-fieldMetadata-Object-o

Improving Play! 2.1 with Knockout.js

 

http://vyazici.blogspot.in/2012/03/chat-application-with-play-framework.html

http://www.vdzon.com/2015/08/24/creating-a-web-application-with-play-akka-and-java/

http://geeks.aretotally.in/tag/play-framework-2/

https://dzone.com/articles/persistence-and-dao-testing-0

https://github.com/ianrae/mettle-framework

https://www.toptal.com/java/building-modern-web-applications-with-angularjs-and-play-framework

https://github.com/unterstein/play-knockout-sample

http://www.ibm.com/developerworks/library/wa-playful-web-dev-1-trs-bluemix/

 

Optimizing Static Asset Loading with Play Framework

FORMS

https://github.com/JoseVte/template-api-rest-java-playframework.git

https://github.com/opensas/play-demo/wiki/Step-6—styling-form

JPA

Neat Explanation of using JPA with Play:- http://www.waitingforcode.com/play-framework/database-and-jpa-in-play-framework/read

application.conf example :- https://raw.githubusercontent.com/akquinet/Play–Framework-Example–Library/master/conf/application.conf

http://stackoverflow.com/questions/20836923/difference-between-jpa-and-ebean-play-framework

https://github.com/nikitsenka/play-jpa-java-example

https://github.com/beingsagir/play-java-spring-data-jpa

https://github.com/jamesward/play2bars/tree/java-jpa

https://github.com/zarinfam/play24-guice-spring

http://gbmetzner.github.io/Multiple-DB/

Authorization

https://github.com/schaloner/deadbolt-2

http://stackoverflow.com/questions/28459333/how-to-build-an-uber-jar-fat-jar-using-sbt-within-intellij-idea

https://www.tunnelbear.com/blog/authenticating-users-in-the-play-framework/

https://github.com/mslinn/play-authenticated

https://github.com/knoldus/jwt-play-authentication

https://github.com/TunnelBear/PlayAuthenticationSample

ACTION COMPOSITION

http://iankent.uk/blog/action-composition-in-play-framework/

https://resources.oreilly.com/examples/9781783982400/tree/master/2400OS%20code%20bundle/Chapter%207/pfe-java/app/controllers

http://bryangilbert.com/post/code/scala/action-composition-auth/

Action composition in the Play Framework

APIs, REST

https://github.com/JoseVte/template-api-rest-java-playframework

Building a REST API in Java and Scala Using Play Framework – Part 1

https://semaphoreci.com/community/tutorials/how-to-add-integration-tests-to-a-play-framework-application-using-scala

DI

Dependency injection in Play Framework using Scala

Caching

Introducing the Google Guava Cache

http://www.concretepage.com/google-api/google-guava-cache-example-using-loadingcache-cachebuilder-and-cacheloader

http://fanli7.net/a/JAVAbiancheng/JAVAzonghe/20131003/guicing-play-framework.html

EXPLANATION:http://codingjunkie.net/google-guava-cache/

CACHING EXAMPLE :

https://www.javacodegeeks.com/2015/01/using-google-guava-cache-for-local-caching.html

https://github.com/Haneke/HanekeSwift/issues/101

http://mydailyjava.blogspot.in/2013/07/extending-guava-caches-to-overflow-to.html

 

https://blog.codecentric.de/en/2016/03/caching-de-luxe-spring-guava/

https://vladmihalcea.com/2014/03/03/caching-best-practices/

MODULE DEFINITION and CONFIGURATION

Hibernate with JPA Annotations and Guice

 

Best of Breed Opensource on Play

https://www.theguardian.com/info/developer-blog/2015/dec/30/how-to-add-a-form-to-a-play-application

https://blog.redelastic.com/diving-into-akka-streams-2770b3aeabb0

http://matthiasnehlsen.com/blog/2014/08/04/building-a-geo-aware-link-shortener-with-play-framework/

File Cutters, File Spiltting

https://blog.knoldus.com/2012/03/20/handling-large-data-file-using-scala-and-akka/

https://www.programcreek.com/java-api-examples/?code=reljicd/play-framework-blog/play-framework-blog-master/app/actions/PostExistsAndUserIsOwnerAction.java# playframework samples

https://www.programcreek.com/java-api-examples/?code=CSCfi/exam/exam-master/app/security/CombinedRoleAndPermissionHandler.java#

https://github.com/commercetools/commercetools-sync-javahttps://github.com/commercetools/sphere-play-sdk/tree/0c8abf48b45f349d97f28d6b6b8fc56b9e8a8374

http://stackoverflow.com/questions/41402495/akka-stream-splitting-a-stream-of-bytestring-into-multiple-files

http://stackoverflow.com/questions/29517478/splitting-a-large-log-file-in-to-multiple-files-in-scala

https://github.com/johandahlberg/Splitter

http://james-iry.blogspot.in/2007/09/monads-are-elephants-part-1.html

http://stackoverflow.com/questions/13454347/monads-with-java-8

https://stedolan.github.io/jq/tutorial/

grpc play framework:

https://github.com/raboof/play-scala-grpc-server/tree/master/app

https://github.com/jfloff/grpc-java-sbt

http://jlogg.weebly.com/blog/writing-rest-apis-using-the-grpc-framework

Setting up PHP Environment for Development

https://gist.github.com/DaRaFF/3995789

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

https://www.linode.com/docs/websites/apache/apache-web-server-on-ubuntu-14-04

http://serverfault.com/questions/357108/what-permissions-should-my-website-files-folders-have-on-a-linux-webserver

OSGI CONTAINERS

https://github.com/doolse/sbt-osgi-felix

https://github.com/mbknor/ddsl-play2-module

https://github.com/mathieuancelin/play-osgi

https://github.com/tux2323/sbt-osgi-demo

https://github.com/sbt/sbt-osgi

Real time scenarios on GIT

git clone https://github.com/beingsagir/play-java-spring-data-jpa.git
git add -all : add all files new and modified locally

git add -A && git commit -m “Comment formatting, 24 hour cache loader, api/contact.”
add all files new and modified locally, commit them locally.

How to see what has changed before actually doing commit

# show differences between index and working tree
# that is, changes you haven't staged to commit
git diff [filename]
# show differences between current commit and index
# that is, what you're about to commit
git diff --cached [filename]
# show differences between current commit and working tree
git diff HEAD [filename]

FIRST PUSH SEQUENCE

git status
git diff
git status
git pull
git stash
git pull
git stash list
git apply stash@{0}
git stash list
git stash apply stash@{0}
git push -u origin master
git status
git push -u origin master
exit
cd /home/user/projects/******-server
git status
ls
get status
git status
git log
git push -u origin master
git push -u origin master git_tracing=2
clear
git push -u origin master

SECOND PUSH SEQUENCE

git status
git add –all
git status
git add -all -v
git add –all -v
git add -i
git status
git stash list
clear
git add -A && git commit -m “Comment formatting, 24 hour cache loader, api/contact.”
history
git add -A && git commit -m “Resolved Conflicts in conf/routes”
git push -u origin master
git status
git status remote
git status remote origin
clear
git remote show origin
cd /home/user/projects/******-server
git remote show origin

git pull

remote: Counting objects: 8, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.
From https://gitlab.com/*****/*****-server
ecc5a5f..32ce420  master     -> origin/master
Auto-merging conf/routes
CONFLICT (content): Merge conflict in conf/routes
Automatic merge failed; fix conflicts and then commit the result.

git status

In case of CONFLICTS resolve conflicts, first, then do a push.

To resolve conflicts, first determine the files under conflict, by issuing git status or

git log –merge -p conf/routes

Resolve your conflicts in any editor or iDEA

git add -A && git commit -m “Resolved Conflicts in conf/routes” : Perform a local commit

git push -u origin master

git config merge.conflictstyle diff3
git status
git diff
git status
git diff
git status
git diff app/controllers/users/UserController.java
git diff HEAD app/controllers/users/UserController.java
clear
git status

git add -A && git commit -m “Comment formatting, 24 hour cache loader, api/contact.”

before doing a push check always ensure to do a pull

********************************************************************

STASHING

git pull
676  git stash –help
677  git log
678  git stash list
679  git stash save “Tests included for BadRequest, Exception Handling in fetchstatesforcountries”
680  git show
681  clear
682  git stash list

user@sys204:~/projects/datacaptive-server$ git stash list
stash@{0}: On master: Tests included for BadRequest, Exception Handling in fetchstatesforcountries
stash@{1}: WIP on master: 8829572 API Contracts, to return JSON responses. sabhi
683  git pull
684  git apply stash@{0}
685  git stash apply stash@{0}

************************************************************

Determine your remote repository

user@user-HP-Compaq-8100-Elite-SFF-PC:~/projects/*****-server-1$ git config --get remote.origin.url
https://gitlab.com/***********ivedevs/*****-server.git

git remote show origin

—————————-

In certain cases you need to checkout a branch from a remote

git clone https://github.com/matthiasn/sse-chat.git –branch 130707-kibana-demo

 

*******************************************************

git log –graph –oneline –decorate –all

In case of comparing what your local has and what has been done on remote, it is first required to fetch the references of your remote on to your local

user@sys204:~/projects/******-server$ git fetch
Username for ‘https://gitlab.com’: ******@******.com
Password for ‘https://******@******.@*****.com’:
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 14 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (14/14), done.
From https://gitlab.com/*********/*****
7950246..666039a  master     -> origin/master
user@sys204:~/projects/********-server$

 

After doing a fetch, issuing a log would still result in local changes and not depicting remote changes.

user@sys204:~/projects/******-server$ git log

user@sys204:~/projects/******-server$ git log -all : displays the fetch references and the local refs

user@sys204:~/projects/******-server$ git log origin/master : displays the fetch references and the local refs

 

****************************************

 

 

At times there might be ignored files which would have been indexed and committed to the repo, and later realized that the files should not have been there.

Your .gitignore is working, but it still tracks the files because they were already in the index.

To stop this you have to do : git rm -r --cached .idea/

When you commit the .idea/ directory will be removed from your git repository and the following commits will ignore the .idea/ directory.

PS: You could use .idea/ instead of .idea/* to ignore a directory. You can find more info about the patterns on the .gitignore man page.

 

*******************************************************************************

Roll back a git pull over a local repo:

git pull is a composition of git fetch and git merge. While fetch does retrieve only the refs, the merge is where the local repo files are merged with remote file. To undo a pull we could only git merge –abort, this command would undo the merge operation after the pull.

Rollback/Undo a commit

Undoing a commit is a little scary if you don’t know how it works. But it’s actually amazingly easy if you do understand.

Say you have this, where C is your HEAD and (F) is the state of your files.

   (F)
A-B-C
    ↑
  master

You want to nuke commit C and never see it again. You do this:

git reset --hard HEAD~1

The result is:

 (F)
A-B
  ↑
master

Now B is the HEAD. Because you used --hard, your files are reset to their state at commit B.

Ah, but suppose commit C wasn’t a disaster, but just a bit off. You want to undo the commit but keep your changes for a bit of editing before you do a better commit. Starting again from here, with C as your HEAD:

   (F)
A-B-C
    ↑
  master

You can do this, leaving off the --hard:

git reset HEAD~1

In this case the result is:

   (F)
A-B-C
  ↑
master

In both cases, HEAD is just a pointer to the latest commit. When you do a git reset HEAD~1, you tell Git to move the HEAD pointer back one commit. But (unless you use --hard) you leave your files as they were. So now git status shows the changes you had checked into C. You haven’t lost a thing!

For the lightest touch, you can even undo your commit but leave your files and your index:

git reset --soft HEAD~1

This not only leaves your files alone, it even leaves your index alone. When you do git status, you’ll see that the same files are in the index as before. In fact, right after this command, you could do git commit and you’d be redoing the same commit you just had.

One more thing: Suppose you destroy a commit as in the first example, but then discover you needed it after all? Tough luck, right?

Nope, there’s still a way to get it back. Type git reflog and you’ll see a list of (partial) commit shas that you’ve moved around in. Find the commit you destroyed, and do this:

git checkout -b someNewBranchName shaYouDestroyed

You’ve now resurrected that commit. Commits don’t actually get destroyed in Git for some 90 days, so you can usually go back and rescue one you didn’t mean to get rid of.

 

Ubuntu not showing eclipse menu

  1. Open your eclipse.desktop file:
    sudo -H gedit /usr/share/applications/eclipse.desktop
    

    (If you can’t find it in this path, try in ~/.local/share/applications/eclipse.desktop. Otherwise, you could have to find yours using locate command).

  2. Replace the Exec= line with this:
    Exec=env UBUNTU_MENUPROXY= eclipse
    

    Where “eclipse” is the path to your eclipse executable. In this case it’s just “eclipse” since there’s a symlink in /usr/bin folder.

    NOTE: If you can’t find your eclipse.desktop file, you can simply create one from scratch in the above path, and fill it with these lines:

    [Desktop Entry] 
    Type=Application 
    Name=Eclipse 
    Icon=eclipse 
    Exec=env UBUNTU_MENUPROXY= eclipse 
    Terminal=false 
    Categories=Development;IDE;Java;
    
  3. Save the file.

MySQL Restore Dump Files to Empty DB

A quicker and faster way to restore databases.

Ensure to have a blank database before we run the restore script.

C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -u root -p epaygit20161208 < restore.sql
Enter password: ********

And your done like….

 

**********************

By default MySQL in the .cnf file specifies some system wider variables. To view the system variables in the query browser execute

show variables;

MySQL by default has 150 connections, can be looked up by the command,
show variables like ‘max_connections’;

To increase the maximum number of connections, set the global variables

SET GLOBAL max_connections = 500; i

 

How to Backup a MySQL Database with mysqldump

One of the most common ways of backing up with MySQL is to use a command called “mysqldump“.

Backing Up

There is an article on how to export databases using mysqldump here. The basic syntax of the command is:

mysqldump -u username -p database_to_backup > backup_name.sql

At times when restoring databases from local system to AWS/RDS there can be
broken pipes, where in the connection of the SSH tunnel is lost and there restoration
fails. To avoid this we can increase the time out of the SSH

If you want to have a longer connection period, in the client add:

echo 'ServerAliveInterval 30' | sudo tee -a ~/.ssh/config
echo 'ServerAliveCountMax 1200' | sudo tee -a ~/.ssh/config

ServerAliveCountMax by default this is set to 3. Therefore once the ServerAliveInterval has sent 3 small packs of info to your server it will then automatically log out. Setting it to 1200 means this process will have to occur at least 1200 times. In short you should be connected at least 30*1200 seconds (10 hours).

Setting up Play Development Environment on Ubuntu

# Configure apt for java
# http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
apt-get update
apt-get install -y python-software-properties
add-apt-repository -y ppa:webupd8team/java
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections

# Update apt sources
apt-get update

apt-get install -y unzip wget git vim oracle-java8-installer oracle-java8-set-default

# Install scala
cd /opt
wget http://www.scala-lang.org/files/archive/scala-2.12.0.tgz
tar -zxvf scala-2.12.0.tgz
# end scala

#Installing playframework on ubuntu there are two options

OFFLINE INSTALLER
Go to https://downloads.typesafe.com/typesafe-activator/1.3.12/typesafe-activator-1.3.12.zip, download the offline installer close to 617MB

OR MINIMAL ACTIVATOR

# Install play with activator
#Download and Install Play (the folder should have permission to write)
#wget http://downloads.typesafe.com/typesafe-activator/1.3.12/typesafe-activator-1.3.12-minimal.zip
#unzip typesafe-activator-1.3.12-minimal.zip
#mv activator-1.3.12-minimal activator

The off-line installer downloads all the dependencies required to run play applications. In a scenario where in we download only the small foot print of activator the dependencies are downloaded at the time of loading the project, which can be annoying and time consuming.

Follow the instructions at https://www.playframework.com/documentation/2.5.x/Installing to install the play and chose “installing play with activator” and follow instructions listed
Extracting Activator

Extract the archive on a location where you have write access. Running activator writes some files to directories within the distribution, so don’t install to /opt, /usr/local or anywhere else you’d need special permission to write to.
Adding Activator to your Path

For convenience, you should add the Activator installation directory to your system PATH:

export PATH=$PATH:/opt/activator/bin

source ~/.bashrc

Making the activator as an executable execute the following command

sudo chmod a+x /activator/bin/activator

Just in case after executing the above commands and when we issue activator in the terminal, if it says command not found, we need to manually edit the bashrc file as follows

gedit source ~/.bashrc

add the command to the bottom of the file

export PATH=$PATH:/opt/activator/bin

 

unzip typesafe-activator-1.3.12.zip
mv typesafe-activator-1.3.12 activator

cd /opt
export PATH=$PATH:/opt/activator/bin
source ~/.bashrc
sudo chmod a+x /activator/bin/activator
./activator
# end play with activator

#echo ‘PATH=${PATH}:/opt/scala-2.12.0/bin:/opt/play-2.2.5’ >> /etc/profile
echo ‘PATH=${PATH}:/opt/scala-2.12.0/bin’ >> /etc/profile

echo ‘PATH=${PATH}:/opt/activator/bin’ >> /etc/profile

sudo apt-get install git

echo “Installing IntelliJ IDEA…”

# We need root to install
[ $(id -u) != “0” ] && exec sudo “$0” “$@”

# Attempt to install a JDK
# apt-get install openjdk-8-jdk
# add-apt-repository ppa:webupd8team/java && apt-get update && apt-get install oracle-java8-installer

# Prompt for edition
#while true; do
#    read -p “Enter ‘U’ for Ultimate or ‘C’ for Community: ” ed
#    case $ed in
#        [Uu]* ) ed=U; break;;
#        [Cc]* ) ed=C; break;;
#    esac
#done
ed=C

# Fetch the most recent version
VERSION=$(wget “https://www.jetbrains.com/intellij-repository/releases” -qO- | grep -P -o -m 1 “(?<=https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/BUILD/)[^/]+(?=/)”)

# Prepend base URL for download
URL=”https://download.jetbrains.com/idea/ideaI$ed-$VERSION.tar.gz”

echo $URL

# Truncate filename
FILE=$(basename ${URL})

# Set download directory
DEST=~/Downloads/$FILE

echo “Downloading idea-I$ed-$VERSION to $DEST…”

# Download binary
wget -cO ${DEST} ${URL} –read-timeout=5 –tries=0

echo “Download complete!”

# Set directory name
DIR=”/opt/idea-I$ed-$VERSION”

echo “Installing to $DIR”

# Untar file
if mkdir ${DIR}; then
tar -xzf ${DEST} -C ${DIR} –strip-components=1
fi

# Grab executable folder
BIN=”$DIR/bin”

# Add permissions to install directory
chmod -R +rwx ${DIR}

# Set desktop shortcut path
DESK=/usr/share/applications/IDEA.desktop

# Add desktop shortcut
echo “[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/idea.sh\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application” -e > ${DESK}

# Create symlink entry
ln -s ${BIN}/idea.sh /usr/local/bin/idea

echo “Done….Installing IntelliJ IDEA…”

echo “Start….Installing Scala..”

How to Install MySQL – Ubuntu

 

apt-get install --print-uris mysql-server > desktop

http://in.archive.ubuntu.com/ubuntu/pool/main/libe/libevent/libevent-core-2.0-5_2.0.21-stable-2_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-common_5.7.16-0ubuntu0.16.04.1_all.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/liba/libaio/libaio1_0.3.110-2_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-client-core-5.7_5.7.16-0ubuntu0.16.04.1_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-client-5.7_5.7.16-0ubuntu0.16.04.1_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-server-core-5.7_5.7.16-0ubuntu0.16.04.1_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-server-5.7_5.7.16-0ubuntu0.16.04.1_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/libh/libhtml-template-perl/libhtml-template-perl_2.95-2_all.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-server_5.7.16-0ubuntu0.16.04.1_all.deb

This will print out a bunch of URLs. You can download these from another computer, and transfer them to your Ubuntu machine, putting the .deb files into /var/cache/apt/archives.

sudo apt-get install mysql-server

And apt will find the package files you’ve downloaded, and install mysql.

Installing SBT on Ubuntu

Sbt is the default build tool for Scala. This post talks about steps to install sbt on ubuntu.
 

Steps to Install SBT on Ubuntu

#Add typesafe repository     
wget http://apt.typesafe.com/repo-deb-build-0002.deb `

#Install the repository
sudo dpkg -i repo-deb-build-0002.deb

#Refresh
sudo apt-get update

#Install sbt
sudo apt-get install sbt

#check whether sbt is installed

sbt

Add Specific Version of SBT

Some project need specific version of sbt like 0.13.

If you get error saying

Detected sbt version 0.12.2 Cannot find sbt launcher 0.12.2 Please download: From typesafe.artifactoryonline.com/typesafe/ivy-releases/… To /home/{username}/.sbt/.lib/0.12.2/sbt-launch.jar

Run the following commands by replacing with your username.

mkdir -p /home/{username}/.sbt/.lib/0.12.2/ 
 wget -O /home/{username}/.sbt/.lib/0.12.2/sbt-launch.jar 
 http://typesafe.artifactoryonline.com/typesafe/ivy-releases/
 org.scala-sbt/sbt-launch/0.12.2/sbt-launch.jar