Project 5: Project Review

by samscaife on Thursday, 10 May 2012

Project 5: Twit Twock

by samscaife

In the end getting this live was a nightmare as I missed out some basic steps due to my unfamiliarity with server side programming but by slowly taking apart examples and experimenting with my code I was able to track down my bugs and get it live, which I'm really pleased with. so its now live on my openshift account with the name Twit Twock.


This visualisation works as a clock which shows a universal time unconnected to any real sense of time. the top row of circles represent the volume of tweet containing the word 'late' within 6 seconds, so the 10 of them make up 1min. The bottom row is the same but each circle represents 1 hour, there are 24 of them in total making up 1 day. The idea is that you are unable to use the clock to time the events in your life which feeds back into people communicating their frustration. And if no one feels late then the clock dose not display as no information is coming in. Given time you could learn to read a relative time from the clock by watching for trends which appear at different times of day, though thats not really the point. The whole thing is kind of pointless and self mocking

Project 5: Going live in the cloud

by samscaife on Wednesday, 9 May 2012

I've now got it all working! but that's on my local machine. As i've been doing some research into how to get it online I think the easiest way is going to be by using some cloud based hosting. There is a large amount of different cloud hosts available but the one which stood out to me was OpenShift. This is a free service and I've found an article about using this in connection with Cloud9, a cloud ide. By using these two services my project will be fully cloud based!

Project 5: Twit & JSON

by samscaife on Friday, 4 May 2012

I have found a Twitter api client for node called Twit this will allow me to access the Streaming api. As this is on the going to work on the sever side I need to have it talking to my client side js to do this I've been doing some reading (Manipulating JSON and XML with node.js, JSON Round Trip with node.js) and I'm going to use GET to pull a json file with the current amount of tweets from the sever. I will then be able to parse this file and set by count variable equal to it.

Project 5: Tweet faker in node.js

by samscaife on Wednesday, 2 May 2012

I wanted to get my Tweet faker working in node before I tried pulling in live information. Node.js has the ability to install little programs and libraries into your code which allow you to easily do a whole host of different things. One of these is called File System, or fs. With this you can do a load of different functions with your files what I was interested in though was the ability to alter the section of my server which controlled what to deliver to the user so that It would give a file instead of text.

I managed to figure out how to do this by changing the string which was delivered to a variable which was loaded with the file information from fs, here is an example of the code;

fs.readFile('./index.html', function (error, data) {
if (error) {
throw error;
}
index = data;
});

function start(response) {
console.log("Request handler 'start' was called.");

response.writeHead(200, {"Content-Type": "text/html"});
response.write(index);
response.end();
}

This is just the small section which delivers the html file to the rest of the code. Using this method I was able to get my sever delivering the html and js files so I had my fake tweet visualisation running. This method however runs multiple versions of my twitter api key so if I where to go live with this I would get banned. To stop this I need to migrate my code to the server then use JSON to request the variables

Project 5: Starting with Node.js

by samscaife on Tuesday, 1 May 2012

When it came to installing node I got a bit confused at first as something went wrong in the installation and it was not working like it was meant to. This lead me to trying to emulate Linix on my pc so that I could use the large amount of user documentation for it. However I final managed to get it installed on my pc after reading this tutorial.

Node.js is controlled through the CLI, command line interface, which looked scary at first but turn out to be very logical and simple to use. I came across and online book Node Beginner which was incrediably helpful, I ended up reading all of it. This book clearly explained how Node.js worked and how to build for it. Through reading that book and this article on Writing for node and the browser I was able to begin to understand the aims of server side programming.

I started off building a simple hello world server which simply writes hello world in the browser. I then worked through the examples in the node beginners book seeing how everything worked. Once I'd built its simple server which would communicate between pages I re wrote the whole thing myself to see if I could remember the correct structure and how to link everything. Doing this really helped me understand what I was writing.