Upgrading a PS4 HD

Like me, you might have a 500GB PS4. While 500GB seems fine at first, it is woefully inadequate for most of today’s games. If you found this to be the case, Sony has thankfully allowed customers to upgrade their hard drives themselves without voiding warranty. To help anyone else wanting to upgrade their storage, I’ve created a few quick and easy steps below to speed up the process. 

  1. Buy a replacement hard drive. PS4 hard drives are 2.5 inch laptop hard drives. Almost any drive will do as long as it can fit into the caddy. The drive that comes with the original PS4 is a 500GB 5400 RPM SATA II hard drive. In order to replace it, you will want to choose another laptop hard drive of 1 or 2 TB. The only limitation you have is the thickness of the 9.5 mm caddy. While the original HD is 5400 RPM it is possible to replace it with a faster drive, however some users have reported the excess heat and power consumption of quicker drives may cause additional wear and tear to your PS4 so definitely use at your own risk. I opted for a Seagate ST2000LM003 2TB 2.5 SATA 6GB/s which cost $165.00AU at Umart. 
  2. The next thing is to backup your save games. For me I grabbed a flash drive and did an archive of my settings and save games from the system menu. For later steps, it’s easier if you use a FAT32 formatted drive. It is possible to backup your game installs, patches and digital downloads but this will take a bigger USB storage device and will take a lot of time.
  3. To initialise your new drive you will need to put the PS4 OS files on a flash drive. Make sure your drive is formatted to FAT32. Download the PS4UPDATE.PUP file from the PlayStation website. Make sure the file is 850MB. The download link is at the bottom of the page so you might have to do some searching. Also, make sure you grab the file from your region as my experience seems to show that the US file will not work on Australian PS4. (For Australia, you can get the file from this page: https://www.playstation.com/en-au/get-help/ps4-system-software/) Put the file in the location X:\PS4\UPDATE\PS4UPDATE.PUP on your USB drive.
  4. Turn off the PS4, unplug the power cord and remove the outer casing.
    1
    Remove the screw holding in the hard drive caddy and slide the caddy out.
    2
    Remove the 4 screws holding in the hard drive and remove the hard drive.
    34
    Replace the hard drive with the new one, replace all 4 screws, slide the caddy back into the PS4. After this, replace the remaining screw and replace the outer casing.  *Diagram’s taken form the official playstation website.
  5. Insert the USB stick with the update file and start the PS4 in safe mode. To start the PS4 in safe mode, press the power button for aproximately 7 seconds. Once you see a menu, choose option 7, Initislise PS4 (Reinstall system software).
  6. Restore your game saves and settings from the system menu. After a restart your PS4 should be as 
  7. Reinstall your games, patches and apps if needed. 
  8. Play your your newly upgraded PS4! 

Introduction to Enterprise Architecture (EntrArch) part 2

I have recently completed the Introduction to Enterprise Architecture on Open2Study. This is my first experiment into the world of MOOCs (Massively Open Online Courses) with Open2Study and overall my experience was very much a positive one.

The course itself was 4 weeks and included a number of short videos as content and multiple choice quizzes as assessment. You needed to get over 60% in all 4 quizzes (each containing only 5 questions) to complete the course. While enterprise architecture might not be the most exciting topic, instructor Craig Martin manages to keep content interesting and successfully ties together all of the content into a series of interested videos.

I found that I needed to take notes through each of the videos in order to have success answering the quizzes at the end of each module without googling the answer to each question.

The course URL can be found at: https://learn.open2study.com

If you are interested, you can watch the first topic of module 1 below.

Introduction to Enterprise Architecture (EntrArch)

Massively Online Open Courses (MOOCs) are a big thing in my sector, and as such I thought it was about time I actually enrolled in one.

I’ve enrolled in Introduction to Enterprise Architecture through open2study.com. Open2study is site offering free 4 week introductory courses and is an initiative of Open Universities Australia (http://www.open.edu.au/).

I’ve only watched the first half of the first module, but in all, I’m pretty excited to be finding out a little more about Enterprise Architecture.

Link to course:
https://www.open2study.com/subjects/introduction-to-enterprise-architecture

Application development life cycle

I am a fan of the traditional waterfall model for application development. I know agile development is the current hype within the software development community, and like all programmers, I hate documentation, but there is something elegant in creating a perfect design for an application before you even fire up your favourite IDE. Below is an example of my typical application development life cycle…

Application development life cycle
1. Requirements! Gather requirements from the client and create a requirements specification.

2. Design! From the confirmed requirements, begin to creation a technical design for the application.

3. Implementation! Development includes looking through the current range of applications and applications templates and picking a similar one as a template. Commit the copy into SVN as the trunk of a new project. From here, start designing your new building block to fit with the technical design. This may involve looking through the any APIs, tag libraries and web services as well as any required third party services.

4. Quality Assurance! Code review and testing.

5. Release! Change control (follow any ITIL processes), Communication and eventually deployment into production.

6. Maintenance! Repeat the above steps for enhancements and bug fixes.

Jira: An issue tracker for developers

Like most programmers, I’ve used a range of issue tracking tools over the years to track bugs and enhancement requests in my applications and to be blunt, most of these have been terrible. Usually, I’ve been forced to use a new tool for a few weeks, then moved back to a trustworthy excel file buried deeply in a corporate network drive to keep track of any bugs I deemed worthy of tracking. This was until I discovered a product called Jira which is created by Australian company Atlassian. Jira is an issue tracking tool designed specifically for IT projects and is designed with developers in mind.

The tool itself is completely customisable. You can create issues, tasks, enhancements or something completely custom and then build specific queries to search for these items. A good example is you could create a project and have a range of sub components within that project, each with its own list of bugs and enhancements. It even has a range of agile development tools if this is what you are after. Better yet, it has a way to track issues with specific builds of an application, and even has a way to integrate itself with Bamboo (atlassian’s continuous code integration tool) and wiki (attlassian’s wiki tool).

It features some handy import tools, so if you are already using something else, you can use a built in import plugin or as long as you can export it as a csv you can use the in built csv importer to move everything into Jira.

The link below takes you to the Jira website where you can purchase various licenses of the tool depending on your needs.

Link:
http://www.atlassian.com/software/jira

Diving by zero in java

Java has some unusual and often unexpected results when dividing by zero when using variables of type int or double.

If you try and divide where both variables are of the type int, a “/ by zero” exception will be thrown.

If, however, you make one of the operands a double, no exception is thrown, and the operation completes successfully. It is important that at least one of the operands and not just the answer is of type double for the statement to complete so the operation itself is done with doubles. If you print the answer, the text “infinity” or “-infinity” will be output.

Why does this happen?

In short, ints have no value for infinity or values that aren’t a number. This means that when 2 ints are divided by zero, the result will always be an exception as the data type has no way to represent the result. Doubles on the other hand are floating point numbers, and floating point numbers can represent infinity or results that aren’t numbers so an operation like dividing by zero is completely valid.

In the examples below, you can see that by making just one of the operands a double, no runtime exception is thrown when dividing by zero and the value of the result is “infinity”. The same operations with ints simply throw an exception.


//Example of standard division of positive ints. 
//output= 4
<%
int aa = 12;
int bb = 3; 
int answer;
try {
answer = aa/bb;
out.println(answer);
} catch (Exception e) {
	out.println("I am a runtime exception!");
}

//Example of dividing by zero using ints.
//output = exception. Exception message: / by zero
int a2 = 12;
int b2 = 0; 
int answer2;
try {
answer2 = a2/b2;
out.println(answer2);
} catch (Exception e) {
	out.println("I am a runtime exception. Exception message: " + e.getMessage());
}

//Example of an int divided by a double. As one of the operands is a double, the answer to will be a double. This works and the answer comes out to be NaN (Not a Number). See the output of 'Infinity' from the below code. 
//output = Infinity 
int a3 = 12;
double b3 = 0; //one of the divisors needs to be a double to work. 
double answer3;
try {
answer3 = a3/b3;
out.println(answer3);
} catch (Exception e) {
	out.println("I am a runtime exception. Exeption message: " + e.getMessage());
}

//Example of int divided by an int.
//output = I am a runtime exception. Exception message: / by zero
int a4 = 12;
int b4 = 0; //one of the divisors needs to be a double to work. 
double answer4;
try {
answer4 = a4/b4;
out.println(answer4);
} catch (Exception e) {
	out.println("I am a runtime exception. Exception message: " + e.getMessage());
}

Changing the context root of your java web app

Problem: In Eclipse, I made a copy of an existing web app and tried to deploy on my local tomat. This failed as it had the same context root (e.g. http://localhost.8080/webapp1) as the existing project I copied from. To fix this, I changed the context root on the new project to something new. I did this by selecting project properties -> Web Project Settings -> Context Root. From here I was able to change the webapp context root to something else (e.g. http://localhost.8080/webapp2), which should allow both projects to be deployed in parallel. While this seemed to be all that was needed, I received the following error when trying to actually deploy the app.

context_error

Solution:
To resolve this issue, tomcat needs to be issued with the ‘clean’ command in order to pick up and activate the changes to the context root of deployed applications. To do this…
1) Stop tomcat.
2) right click on your server from within the servers window and select ‘clean’.
tomcat_clean
3) Click OK when asked to republish from scratch.
4) Click YES to when asked if you want to update the context root of the module you just changed.
5) The server should now automatically restart. You should now be able to successfully navigate to both applications as they are deployed on different context roots.

