Profile

Cover photo
Anthony Dourish
Attended Heworth Grange Comprehensive
Lives in Reston, VA, USA
97 followers|754,664 views
AboutPostsCollectionsPhotosYouTubeReviews

Stream

Anthony Dourish

Shared publicly  - 
Google wants to teach you deep learning — if you're ready that is. The tech giant has launched a free course explaining the machine learning technique that underpins so many of its services....
16
2
Eva Hsieh's profile photo湯愛薇(CAAAV)'s profile photo

Anthony Dourish

Shared publicly  - 
 
Naming is hard. There are only two hard things in Computer Science: cache invalidation and naming things. - Phil ...
14
1
Lyndon Bredenkamp's profile photo
Have him in circles
97 people
anjani turlapati's profile photo
Valdeir thyago Ferreira's profile photo
B. Reyes Maria Magdalena's profile photo
Rama Mohan Dharmavarapu's profile photo
Sravan Kumar Musunuru's profile photo
Rana Majid's profile photo
Mark Waggitt's profile photo
Santosh kadli's profile photo
Thomas Hartnett's profile photo

Anthony Dourish

Shared publicly  - 
 
There are some people who are still on the fence on whether they should use TypeScript to compile JavaScript. Here is a basic inheritance example. Writing the TypeScript code took a few minutes. To write the equivalent JavaScript would be time consuming. Not impossible but it would take quite a while to write this code. Also note that TypeScript constructs the JavaScript perfectly including prototypes.

#typescript #javascript

//////////////////////////////////////////////////////////////////////////////////
// Input TypeScript

module com.zoo.animals {
export class Animal {
constructor(public name) {
}

move(meters) {
alert(this.name + " moved " + meters + "m.");
}
}

export class Snake extends Animal {
move() {
alert(this.name + " is Slithering...");
super.move(5);
}
}

export class Horse extends Animal {
move() {
alert(this.name + " is Galloping...");
super.move(45);
}
}
}

var sam = new com.zoo.animals.Snake("Sammy the Python");
var tom: com.zoo.animals.Animal = new com.zoo.animals.Horse("Tommy the Palomino");

sam.move();
tom.move(34);

//////////////////////////////////////////////////////////////////////////////////
// Output JavaScript
var com;
(function (com) {
var zoo;
(function (zoo) {
var animals;
(function (animals) {
var Animal = (function () {
function Animal(name) {
this.name = name;
}
Animal.prototype.move = function (meters) {
alert(this.name + " moved " + meters + "m.");
};
return Animal;
})();
animals.Animal = Animal;
var Snake = (function (_super) {
__extends(Snake, _super);
function Snake() {
_super.apply(this, arguments);
}
Snake.prototype.move = function () {
alert(this.name + " is Slithering...");
_super.prototype.move.call(this, 5);
};
return Snake;
})(Animal);
animals.Snake = Snake;
var Horse = (function (_super) {
__extends(Horse, _super);
function Horse() {
_super.apply(this, arguments);
}
Horse.prototype.move = function () {
alert(this.name + " is Galloping...");
_super.prototype.move.call(this, 45);
};
return Horse;
})(Animal);
animals.Horse = Horse;
})(animals = zoo.animals || (zoo.animals = {}));
})(zoo = com.zoo || (com.zoo = {}));
})(com || (com = {}));
var sam = new com.zoo.animals.Snake("Sammy the Python");
var tom = new com.zoo.animals.Horse("Tommy the Palomino");
sam.move();
tom.move(34);
4
1
Lyne Vale's profile photo

Anthony Dourish

