Showing posts with label Project 5: Independent Project. Show all posts
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
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
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
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!
- One comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
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.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
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
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
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.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
The code for my processing twitter counter was pretty simple so I decided that I could have a go at building a fake version using js. I chose to make it fake because I did not want to get into any of the complications for needing to access the Twitter api as I'm not sure what they will be and would like to know I can get the underlying structure working first.
Again I made strong use of comments in this project so that I could easily refer to it and understand what was going on. For the tweets I just made a simple random number generating function which I used inplace of a real number of tweets.
/*current bugs
- suspected memory leak with currentTime function, animates even outside of the loop
-growth is not smooth. potentially something with how Im looping through my draw.
*/
//global variables
var countDuration = 10, //seconds. However js dose use millis.
globalCount = 0,
pGlobalCount = 0,
cp = 0,
time = 0, //this will return a value in seconds
context,
SCREEN_HEIGHT,
counterAmount = 10,
nodeDistance = 0,
nTweets = 0,
timeReset = 0,
s = 0,
//create builder
Counter = (function() {
//builder variables
var countDisplays = [],
canvas,
SCREEN_WIDTH;
//initiate
function init() {
measureScreen();
currentTime();
//sets up DOM elements
canvas = document.createElement('canvas');
context = canvas.getContext('2d');
setCanvasSize();
document.body.appendChild(canvas);
//loads counters elements
createDisplays();
//Starts Loop
update();
}
function measureScreen() {
SCREEN_WIDTH = window.innerWidth;
SCREEN_HEIGHT = window.innerHeight;
}
function setCanvasSize() {
canvas.width = SCREEN_WIDTH;
canvas.height = SCREEN_HEIGHT;
}
function clearContext() {
context.fillStyle = "rgb(0,0,0)";
context.fillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
}
//Tweet facker
function fakeTweets(frequency) {
var random = (Math.random()*10)+1;
nTweets++;
if( nTweets === frequency) {
globalCount += random;
nTweets = 0;
}
}
//caluculates which counter should be counting
function countPosition() {
if (currentTime() - timeReset === countDuration) {
//if (currentTime() % countDuration === 0) { //THIS IS BUGGED STICKS ON 4
timeReset = currentTime();
cp++;
pGlobalCount = globalCount;
}
if (cp === counterAmount) cp = 0;
}
//recursive function which increase time by 1 every second.
function currentTime() {
time++;
return (time/60).toFixed(0); //toFixed lets you round to X decimal places. in this case 0.
//setTimeout(startTime,1000);
}
///////////////////////////////////////////////////////
// COUNTERS
//renders the counters
function drawCountDisplays() {
//runs through all the counters in the array
for(i = 0; i < countDisplays.length; i++) {
var current = countDisplays[i];
// checks if the current array should be counting
if(i === cp) {
current.counting();
current.size = current.counting();
current.countRender();
} else {
current.countRender();
}
}
}
//populates an array with count displayers
function createDisplays() {
for(i = 0; i < counterAmount; i++ ) {
//xpos: {SCREEN_WIDTH / (counterAmount - i)};
//xpos++;
nodeDistance = SCREEN_WIDTH / counterAmount;
countDisplays.push(
new CountDisplay((i+0.5) * nodeDistance, 0));
}
}
// end of counters
///////////////////////////////////////////////////////
//DEBUG PRINTER
function debug() {
document.getElementById("globalcount").innerHTML= "Global Count = " + globalCount;
document.getElementById("pglobalcount").innerHTML= "Previous Global Count = " + pGlobalCount;
document.getElementById("countposition").innerHTML= "Counter Position = " + cp;
document.getElementById("timereset").innerHTML= "Time reset = " + timeReset + "sec";
document.getElementById("time").innerHTML= "Time = " + currentTime() + "sec";
}
function render() {
currentTime();
fakeTweets(25);
//createDisplays();
countPosition();
drawCountDisplays();
debug();
}
//the loop - I think This is a recursive function.
function update() {
clearContext();
requestAnimFrame(update);
render();
//fakeTweets(25);
//countPosition();
//drawCountDisplays();
}
//api
return {
init: init
};
})();
// Constructer for Count Display Objects
function CountDisplay(xpos, size) {
this.size = size;
count = 0;
//counts the amount of tweets
this.counting = function() {
count = globalCount-pGlobalCount;
return count;
}
//draws the counter based on the amount of tweets
this.countRender = function(){
context.fillStyle = 'rgba(255,255,255,0.5)';
context.beginPath();
context.arc(xpos, SCREEN_HEIGHT/2, this.size, 0, Math.PI * 2, true);
//context.arc(xpos, 200, 50, 0, Math.PI * 2, true);
context.closePath();
context.fill();
}
};
//starts code
window.onload = function() {
Counter.init();
};
Its steadily getting more and more complicated! and I've not even started on the web sever. This took a little more work as I had a few simple bugs which due to how new I am to JS I couldn't spot. There are still some bugs in this any way, as you can see from the top line. I have not put this online but here is a screen grab of it in action
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
I've never done any JS before for I decided a good way to start was to do some of the examples from the website Codecademy so that I could see how the structure of things such as arrays and variables where in JS. In total I did a little over 100 exercises on the site covering the basics and object oriented programming.
Alongside this I also downloaded some example projects from CreativeJS by Paul Lewis and Seb Lee-Delisle. I thought it would be a good idea to look at Seb's coding as he taught me everything I know about programming so far so it might have similarities in the structure and approach to it. I looked thought these projects and tried to look for the various section that appear in processing such as the draw loop and the setup, by doing this I was able to understand the structure of JS. Through doing this I was introduced to some new concepts such as DOM, Document Object Model, and a better understanding of API, application programming interface.
I wanted to start off really simple, so instead of building twitter counter straight away I build a simple bouncing ball in js. I made sure that I hand wrote everything so that I would be able to spot when I made mistakes and would actually be learning. I also made sure to comment my code so that I would understand what every section was doing.
//load up my bounce class
var Bounce = (function() {
var canvas = null,
context = null,
SCREEN_WIDTH = 0,
SCREEN_HEIGHT = 0,
//ball variables
xPos = 500,
yPos = 500,
xVel = 10,
yVel = 9,
radi = 50;
// init the code
function init() {
measureScreen();
//creates DOM elements
canvas = document.createElement('canvas');
context = canvas.getContext('2d');
setCanvasSize();
document.body.appendChild(canvas);
//StartsLoop
update();
}
function measureScreen() {
SCREEN_WIDTH = window.innerWidth;
SCREEN_HEIGHT = window.innerHeight;
}
function setCanvasSize() {
canvas.width = SCREEN_WIDTH;
canvas.height = SCREEN_HEIGHT;
}
function clearContext() {
context.fillStyle = "rgba(255,255,255,1)";
context.fillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}
// draws bouncing ball
function draw() {
xPos += xVel;
yPos += yVel;
// x cordinate bounce
if (xPos > SCREEN_WIDTH - radi) {
xVel *= -1;
xPos = SCREEN_WIDTH - radi;
}
if (xPos < radi) {
xVel *= -1;
xPos = radi;
}
// y cordinate bounce
if (yPos > SCREEN_HEIGHT - radi) {
yVel *= -1;
yPos = SCREEN_HEIGHT - radi;
}
if (yPos < radi) {
yVel *= -1;
yPos = radi;
}
context.fillStyle = 'rgb(200,255,200)';
context.beginPath();
context.arc( xPos, yPos, radi*2, 0, Math.PI * 2, true );
context.closePath();
context.fill();
}
//Loop
function update() {
clearContext();
requestAnimFrame(update);
draw();
}
//api
return {init: init};
})();
//start my code when window opens
window.onload = function() {
Bounce.init();
};
I have put a live version on my site. As you can see its a little buggy but I'm pretty happy with how it turned out and learn a lot writing it. The project runs in html5 using the jS to put the canvas element in the html when the page loads, this is so it will be full screen regardless of screen size.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
I was quite keen with this project to use it to enable me to learn JavaScript. It had been my intention to recreate my processing project in JavaScript before I found out about the repeat api use issue. Now however I have found out about Node.js which is defined on their site as,
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
This is perfect for what I want to do as it will all be in JS so that I can spend more time learning it and it will enable me to have my api section running server side.
Node.js looks really advanced however so I'm going to start by learning some JS and then porting my existing processing prototype to JS.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
After doing some more reading about the Twitter streaming api I came across a paragraph which I had not noticed before.
Each account may create only one standing connection to the Streaming API. Subsequent connections from the same account may cause previously established connections to be disconnected. Excessive connection attempts, regardless of success, will result in an automatic ban of the client's IP address. Continually failing connections will result in your IP address being blacklisted from all Twitter access.
The impact of this means that I can not have each user run a version of my code otherwise I would be running multiple connections and would risk an automatic ban. There is the possibility of using a 'site stream' though you have to apply for this and I do not want to waste time waiting to see if I'll get one.
The way around this is to have my code running on a websever which is always active which then users request the information from when they visit the site. I like this as it lets me follow my idea of the site as an object. However I've no idea about server side programming so I need to do some research.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
Currently I know that I want my visualisation to be delivered online but I'm not sure what I'm going to build it with. However to understand the processes involved I've decided to mess around with processing and the Twitter api.
There is a Java Libary which I found on a blog post by Jer Thorpe called Twitter4j which will let me access the twitter api. I created my api key by going to the developer section of twitter then messed around with some code I found so that I could understand what each of the sections did.
The first project uses the twitter search api. It was built by going through this Jer Thorpe tutorial then modding the code slightly.
This project searches a given time period for a random sample of X tweets containing Y, in this example X is 10 and Y is "Sleep".
The search api is good but it only gives you access to existing tweets not ones which are coming in live for this I need to use the streaming api.
I found an example by Michael Zick Doherty of using Twitter4j to access the streaming api and display images when they come in on a chosen subject. By looking at this and decompiling the Twitter4j library so I could understand its structure and how the classes worked.
With this knowledge I was able to write a prototype that I could increment a variable when ever a tweet came in. Once I had this I was able to create a display which would show this amount over time. One thing which was really useful while building it was to create a little debug panel which I could look at the amounts in my current variables and spot if there where any errors.
//Search term
String keywords[] = {"breakfast"};
//Global variables
int countDuration = 60000; //how long before the counter moves on (in miliseconds)
int globalCount;
int pGlobalCount; //previous global count value
int cp = 0; //counter position
float time = 0;
TweetCount[] tweetCount = new TweetCount[59]; //amount of bits of data to collect
TwitterStream twitter = new TwitterStreamFactory().getInstance();
// Twitter API variables
static String OAuthConsumerKey = "XXXXXXXXXXXXX";
static String OAuthConsumerSecret = "XXXXXXXXXXXX";
static String AccessToken = "XXXXXXXXXXXXXX";
static String AccessTokenSecret = "XXXXXXXXXXXXXXXXXXXXX";
//////////////////
//////////////////
void setup() {
size(1000, 400);
noStroke();
imageMode(CENTER);
smooth();
connectTwitter();
twitter.addListener(listener);
twitter.filter(new FilterQuery().track(keywords)); // This is where my filters come into the code
for(int i=0; itweetCount[i] = new TweetCount();
}
}
void draw() {
background(0);
debug();
CountPosition();
for(int i=0; ifloat xpos = map(i, 0, tweetCount.length, 0, width);
tweetCount[i].render(xpos);
}
tweetCount[cp].counting();
}
// Initial connection
void connectTwitter() {
twitter.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret);
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);
}
// Loading up the access token
private static AccessToken loadAccessToken() {
return new AccessToken(AccessToken, AccessTokenSecret);
}
// This listens for new tweet
StatusListener listener = new StatusListener(){
public void onStatus(Status status) {
//println("@" + status.getUser().getScreenName() + " - " + status.getText());
globalCount++;
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
//System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
// System.out.println("Got track limitation notice:" + numberOfLimitedStatuses);
}
public void onScrubGeo(long userId, long upToStatusId) {
System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
}
public void onException(Exception ex) {
ex.printStackTrace();
}
};
void CountPosition() {
if(millis()-time >= countDuration) {
time = millis();
cp++;
pGlobalCount = globalCount;
}
if (cp==tweetCount.length) cp = 0; //counter postion reset
}
void debug() {
text("globalCount =" + globalCount, 20, 20);
text("pGlobalCount =" + pGlobalCount, 200, 20);
text("CountPosition =" + cp, 20, 40);
text("time =" + millis()/1000, 20, 60);
}
class TweetCount {
int count;
int countreset;
TweetCount() {
}
void render(float xpos) {
fill(255,100);
ellipse(xpos, height/2,count,count);
fill(255);
text(count, xpos, height/2+70);
}
void counting() {
count = 0;
count = globalCount-pGlobalCount;
//println("count =" + count + " globalCount =" + globalCount + " pGlobalCount =" + pGlobalCount);
}
}
At this stage I am happy with my knowledge of how the code side of it works I just need to look into how I will make this available online
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
I've now settled on a new idea. I got a little lost thinking about interesting ways in which I could use images from Instgram. I did want to create a site which would show images of what people are eating in real time based on the images coming in from Instgram (I may still try build this sometime as it sounds like a fun project). Now though I've decided that I'm just going to draw my data from twitter.
The basic idea is that I want to create an abstracted real time clock based on people talking about lateness on twitter. Hopefully this will produce an interesting clash of ideas. I am still keen on it being created for a gallery space but I also want it to be accessible online so that, like the data its based on, it's not spatially limited.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
Glitchhiker was the winner of the 2011 Global Game Jam NL. Its a simple game with a fantastic mechanic, the game can die. Infact it is already dead. The game works by having a global life count, starting the game uses a life and collecting 100 coins gains a life. Once the lifes reach 0 the game is no longer playable or downloadable so it dies!
This is quite a similar concept to what I picked up from Iain M banks. I think it would be really interesting to build a world from data which only develops based on if people are using it. I can picture this in a few forms;
- A virtual world which grows over time as it is viewed at a speed based on the amount of people viewing it. If no one or a limited number of users are viewing it then it will degenerate with time until its being watched again.
- A generative narrative animation which progresses when ever someone is viewing it so that if you come back to it you will miss parts of it. This would work really well if it was a 24 hour loop so it would encourage people who are interested in the story to visit regularly so that they can know where they are within the story and then catch up. This would need a story which did not depend on traditional narrative structures, such as the Golden Notebook by Dorris Lessing
This kind of approach also in this idea I was talking about previously in my blog about treating the website like a real thing which has a life away from the user. This contrasts with the classic view of it being a portal to dispense information.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
Well I have written a few notes in my sketch book based on a new idea of displaying some form of life data online. As they are in my personal sketchbook like before I'm going to upload them here as I will still need to use my sketchbook! I also played around with some different ideas here as well.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
After talking to my tutors about my idea they did not think that I would be able to get enough data to realise my idea in a worthwhile way. They suggested that I use my strong interest in data and switch to using a data set which I do not have to create myself such as Twitter or Instagram to base my idea on. They also think that I should draw on some of the ideas from my dissertation, which talks about lifelogging and the increase of data about a users life which is being gathered and made available online.
I was quite excited about building this visualisation but I do agree with my tutors about this idea not being something which I have the resources to create at the moment. So now I've got to think of a new idea!
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
As I would like to build some form of device to feed data to my visualisation I have order myself an Arduino Uno. But until that arrieves I throught it would be a good idea to see if I could build a quick prototype in processing which would graphically display the volume of a mic input. I decided to ignore the web limitations for now as I had no idea how easy it would be to put together.
I used Minium, a sound library for processing. Which I discovered records the volume from the left and right channel with a value between 0 and 1. This meant that with a very small amount of code I was able to create a simple visualisation which changed the colour of a circle based on the volume.
// load libaries
import ddf.minim.*;
// minium vars
Minim minim;
AudioInput input;
void setup(){
size(500,500);
smooth();
noStroke();
colorMode(HSB);
minim = new Minim(this);
input = minim.getLineIn();
}
void draw() {
background(0);
fill(volume(),255,255);
ellipse(width/2,height/2,100,100);
println(input);
}
float volume() {
return(input.mix.get(1)*1000);
}
void stop(){
input.close();
minim.stop();
super.stop();
}
even with something simple like this if you where to have a large amount of them positioned relative to there location you would get a really interesting image
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
When looking for inspiration on the potential forms which my sound data could be displayed in I came across these abstracted literal tube maps at Line Posters.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
I found an example of a great little web based visualisation. Color Forecast shows what people are wearing in key fashion capitals around the world in real time. Its has been made by an online clothes retailer and will suggest what clothes you should wear to go with the city. It also shows a little bit of the history of the data and shows its process.
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
I was not under the impression that my idea was completely new but I was not aware of any examples. That was until I read a line In Emotional Geographies, a book I've been reading because I think I'm aiming to visualise an emotional geography of the noise of life. The line was about the desire to "decouple diological and military concers" which made me think of a machine they build in The Dark knight which make a large sonar real time map of the city from the sound provided through mobile devices... pretty much a literal visual version of what I wanted to build. Incase you have not seen the film here is a clip
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit
When I was imagining how a visualisation of location mapped sound might look the work of Aaron Koblin came to mind. In particular one project which he creates a visualisation tool for SMS messages in Amsterdam,
The video really shows the patterns which appear in this style of data. It looks almost like bar charts but they are mapped in 3d space. I would like to create a 3D space within the website which could be explored by the user so that they can focus on the section of the data they are personally interested in
- Leave your comment • Category: Project 5: Independent Project
- Share on Twitter, Facebook, Delicious, Digg, Reddit




