Processing and Twitter

Screen shot 2013-03-06 at 1.06.42 AM

Recently I’ve been looking into creating some design that is heavily reliant on code and coding. I’m absolutely amazed by all the people out there willing to post the entire code of their sketches, or post regularly to help forums.. I don’t think I’d be able to get through an inch of the world of code without all these amazing and helpful people. Which got me to thinking that perhaps in return when I stumble on things that work I should also share my learning with people so they can gain from it too.

So, this week I was interested in collecting data off of twitter through processing. I found a really straight forward tutorial by Jer Thorp and through tinkering for a few hours I was able to get the sketch to function and collect tweets #Tasmeem.

This is the link to the original post, where you can find all the steps. I am only going to be writing about the things I needed to tweak to get it to run for me, and where I found those tweaks online:

http://blog.blprnt.com/blog/blprnt/updated-quick-tutorial-processing-twitter

Regarding the twitter oAuth process there are a few steps that are different, but its not something you can’t just messing around and figure out. Don’t forget you need all four codes for this to run.

To import the twitter4j library you can’t just simply drag and drop the file into the sketch as is it mentioned on Jer’s blog. You need to manually install the library following the steps listed here:

http://wiki.processing.org/w/How_to_Install_a_Contributed_Library

Here is an image, all the highlighted text had to be edited after I unzipped the twitter4j file, and placed into my sketch folder.

Screen shot 2013-03-07 at 12.16.51 AM

Over and over again I got the error “Cannot find a class or type named Tweet”. I found two really helpfully links:

https://forum.processing.org/topic/twitter4j-error-cannot-find-a-class-or-type-named-configuration-builder

http://stackoverflow.com/questions/14510641/twitter4j-not-recognizing-setrpp-or-tweet-class

Which made me add the following code:

import twitter4j.*;

import twitter4j.conf.*;

And switch out the lines of code about Tweet t = (tweet).. to:

Status t=(Status) tweets.get(i);
User u=(User) t.getUser();
String user=u.getName();