Exception hanlding and logging of pl/SQL

pl/SQL Logging
During a batch process or the execution of pl/SQL, you will want to log the output and the success or failure of the process.

Typically, I always find it good practice to output some simple information such as the start and end date/time of the process as well as any errors that may occur. This is really handy if you are wanting to look at how long a process takes and will give you a feel for if something ‘went wrong’ while running the script.

If you run a script as a one off, you will see the output of your code (package, procedure, anonomous block) in the output from your IDE such as TOAD, SQL developer or SQL*Plus.

Example:

set serveroutput on

... your code

or you can redirect it to a file (see below)

Example:

set serveroutput on
spool log.txt

... your code

spool off

If you run a batch process using crontab or some other scheduler, use this to redirect your output into a file. If you do this, it is always a good idea to time stamp the file.

Exception handling
In your batch pl/SQL applications, you will need to have some exception handling.

If anything, you will want to catch some specific errors as well as others.

In my examples below, I am catching a NO_DATA_FOUND exception and outputting a different error to when any other exception occurs.

Example:

BEGIN 

	DBMS_OUTPUT.PUT_LINE('Batch process started - '||SYSDATE);
	
	... your pl/SQL block that does stuff...

	COMMIT; --commit changes 
	DBMS_OUTPUT.PUT_LINE('Batch process ended - '||SYSDATE);
	
