Git: Testing Someone Else’s Pull Request on your local dev machine

You do not have to clone every developer’s fork or repository  and then checkout their respective branch in order to test the pull request locally on your dev box 😉

This tutorial will show you how to checkout a pull request on your own computer. This can be very helpful when you want to find bugs and test out new features before they get merged into the main project.

That gist does describe the config changes required in .git/config of the project.

Basically you need to add this line in config

fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

which will allow you to checkout pr locally

Obviously, change the github url to match your project’s URL. It ends up looking like this:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@github.com:joyent/node.git
    fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

Now fetch all the pull requests:

$ git fetch origin
From github.com:joyent/node
 * [new ref]         refs/pull/1000/head -> origin/pr/1000
 * [new ref]         refs/pull/1002/head -> origin/pr/1002
 * [new ref]         refs/pull/1004/head -> origin/pr/1004
 * [new ref]         refs/pull/1009/head -> origin/pr/1009
...

To check out a particular pull request:

$git checkout <pr-id>

$ git checkout pr/999
Branch pr/999 set up to track remote branch pr/999 from origin.
Switched to a new branch 'pr/999'
Advertisements

Microservice development for full stack application with angularjs, spring boot by using jHipster

Hi Friends,

How easy is to create a micro service, put it behind a gateway and make it up and running as part of a full stack application ? Well its easier then it appears. I have published the video with live demo creating a micro service and making it full from a Angular UI by using aa awesome tool called jHipster. Watch it and have fun 😉

My Book on design patterns is now available on Udemy platform

Friends,

It was my deep down wish to be an instructor on Udemy platform and with Guru’s grace it got fulfilled today.

My video Book on “Learn software design patterns with Java” is now available on Udemy as on line course. Students would also get the certificate of completion once they finish the entire course.

https://www.udemy.com/learn-design-patterns-with-java/

Udemy

 

 

Be a Problem Solver, not a Puzzle Master

As developers we fall into the following trap often: we focus on solving puzzles, not solving problems. What’s the difference between a puzzle and a problem?

Solving both puzzles and problems is satisfying, revealing, and educational. Solving a complex puzzle or problem can be intellectually rewarding and exhilarating. Unfortunately, puzzles are often meaningless distractions and time-wasters despite the satisfaction gained. Solving problems unblocks you and helps you accomplish your goals.

So, you’re feverishly trying to optimize your app’s search feature to make it a few milliseconds faster — is this a distracting, wasteful puzzle or a critical problem to solve? It depends! If the search feature is the most used customer feature then you might be saving the company. But, if you just stumbled upon this unused code and you remember reading a blog article a while back about a new technique and… well it just could be better and it’s annoying you then this might be a puzzle for another day.

Be a problem solver. Again, step back, get out of your own head, and ask yourself, “What am I trying to accomplish? Is this important?”

Certificate : Jhipster – Full stack web application generator for Java spring boot and angular/React

JHipster is a very powerful application generation framework to create full stack applications using Java + JavaScript. I have completed a course which has Java spring back end and Angular 4 / React front end without dockers.

jHipster-course-certificateUC-D6XTMEXH

 

This certificate above verifies that Aseem Jain successfully completed the course Angular 4 Java Developers on 09/24/2018 as taught by Dan VegaJohn Thompson on Udemy. The certificate indicates the entire course was completed as validated by the student.

git : pushing a new project to you github repo

Its a good practice to push your pet project to github repository. Below commands will help you.

First, you need to create a project in github repo and copy its repository url which will act has your remote origin, then you need to init you local repository and link them. so that you can push them once its all set.

git init
git add -A
git commit -m 'Added my project'
git remote add origin git@github.com:premaseem/my-new-project.git
git push -u -f origin master

With this, there are a few things to note. The -f flag stands for force. This will automatically overwrite everything in the remote directory. We’re only using it here to overwrite the README that GitHub automatically initialized. If you skipped that, the -f flag isn’t really necessary.

The -u flag sets the remote origin as the default. This lets you later easily just do git push and git pull without having to specifying an origin since we always want GitHub in this case

 

Docker: Building Docker Images with Dockerfiles

In this guide we’ll learn about the Dockerfile. What it is, how to create one, and how to configure the basics to bring up your own Dockerized app.

What is a Dockerfile?

  • A Dockerfile is a text configuration file written in a popular, human-readable Markup Language called YAML.
  • It is a step-by-step script of all the commands you need to run to assemble a Docker Image.
  • The docker build command processes this file generating a Docker Image in your Local Image Cache, which you can then start-up using the docker run command, or push to a permanent Image Repository.

Create a Dockerfile

Creating a Dockerfile is as easy as creating a new file named “Dockerfile” with your text editor of choice and defining some instructions.

#
# Each instruction in this file generates a new layer that gets pushed to your local image cache
#

#
# Lines preceeded by # are regarded as comments and ignored
#

#
# The line below states we will base our new image on the Latest Official Ubuntu
FROM ubuntu:latest

#
# Identify the maintainer of an image
MAINTAINER My Name “myname@somecompany.com”

#
# Update the image to the latest packages
RUN apt-get update && apt-get upgrade -y

#
# Install NGINX to test.
RUN apt-get install nginx -y

#
# Expose port 80
EXPOSE 80

#
# Last is the actual command to start up NGINX within our Container
CMD [“nginx”, “-g”, “daemon off;”]

Run below command to build image from Dockerfile

$ docker build . -t <image tag name>

eg.$ docker build . -t premaseem/dockerimage

 

Dockerfile Commands

  • ADD – Defines files to copy from the Host file system onto the Container
    • ADD ./local/config.file /etc/service/config.file
  • CMD – This is the command that will run when the Container starts
    • CMD [“nginx”, “-g”, “daemon off;”]
  • ENTRYPOINT – Sets the default application used every time a Container is created from the Image. If used in conjunction with CMD, you can remove the application and just define the arguments there
    • CMD Hello World!
    • ENTRYPOINT echo
  • ENV – Set/modify the environment variables within Containers created from the Image.
    • ENV VERSION 1.0
  • EXPOSE – Define which Container ports to expose
    • EXPOSE 80
  • FROM – Select the base image to build the new image on top of
    • FROM ubuntu:latest
  • MAINTAINER – Optional field to let you identify yourself as the maintainer of this image
    • MAINTAINER Some One “someone@xyz.xyz”
  • RUN – Specify commands to make changes to your Image and subsequently the Containers started from this Image. This includes updating packages, installing software, adding users, creating an initial database, setting up certificates, etc. These are the commands you would run at the command line to install and configure your application
    • RUN apt-get update && apt-get upgrade -y && apt-get install -y nginx && rm -rf/var/lib/apt/lists/*
  • USER – Define the default User all commands will be run as within any Container created from your Image. It can be either a UID or username
    • USER docker
  • VOLUME – Creates a mount point within the Container linking it back to file systems accessible by the Docker Host. New Volumes get populated with the pre-existing contents of the specified location in the image. It is specially relevant to mention is that defining Volumes in a Dockerfile can lead to issues. Volumes should be managed with docker-compose or “docker run” commands.
    • VOLUME /var/log
  • WORKDIR – Define the default working directory for the command defined in the “ENTRYPOINT” or “CMD” instructions
    • WORKDIR /home