Shared publicly  - 
Learn the fundamentals of Release Management, how it relates to DevOps, and benefits it and continuous deployment bring to any organization. More specifically, we cover these topics in this module: [
3

Anthony Dourish

Shared publicly  - 
11
3
Khurram Bashir's profile photoBibacz LP's profile photo

Anthony Dourish

Shared publicly  - 
Daniel Egan (@DanielEgan) has been a .NET guy for a long time, but he's taking himself through a migration - a migration to the open source MEAN stack. Just like when you learn a new spoken language,
11

Anthony Dourish

Shared publicly  - 
 
Using WebAPI, TypeScript, and file:input control to upload a file. In this example we send both the file and a JSON payload to the server.

--------------------------------------------------------------------------------------------------
DocumentModel.ts:

module Com.Document.Models {
export class DocumentModel {
constructor() {
this.Files = new Object();
this.FileDescription = '';
}
public Files: any;
public FileDescription: string;
public FileExtension: string;
public UserId: string;
public Lenght: string;


public IsFileDescriptionValid(): boolean {
var valid: boolean = false;
if (this.FileDescription == undefined || this.FileDescription.length <= 500) {
valid = true;
} else {
valid = false;
}
return valid;
}

public IsFilesValid(): boolean {
var valid: boolean = false;
if (this.Files !== undefined && this.Files.length >= 0) {
for (var i = 0; i < this.Files.length; i++) {
var file = this.Files[i];
if (file.size > 0) {
valid = true;
}
}
}
return valid;
}

}
}

--------------------------------------------------------------------------------------------------
MyController.ts:

UploadDocumentClick() {
var docModel = new Com.Document.Models.DocumentModel();
// set the test of docModel based on your view bindings.
var e = <any>document.getElementById("fileInput");
docModel.Files = e.files;
if(docModel.IsFilesValid()){
this.Service.UploadDocument(docModel);
}
}

--------------------------------------------------------------------------------------------------
MyService.ts

UploadDocument(docData: Com.Document.Models.DocumentModel) {

var result;
var formData = new FormData();
if (docData.Files !== null && docData.Files.length > 0) {
for (var x = 0; x < docData.Files.length; x++) {
formData.append("file" + x, docData.Files[x]);
}
}
formData.append('docData', JSON.stringify(docData));

$.ajax({
type: "POST",
url: this.apiUrl + "/" + "UploadDocument",
async: false,
processData: false,
contentType: false,
data: formData,
success: function (data) {

result = data;

},
error: (xhr, textStatus, errorThrown) => {
console.log("Error executing - " + textStatus);
}
});
return result;

}

--------------------------------------------------------------------------------------------------
HTML:

<input type="file" name="file" id="fileInput" accept=".txt,.doc">
<input type="submit"
name="btnUploadDocument"
value="Upload"
onclick="myController.UploadDocumentClick(); return false;"
id="btnUploadDocument">

--------------------------------------------------------------------------------------------------
WebAPI:

MyController.cs

[HttpPost, Route("api/document/UploadDocument")]
public async Task<HttpResponseMessage> UploadDocument()
{
MultipartFormDataStreamProvider provider = null;
var documentUploadModel = new DocumentUploadModel();
try {
provider = new MultipartFormDataStreamProvider("C:\temp");

var streamProvider = await Request.Content.ReadAsMultipartAsync(provider);
var docData = JObject.Parse(streamProvider.FormData["docData"]);
documentUploadModel = docData.ToObject<DocumentUploadModel>();

foreach (var file in streamProvider.FileData)
{
var fileInfo = new FileInfo(file.LocalFileName);
documentUploadModel.FileExtension = fileInfo.Extension;
documentUploadModel.Length = fileInfo.Length;
documentUploadModel.FileName = fileInfo.FullName;

// doc something with the file.

FileOperation.Delete(file.LocalFileName, false);
}
}
catch(Exception ex)
{
throw
}
finally
{

}
return Request.CreateResponse(HttpStatusCode.OK, "success!");
}

--------------------------------------------------------------------------------------------------
DocumentModel.cs


public class DocumentUploadModel
{

public Guid UserId { get; set; }
public long Length { get; set; }
public string FileExtension { get; set; }
public string FileDescription { get; set; }
public string FileName { get; set; }
}
1
Anthony's Collections
People
Have him in circles
97 people
anjani turlapati's profile photo
Valdeir thyago Ferreira's profile photo
B. Reyes Maria Magdalena's profile photo
Rama Mohan Dharmavarapu's profile photo
Sravan Kumar Musunuru's profile photo
Rana Majid's profile photo
Mark Waggitt's profile photo
Santosh kadli's profile photo
Thomas Hartnett's profile photo
Work
Occupation
Principle software developer. Currently working with JavaScript, .Net, and SQL server.
Skills
JavaScript, TypeScript, .Net, SQL Server, Java, Oracle
Employment
  • Principle software developer, present
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Currently
Reston, VA, USA
Previously
Gateshead, UK - LaGrange, GA, USA
Story
Introduction
It's a very bad angle.
Bragging rights
:)
Collections Anthony is following
View all
Education
  • Heworth Grange Comprehensive
    School
  • Gateshead College
    OND Electronics and Electrical Engineering, 1990 - 1994
  • University of Sunderland
    HND Electronics and Electrical Engineering, 1994 - 1996
  • University of Sunderland
    BEng Digital Systems, 1994 - 1996
  • Microsoft
    MCSD Web Applications, 2014 - 2014
Basic Information
Gender
Male
Relationship
Married
Public - a year ago
reviewed a year ago
2 reviews
Map
Map
Map