Jon Perry's Blog

Git Commands – Help Sheet

Essential Git commands for effective software development.

Undo a commit

git reset HEAD —hard

Pulls latest changes from the repo and rebases changes from the master branch

git pull origin remote-branch —rebase master

Title

git reset –soft HEAD

Resets stage locally (undo’s any uncommitted changes)

git reset -—hard HEAD

Continues iterating through merged changes made from the rebased repo

git rebase —continue

Aborts merging rebased changes

git rebase —abort

Force pushes changes made to the local repo (usually made when a rebase has occurred when updating a branch)

git push origin branch —force

Fetches all remote branch names not in local

git fetch

Checks out a remote branch into local tracking that repo for changes

git checkout —track remote-branch

Create a new branch and switch to it

git checkout -b branch

Current local branch

git branch -l

List current, all local remote branches being tracked

git branch -a

Display URL to remote repository

git remote -v

Add New Repository URL

git remote add origin url

Change Existing Repository URL

git remote set-url origin repository-url

Delete a local branch

git branch -D branch

Delete a remote branch

git push origin –delete remote-branch

Stages a file for commit

git add path-to-file

Commits all staged files with commit message

git commit -am “message”

Stash Changes

git stash

List Stash Changes

git stash list

Apply Stash

git stash apply stash@{stashIndex}

Note: 0 is the most recent stash

Delete Stash by Index

git stash drop stash@{stashIndex}

Delete All Stashes

git stash clear

This will delete ALL your stashed changes

Spring Web Flow – using Eclipse IDE (Tutorial)

I’ve been looking online lately for tutorials on Spring Web Flow, and I didn’t find any that were succinct, memorable, or very appealing. For every tutorial that you find online, that framework may be out of date, and another may be in date; but be horrendously long to read… This article helps challenge these attributes.

For this tutorial I am using:

IDE: Eclipse (Java EE)
Build tool: Maven
Framework: Spring v4 << the important bit ... and Java, obviously.

Step 1:

Create a new project in Eclipse. You’ll need to open ‘other’ option under the New menu heading. A new window will open – select Maven -> Maven Project.

Step 2:

Setup your Spring dependencies.

When you create a new Maven project (under File -> New -> Other…), you will need to use your default workspace location, using the ‘maven-archetype-webapp’ artifact ID. Give your Maven project a name, followed by the parent package that you want to create for this project.

Open the pom.xml file under the root of your application’s directory.

With your pom.xml configuration file open, you’ll need to specify to Maven what Java libraries your application will need to build, deploy and run.

To create a Spring Web Flow application, we’ll need three components belonging to the Spring framework, those being: Spring Core, Spring MVC and Spring Web Flow. We will also need Spring Boot, Spring Web, Spring Context and Spring Autoconfigure.

The framework itself isn’t one dependency, more-over is an assortment of components, (I presume) for the purpose of modularity and performance.

<!-- Spring Boot -->
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot</artifactId>
   <version>1.2.3.RELEASE</version>
</dependency>
       
<!-- Spring Web -->
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>4.1.6.RELEASE</version>
</dependency>
       
<!-- Spring Core -->
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-core</artifactId>
   <version>4.1.6.RELEASE</version>
</dependency>
       
<!-- Spring MVC -->
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>4.1.6.RELEASE</version>
</dependency>
   
<!-- Spring Web Flow -->
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webflow</artifactId>
   <version>1.0.6</version>
</dependency>
   
<!-- Spring Context -->
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>4.1.6.RELEASE</version>
</dependency>
   
<!-- Spring AutoConfigure -->
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-autoconfigure</artifactId>
   <version>1.2.3.RELEASE</version>
</dependency>

Figure 1. Maven dependencies – feel free to copy n’ paste!

Step 2: Write code like MVC… not ABC…

We’ve got the important stuff out of the way. We can now focus on writing our Java code!

To begin with, we’re going to write the root of our application.

Start by creating a new Java class and name it something like Application. This will allow us to compile and execute the application on our local Tomcat server.