EXCEPTION
   WHEN NO_DATA_FOUND THEN
      ROLLBACK;
	  
      DBMS_OUTPUT.PUT_LINE('No data was found - '||SQLCODE||' -ERROR- '||SQLERRM);

EXCEPTION
   WHEN OTHERS THEN
	  ROLLBACK;
      DBMS_OUTPUT.PUT_LINE('An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END;

Raising your own exceptions
Another option is when you come across a condition in your code where you want to throw an exception. A really good example of this is if a variable ends up with a negative number you may want to raise an exception rather than let the program continue on.

Example:

BEGIN

	IF input > 0 THEN
		... your pl/SQL block that does stuff...
	ELSIF input = -1
		--Raise no data found exception if 
		RAISE NO_DATA_FOUND; 
	
	ELSE
		--Something wrong has happened. Raise an exception. 
		RAISE;
	END IF:

	EXCEPTION
	   WHEN NO_DATA_FOUND THEN
		  DBMS_OUTPUT.PUT_LINE('Please enter a correct paramater and try again.');

	EXCEPTION
	   WHEN OTHERS THEN
		  DBMS_OUTPUT.PUT_LINE('An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
	END;
END;

Creating your own custom exceptions
It is also possible to create your own exceptions and even allocate them to their own error number within the user-specified range of between -20000 – -20999. All other error numbers are reallocated to standard oracle errors. While this is certainly possible, I’ve never found a real life scenario where I have wanted to create my own exceptions as the Oracle keywords and mapping to error numbers have been sufficient for most needs. (hence why I haven’t included an example)

Tutorial 6: Servlets

Servlets are server side java classes that render into a web page. (Similar to Perl/CGI)

How to create your first servlet

From Eclipse…
1. Right click on project.
2. Click on new
3. Click on other
4. Type in servlet (it is in the wizard section)
5. Click next.
6. Add package, class name. In this case the package is com.informalsemantics, the class is FirstServlet.
7. Click next
8. Click Finish.

You have now created the scafolding for a simple servlet, however you will notice some compile time errors.

All of the imports for javax.servlet.* will be underlined red and have compile time errors.
For this, you will need to add the servlet-api.jar to the build path.
To do this…
1. right click on your project, build path, configure build path
2. Click on the libraries tab.
3. Click on Add external JARs
4. Navigate to where you installed Tomcat. (in my case, it was c:\tomcat)
5. Go the libs folder. (c:\tomcat\libs)
6. And select servlet-api.jar.
7. Click select.
8. Click OK.
Eclipse will now recompile your project and the compile time errors will disappear.

You now have FirstServlet.java under src in the package com.informalsemantics. Lets do the usual, and add some code to display “Hello World!”.

Open FirstServlet.java.
There are 3 default methods in your servlet class.
– FirstServlet() – default constructor
– doGet – is called when the servlet has a get http request made to it
– doPost – is called when the servlet has a post http request made to it.

@WebServlet(description = “My First Servlet”, urlPatterns = { “/FirstServlet” })
This tell the JVm that the servlet is called “My First Servlet” and it can be found at the following URL. “/FirstServlet” (web context)

The params to doGet and doPost are…
– HttpServletRequest – contains anything that comes FROM the browser.
– HttpServletResponse – Contains the stuff the application needs to send back to the browser. Most common is to get the writer from HttpServletResponse for a PrintWriter that then writes data back to the browser.

response.setContentType(“text/html”) tells the browser to expect HTML.

You can then use the out.println statement to build a webpage using standard HTML tags.
e.g. out.println(“

Hello World!

“);
More complex servlets – Hello BLUE world
In the real world, your code will never be this simple, so let’s create a custom helper class to do some work in our new servlet.

In this, I’ve used a helper class to output the title and change the colour to blue. This gives an example of how to interface with objects within your servlet. I’ve created a servlet called TestServlet1 and a custom class called TestServlet1Utilities.

The TestServelet1Utilities class contains a single method that simple returns a string with the HTML doctype and head tags. See below.

	/*
	 * <pre>: Requires the title of the page
	 * <post>: Outputs the required html as a string that defined the title. 
	 */
	public static String getHeadWithTitle(String title){
	    return("<!DOCTYPE html>\n" +
	            "<html>\n" +
	            "<head><title>" + title + "</title></head>\n"); 
		
	}

Annotations VS web.xml
You can now create a servlet by just using an annotation.
e.g. @WebServlet(“/test”)
and this allow, assuming your class extends HttpServlet, is enough to let the web app know to serve your servlet from the specified path.
Prior to this, each servlet has to be specifically specified in the applications web.xml file.
Web.xml lives inside the web-inf directory of your application.
e.g. of a web.xml file defining a servlet:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

  <servlet>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>com.informalsemantics.MyServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/MyServlet</url-pattern>
  </servlet-mapping>

</web-app>    

While this is how you will see a lot of servlet code written, annotations is an easier and simpler approach.