22 January 2007

Downloading and Activating Photoshop CS3 BETA

Good News!

Adobe has released Adobe Photoshop CS3 Beta for download to already existing CS2 customers.

You can register and download a copy for both Mac or PC using the link below:

https://www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5Fphotoshop

According to a post I read on the photoshop web site, some users serial numbers from CS2 have been accidentally left of the list. Should your valid serial number be invalid, they metntioned you can simply rename the c:\program files\adobe\photoshop CS3\AMT\application.sif to something else and restart photoshop.

Sparky

09 January 2007

C#.Net Debugging to the Output Window

Finally I discovered that I can actually debug by outputting text to a window in VS.Net

To get your C#.Net script to output to the console, simply add:

System.Diagnostics.Debug.WriteLine("Hello!");


Do the Debug > Attach to Process > aspnet_wp.exe and visit the page.

Here is a screenshot of the results:

11 December 2006

Javascript: Convert DMS to DD

Hi Guys,

Here is a little object to convert decimal degrees (dd) to degrees minutes and seconds (dms) and the same in reverse. I've tried to optimise it to be as fast as possible to use with Google Maps when dragging over coordinates. Post your questions and comments and I'll try to assist you.

Next post I have an exciting script that allows you use a Google Sattelite Map interface to find your house and drag a marker over it to get the coordinates.

/* Written by Sparky Spider (http://sparkyspider.blogspot.com) */

function Coordinates() {

// Properties

this._latitude = 0;
this._longitude = 0;

this.LATITUDE = 0;
this.LONGITUDE = 1;

// Constuctor

this.latitude = new DMSCalculator(this.LATITUDE, this);
this.longitude = new DMSCalculator(this.LONGITUDE, this);

// Methods

this.setLatitude = function setLatitude(lat) {
this._latitude = lat;
};

this.setLongitude = function setLongitude(lng) {
this._longitude = lng;
}

this.getLatitude = function getLatitude() {
return this._latitude;
}

this.getLongitude = function getLongitude() {
return this._longitude;
}

// SubClasses

function DMSCalculator (coordSet, object) {

var degrees = new Array (0, 0);
var minutes = new Array (0, 0);
var seconds = new Array (0, 0);
var direction = new Array (' ', ' ');
var lastValue = new Array (0, 0);
var hundredths = new Array (0.0, 0.0);

var calc = function calc(object) {

var val = 0;

if (coordSet == object.LATITUDE) {
val = object._latitude;
} else {
val = object._longitude;
}

if (lastValue[coordSet] != val) {

lastValue[coordSet] = val;

if (val > 0) {
direction[coordSet] = (coordSet == object.LATITUDE)?'N':'E';
}
else {
direction[coordSet] = (coordSet == object.LATITUDE)?'S':'W';
}
val = Math.abs(val);
degrees[coordSet] = parseInt (val);
var leftover = (val - degrees[coordSet]) * 60;
minutes[coordSet] = parseInt (leftover)
leftover = (leftover - minutes[coordSet]) * 60;
seconds[coordSet] = parseInt (leftover)
hundredths[coordSet] = parseInt ((leftover - seconds[coordSet]) * 100);

}
}

this.getDegrees = function getDegrees() {
calc(object);
return degrees[coordSet];
}

this.getMinutes = function getMinutes() {
calc(object);
return minutes[coordSet];
}

this.getSeconds = function getSeconds() {
calc(object);
return seconds[coordSet];
}

this.getDirection = function getDirection() {
calc(object);
return direction[coordSet];
}

this.getHundredths = function getHundredths() {
calc(object);
return hundredths[coordSet];
}

this.getSecondsDecimal = function getSecondsDecimal() {
calc(object);
return seconds[coordSet] + (hundredths[coordSet] / 100);
}

this.setDMS = function setDMS (degrees, minutes, seconds, direction) {
var val = degrees + (minutes / 60) + (seconds / 3600);
if (direction == 'W' || direction == 'S') {
val *=-1;
}
if (coordSet == object.LATITUDE) {
object._latitude = val;
}
else {
object._longitude = val;
} // if
} // this.setDMS
} // DMSCalculator
} // Coordinates