package com.learning.spring.webflow;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
   
   public static void main(String [] args) {
      SpringApplication.run(Application.class, args);
   }

}

This very small and simple class simply instructs the Spring boot component to execute our code against the JVM.

Next, we need to create a class which will act as the Controller (eventually) in our Spring Web Flow application.

// Spring MVC component
import org.springframework.stereotype.Controller;

// Spring Web component
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HolidayBookingFormController {

   @RequestMapping("/book-holiday-date")
   public String holidayChooseDates() {
     
   }

   @RequestMapping("/book-holiday-guests")
   public String holidayNumberOfGuests() {
     
   }

   @RequestMapping("/book-holiday-flights")
   public String holidayChooseFlights() {
     
   }

   @RequestMapping("/book-holiday-extras")
   public String holidayChooseExtras() {
     
   }

   @RequestMapping("/book-holiday-insurance")
   public String holidayConfirmBooking() {
     
   }

}

For each of the methods contained within this controller, each HTTP request maps (corresponds) with the JSP that will handle the presentation of our application.

Step 3: Create the JSP’s!

New Hobby…

So… we are 25 days into the New Year. It’s been ok, and despite the cold, things are going generally, ‘ok’.

For a long time, I’ve been exploring and developing experience in different disciplines encompassing Computer Science (mainly to get a job in software engineering), but I haven’t had time to explore a topic where I can unleash my creativity, never get bored technically, and generally enjoy a hobby with a lot of pleasure attached to it. That topic, is Computer Graphics!

I can’t wait to see how things develop. I’m going to make loads of mistakes, and probably adopt some bad practices (by mistake) at some stage, but I can’t wait to show the world what I do. I’ve been exposed to art, design and technical disciplines through my life and I really relish doing something a lot of Computer Science professionals never sadly explore in their spare time alongside a full time job.

Happy New Year!

It’s been quite a while since I last posted something on this blog. In that time I have finished my MSc and started a new job in the real world. In the spirit of the New Year and Resolutions, I have recently created my own custom theme for this blog (ooh er!).

The hope behind the change in the design is to put myself into a more focused, professional mindset, so I can use this little space on the inter-web to share my technical creations in my spare time, now that I am working in the commercial world of technology 🙂

Watch this space…

Dissertation Progress – Day 67

Tasks complete today:

  1. Coded intial monitoring system component – will implement Fuzzy Logic system tomorrow.
  2. Read paper ‘The Computer for the 21st Century’.

Dissertation Progress – Day 66

Tasks complete today:

  1. Printed Project Report (draft)
  2. Printed System Evaluation questionnaire.
  3. Uncommitted changes in Web GitHub repository. Was drifting towards measuring productivity.
  4. Amended System Evaluation Questionnaire – it has been structured in categories.
  5. Topped-up printing credits – there should be sufficient credit from-here-on-out.

Dissertation Progress – Day 65

Tasks complete today:

  1. Submitted Ethical Review Application.
  2. Produced rough System Evaluation document – including questions.
  3. Soldered second temperature sensor.

Dissertation Progress – Day 64

Tasks complete today:

  1. Finished Ethics Review – including supporting document.

Dissertation Progress – Day 63

Tasks complete today:

  1. Sourced and printed off written material by Mark Weiser – including his classic paper on ubiquitous computing.
  2. Completed Project Description for Ethics Review Application.
  3. Finished writing functionality for class SystemProcessUtil (incl. internal classes… for the meantime).

Dissertation Progress – Day 62

Tasks complete:

  1. Redesigned and restructured the client application to attempt to start automatically on system boot.
  2. Drawn up sequence diagram in MS Visio to reflect changes in client application structure.
  3. Implemented Thread functionality that delays operation of application to ensure a connection to Eduroam is established.
  4. Wrote the ‘Acknowledgements’ chapter in the Project Report.
  5. Finished Ethical Review Application – including an Evaluation Plan, submitted as a supporting document.