[If you are getting an error about setRpp the last link above had a solution to that also, I didn't]

Here is the edited code:

import twitter4j.*;

import twitter4j.conf.*;

import java.util.List;

//Build an ArrayList to hold all of the words that we get from the imported tweets
ArrayList<String> words = new ArrayList();

void setup() {
  //Set the size of the stage, and the background to black.
  size(1300,800);
  background(0);
  smooth();

  //Credentials
  ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("XXXXXXXXXXXXXXXXXXX");
cb.setOAuthConsumerSecret("XXXXXXXXXXXXXXXXXXX");
cb.setOAuthAccessToken("XXXXXXXXXXXXXXXXXXX");
cb.setOAuthAccessTokenSecret("XXXXXXXXXXXXXXXXXXX");

  //Make the twitter object and prepare the query
  Twitter twitter = new TwitterFactory(cb.build()).getInstance();
  Query query = new Query("#tasmeem");

  //Try making the query request.
  try {
    QueryResult result = twitter.search(query);
    ArrayList tweets = (ArrayList) result.getTweets();

    for (int i = 0; i < tweets.size(); i++) {
Status t=(Status) tweets.get(i);
User u=(User) t.getUser();
String user=u.getName();
      String msg = t.getText();
      Date d = t.getCreatedAt();
      println("Tweet by " + user + " at " + d + ": " + msg);
      //Break the tweet into words
      String[] input = msg.split(" ");
      for (int j = 0;  j < input.length; j++) {
       //Put each word into the words ArrayList
       words.add(input[j]);
      }
    };
  }
  catch (TwitterException te) {
    println("Couldn't connect: " + te);
  };
}

void draw() {
  //Draw a faint black rectangle over what is currently on the stage so it fades over time.
  fill(0,1);
  rect(0,0,width,height);

  //Draw a word from the list of words that we've built
  int i = (frameCount % words.size());
  String word = words.get(i);

  //Put it somewhere random on the stage, with a random size and colour
  fill(255,random(50,150));
  textSize(random(10,30));
  text(word, random(width), random(height));
}

Day 50 – Aisha

This year at VCUQ I was able to do something I’d been wanting to do for a long time, which was working with people with intellectual or developmental disabilities. At the beginning of the year I joined Best Buddies of Qatar where I was paired with the sweetest soul I could ever ask for as a friend. I can’t fully express right now how or why meeting and working with Aisha represent a step in the direction of my thesis, but I know it belongs in my 60 day challenge. I’m just not ready to talk about it yet.

Day 51 – Truth or Truth

There we sat, the five of us, on the last day of our field study, in a Muslim run Italian restaurant in the heart of Amsterdam. Not wanting the night to end one of us suggested a game of truth or dare. However after reviewing the types of dares that might be suggested we decided to stick with playing our slightly modified version of the traditional game. It was that game that finally allowed us to put down the masks we so desperately clung to every day of our lives. For a short while in Amsterdam we allowed ourselves to be seen as exactly who we are.

That night changed everything for me.

Community Classes VCUQ

I think one of the smartest choices I made last semester was to join the basic drawing and water color community classes at VCUQ. The classes started a few weeks into the semester so I had a chance to get adjusted to the new schedule and they only lasted for 8 weeks. I took basic drawing with Ben Barbour, a soft spoken artistic fella. I honestly feel sorry for the man, I just had the worst case of low self esteem in his class, but he always had something positive and encouraging to say.. I really enjoyed his class. In fact I was signed up to take his summer class until I decided to fly away to Kuwait for the summer, now I’ll be in his class over the fall semester.. One of the big things I am looking forward to about the fall actually. Above are the last two drawing I did in his class [Ben brought in fish for our last day of drawing, it smelly, weird, and fun].

Above is the last painting I did in Charles Bleick’s (Chuck) water color class. I also really enjoyed Chucks class, except it was at 5pm on a Thursday, which made going to it feel more like a chore than a pleasure some days.. But that isn’t a comment on the quality of the class, just the fact that the class was on the last hour of the last day of the week.. which is generally when people are just wiped out.. which I always was. I’m really debating about whether I should sign up for painting in the fall as well.. I feel like there just wont be enough hours in the week to get it all in.. We’ll see..

 

Ego by Takashi Murakami

My sister is out of school for a week so I decided to take her to the Murakami exhibit at AlRiwaq art space, in front of the Museum of Islamic Art. I didnt think anything would be able to top Cai Guo-Qaing‘s fireworks show for at least a while, but I was wrong; this exhibit was fantastic. In one room there was this huge circus tent, with flower cushions on the floor and we sat on them and watched anime for half an hour.. I felt like I was in a completely different universe.. All I could think about during the whole experience was Bruce Sterling’s talk about “suspending disbelief”.. today was the first time I suspended my disbelief.. it was an amazing feeling.

On the way out the lady at the front desk handed my sister and I this build it yourself paper doll.. we enjoyed putting it together ourself 🙂

Visual Interface Design

For my elective this semester I signed up for a graduate level graphic design class called Visual Interface Design. The class meets once a week, for six hours at a time. I honestly was really worried about that, but after attending the first class I was be happy with the way things played out. In this class we are doing 8 weeks of mini projects, at the end of 8 weeks we will choose one of our mini projects to expand into an 8 week final project. We are required to keep some form of journal for this class, and since our teacher suggested a tumblr, and I already had one I wasnt using, I decided to start posting my work there.

Above is an image from last weeks iPhone App design. I designed an App called In My City that basically tells you all the events going on in your city.

So far we’ve done 4 projects, I’m not sure if any of them really scream final project yet.. we shall see.

 

 

Design Studio One: Open Design (Part Two): Fab-Shoes

 

 

For the second half of the Open Design project in our studio one class we as groups exchanged projects. Our group inherited the Open Design shoe file. We decided we wanted to go two different directions with the project, one would be making a 3D printed heel, and the other would be modernizing a traditional Arab mens sandal. We ended up with two files for the heel, an illustrator file for the upper, and a Rhino file for the wedge, both files can be edited and printed at any fab lab in the world. The idea for the second shoe was actually to use an Eskafi (shoe makers) to build a shoe for us, and so we would be considering the labor of one man equivalent to the machines in a fab lab. But they actually didn’t have an Eskafi’s in Qatar (weird?) so we had to modify our idea and use a local shoe factory to assemble our shoe (which kind of makes it not an open design project, but there is nothing we could do about it..). For the sandal we created a basic illustrator upper that can easily be modified and cut.

Part Two

We’ve been done with the third project for a while now.. I just haven’t really found much time to sit down and post these. The assignment was basically a part two for the “I close my eyes..” project, we were asked to take our 3D models and make them into 2.5D objects by layering or folding material. All my pieces are made out of white bristol paper, and they are all hearts. The first is a failed example of the waffling technique.. I realized after the fact that I had designed the slices for normal paper and then I ended up choosing to cut them out of bristol (which is thicker) and so the slots weren’t big enough and it turned into a huge annoying mess. The second image is an example of Pepakura paper folding. The hardest part of Pepakura is setting up the Rhino file, but once you’re done its so fun to actually assemble the piece. Finally I decided to layer a few cross sections of a 3D model of a human heart. I really had fun losing myself in the construction of this project.. and I think I’ve fallen madly in love with the laser cutter 😉

VCUQ Painting and Printmaking Open House

I stopped by the painting and printmaking open house yesterday. I finally know why my linoleum prints didn’t work last year.. I didn’t own a fancy printing press! I’m glad I stopped by.. even though I won’t have time next semester to take a printmaking class, I think I might look into a summer class or something. The prints that were on display were breathtaking..