It's really easy to use too. Here are 2 examples:


function test() {
var coords = new Coordinates();
coords.longitude.setDMS(33, 46, 16.68, 'S');
coords.latitude.setDMS(18, 44, 24.19, 'E');

alert (coords.getLatitude() + ' ' + coords.getLongitude());

coords.setLatitude (-33.7713);
coords.setLongitude (18.7400527778);

DMSStringLat = coords.latitude.getDegrees() + ' ' + coords.latitude.getMinutes() + ' ' + coords.latitude.getSecondsDecimal() + ' ' + coords.latitude.getDirection();
DMSStringLng = coords.longitude.getDegrees() + ' ' + coords.longitude.getMinutes() + ' ' + coords.longitude.getSecondsDecimal() + ' ' + coords.longitude.getDirection();

alert (DMSStringLat + ' ' + DMSStringLng);
}


I'd love to hear if you have any improvements. Please post them here.

28 November 2005

Model View Contoller Architecture

Ever wondered how some developers get such lovely URL's, and how they manage to add oodles of content to their web sites in a breeze? How'd they make that web site so quickly and what type of application server uses .do and .view pages anyway? Well, the answer is simple, most of them use a Model-View-Controller (or MVC) pattern. Stay with me and I'll give you a little taste into this new way of developing web applications.

This article discusses the MVC pattern. For this example, we'll be using a J2EE (Java) container (web server) such as Tomcat or JBoss. Instead of writing the system from scratch, we'll be using the popular Struts framework. Views (templates) are rendered either using JSP (JavaServer Pages) technology, JSF (JavaServer Faces) or XSLT.

Most web sites are created using a Model 1 or page-centric approach. This means that the functionality of the web site is based on the page that is requested. This is limiting, having your functionality split over so many pages.

In the MVC approach, you have a single controller that processes all requests. This controller takes the request, runs it through a xml mapping file, and, depending on the configuration of the mapping file, forwards the processing of logic on to a java component (object that you write to do the logic). The component does the work, and stores the "state" or "result" in what's known as a model (a fancy word for some kind of data object stored in the request or session or disk). One the business logic is complete, the component gives processing back to the controller who then decides on a view. The view (template) gets populated by variables in the model, and wham, your client has their web page.

Sun's Java (J2EE) makes a really great platform for this. In a Java-based web application, you can add a web.xml file to the application that instructs to the web server (like JBoss or Tomcat) how to handle requests, etc. In this file, you can map a URL request pattern such as *.do or /home/* to a single servlet (Java web component). This servlet, known as the controller servlet, then processes the request and passes execution on the model (buiness logic) and view (template).

Let's look at some of the adantages of this approach before looking at some pseudo-code:

1. Easy creation of content as there are no actual pages.
2. Complete re-use of components because of great seperation of presentation and logic.
3. Easily convert applications for other browsers / WAP / web services using different views.
4. Use pre-built frameworks (such as struts or JSF) and save thousands of hours coding.
5. Easily manage an application flow from a single XML-based configuration file.
6. The controller handles validation and form data. Your application can simply read out these values.

Struts is a great code-based framework to start your first MVC architecture with. In order to develop a struts application, you need to have a running instance of the Tomcat Web Server and the Struts Framework.

Lastly, the view, is typically a JSP page (JavaServer Pages) page or template with some simple custom tags (little variables) in it. The JSTL (JSP Standard Tag Library) provides a set of html-like tags that can be used to access data objects and embed them in a page.

A fairly new technology, JSF (JavaServer Faces) also provides a "tag language" for accessing and displaying re-usable web components (widgets). This can be used in place of the JSTL library. Some folk also prefer to use XSLT (a SGML-based W3C specification for transofming XML documents into other types; like XHTML; using a special XSL style sheet) to render their views. There is a great article showing the use of Struts with XSLT on JavaWorld. But first, get into Struts with this article.

Hope this introductory article proved useful to you! Enjoy!

Web Discoveries Blog

This is my new weblog where I'm going to mention all those wonderful web site development tips and tricks that I've discovered. Hopefully, I'll make a little money off adsense too.