RSS
 

Fall 2012 Classes

12 May

Summer’s just starting but my schedule for next semester is confirmed.  You can see how these classes very specifically support my plans for researching and building out Galapag.us.

Basic Analog Circuits – Eric Rosenthal (Syllabus)

Today’s mostly digital world also requires a basic knowledge of analog circuits. In this course students learn about the basic principles of analog circuits design and operation. Students learn about discrete components such as resistors, capacitors, diodes and transistors as well as integrated components such as operational amplifiers. In addition, students become familiar with the operation of basic electronic test equipment such as digital multimeters, oscilloscopes, function generators. The instructor lectures on, and demonstrates, basic analog concepts so that students can form a basic rule of thumb understanding of analog circuits, concepts and components. In the lab, students can integrate analog solutions into their project work.

Data Without Borders: Data Science in the Service of Humanity - Jake Porway

We are living in the dawn of the big data era, a time in which the vast digitization of our world has created incalculable amounts of information that is now being used to drive our every decision, from what movie we decide to watch this weekend to how we navigate the globe next year. Though data can be immensely transformative, much of the efforts in data science are still focused on first-world gains, such as optimizing ad networks or recommending restaurants. As designers, developers, and scientists, it is not only incumbent upon us to understand how to analyze, understand, and tell stories with data, but also to think about its use in meaningful and socially conscious ways. This class will train students in the basic tools and trade of data science through exploration of a socially conscious data project. Students will learn to scrape, merge, and clean data with Python, perform statistical analysis and use machine learning algorithms in R, and visualize and explore data with R and D3. In addition to training students as junior data scientists, we will discuss the important social issues around data provenance, privacy, and the responsibility that comes with making claims from data.

Glitch - Kyle McDonald / Jeremiah Johnson

“…our control of technology is an illusion, and … digital tools [are] only as perfect, precise, and efficient as the humans who build them.” – Kim Cascone

“If it works, it’s obsolete.” – Marshall McLuhan

How do the tools and media we use affect the work we create? What biases are embedded in the software and data formats we take for granted? In this class we will reverse, invert, and deconstruct prescribed workflows. We’ll empower ourselves by digging into the intricacies of different formats. We’ll explore the limitations of our tools, and exploit the strange behavior at those limits. We’ll also spend a significant amount of time understand the history and theory behind glitch and noise, through enlightening readings, discussion, and exercises.

While this class will cover a variety of low level, technical topics, there are no prerequisites, and there is no single tool, environment, or language that we will focus on. We will instead aim for a more process-oriented approach, and students will be challenged at every level of technical expertise.

This two-credit will meet the first seven weeks of the semester.

PAC I – Evan Korth (Syllabus)

An accelerated introduction to the fundamental concepts of computer science for students who lack a formal background in the field. Topics include algorithm design and program development; data types; control structures; subroutines and parameter passing; recursion; data structures; searching and sorting; dynamic storage allocation; abstract data types, such as stacks, queues, lists, and tree structures; and an introduction to the principles of object-oriented programming. The primary programming language used in the course will be Java.

Understanding Genomes: An Introduction to Biohacking – Yasser Ansari (Syllabus)

This class will expose the tools and fundamental principles underlying the emerging biohacking and DIY Bio movements, providing students with practical knowledge and awareness of specific techniques. Beginning with the discovery of the three-dimensional structure of DNA and building up to genes, genomes, and genome sequencing, we will uncover the biological mechanisms at play and the specialized equipment and protocols being used in today’s laboratories, studios, and garages. Along the way, we will study scientific breakthroughs like the generation of the first recombinant DNA molecules, deconstruct infamous bioart pieces like “Alba” the bioluminescent bunny, and examine interesting amateur projects like homebrewed insulin. The first phase of the class will be focused on introducing core concepts through investigation and discussion. Continuing on, the second phase of the class will allow students to apply what they’ve learned through the design and development of their own projects. Class assignments will range from individual exercises and readings to group presentations and projects. Guest lecturers and visits to local laboratories will help provide additional context and insight during the semester. The ultimate goal of this class is to equip students with enough knowledge and skill to explore biologically driven concepts and projects with confidence. Although topics from molecular biology will be covered, no previous knowledge is required.

 
No Comments

Posted in ITP

 

Redial Final Project: Hermes Ordering System

03 May

In my Redial class, we learned about the dark arts of telephony in an age of digital, packets, and VOIP.  Once we learned the basics of operating in an Asterisk telephony server environment, we moved on to how to write scripts in Ruby, bash, whatever to interact with Asterisk during a phonecall.  We set up our own Rackspace servers loaded up with Asterisk and used our professor’s script to install needed software on its Ubuntu instance.  I’ve saved that script to add extra stuff when I’m setting up a new Ubuntu server from scratch.  Ubuntu basic literacy is now attained.

That part was fun enough, but it started to get interesting when our badass professor, Chris Kairalla, published some code to Github for interacting with a web front-end in JavaScript by using socket.io, node.js, and a Ruby-Asterisk Gateway Interface script interfacing with calls placed to Asterisk. That’s when the realm of ideas greatly opened up.  Real-time interaction with the phone dialpad to control a screen, an Arduino, robots, electric switches, whatever.  And with the explosion of JavaScript and Node.js, it couldn’t have come at a better time.

Here are the class notes:  http://www.itp-redial.com/class/

And the Github repo: https://github.com/itp-redial/

I set out with confidence, knowing I could use Professor Kairalla’s brilliant tinyphone code, which provided the framework to facilitate an incoming call into a caller object that one could manipulate in the web page DOM.

My idea was to build a bar or restaurant menu displayed on screens around a bar which would let customers place orders by just pressing digits on their phone, instead of waiting on waitstaff or having a gimmicky touchscreen or table screen.  The orders would be tied to someone’s phone number so paying for bills wouldn’t require the awkward splitting up of the bill, and customers would be able to use a very personal device to them, their own cellphone, to control interaction in the bar/restaurant.  Orders could be processed quickly, verified afterwards, and immediately incorporated into a database which could provide business intelligence in the form of statistics on food orders, frequencies, favorites for each customer, etc. All in a scalable, modular framework such as Node.js + Express.

Previous blog documentation: post #1.

Demo video:

YouTube Preview Image

Screenshots of some functionality:

Initially I figured I’d follow advice and build out the API first.  For that, I’d need an admin dashboard to perform CRUD operations to build up the menu.  I’m pretty tired of having to build out AJAX and menus to add, remove, edit, etc. so I’ve started building a Node.js app with all that stuff built-in, including JSON operations and other common usage events so I don’t have to keep testing it.  Anyway, I got my menu add functions working so I quickly started adding all my favorite Stellas, Dark & Stormies, Mojitos, etc.

Then I spent most of my development time building an interface that could only use the dialpad numbers 1-9, 0, *, and #.  Because I was fairly ill-versed with JavaScript still, I actually ended up refactoring my interface about three or four times, each time becoming more and more modular, using JavaScript objects which contained each “menu” (i.e. a beer menu that would point to each individual beer’s screen, which would pass to another object that would fill out a screen to let you order the beer) pushed into an interface that had no more than 8-9 choices.  Then the screen would have to have text displayed large enough to read, yet still accomodate perhaps 3-4 simultaneous callers at once.

var menuFoodObj = {
	name : "Food/Drinks Menu",
	upMenu : "Main",
	currentMenu : "Food",
	id : "",
	p : ["", "Beer", "Wine", "Liquor", "Non-Alcoholic Drinks", "Water", "Burger", "Specials", "Chips & Salsa"],
	pClick : ["", "Beer", "Wine", "Liquor", "Other", "Water", "Burger", "Specials", "Chips"]
}

By the end of the refactoring though, I had a really nice (but still a little soupy) interface of JavaScript objects being pushed into the DOM by jQuery.  I learned OO JavaScript pretty well although I didn’t understand fully how to create new objects and then properly make methods for objects (I was declaring new functions within objects).  Since I did most of the development and testing just using the web browser and mouseclicks, I was happy when all my refactoring allowed me to easily map a phone’s keypresses to the interface interactions using jQuery’s .triggerHandler event.  My code is still quite soupy though, and I think I’m about ready to learn backbone.js for injecting data from models into a static template — it would have been perfect for this type of project where the layout remains mostly the same but the data changes frequently.  I’m happy, though, that it was easy for me to instantiate new user objects (e.g. user[1] = new User();) for the 4 users that Hermes currently supports.

I actually ran into a weird problem after I’d hooked in caller keypresses, which I thought at first was within the DOM.  Keypresses from my softphone (I used Zoiper to connect via SIP) were happening twice and I thought the click event handler was being called twice in the DOM.  This did not occur on normal phone calls over, say, a cellphone.  Further inspection saw two keypresses coming across in Asterisk:

 <SIP/general_sip-000000ae>AGI Rx << WAIT FOR DIGIT -1
 <SIP/general_sip-000000ae>AGI Tx >> 200 result=50
 <SIP/general_sip-000000ae>AGI Tx >> 200 result=50

Prof. Kairalla found that we were actually picking up feedback on my laptop from the call being made over the software.  Once we muted my laptop, the audio wasn’t being sent to the Asterisk server, which had been detecting the extra audio as what it assumed was an extra keypress.

I added an option to check news headlines from Google News’ API, which has been deprecated so will probably disappear soon?  The other bad thing about this was that you can’t really link to the body of an article since 1) Google News just provides the link and the source’s weak abstract and 2) news sources are so proprietary about people stealing their content.  APIs always leave a bad taste in my mouth because they’re hamstrung from the outset.  Anyway, there’s a definite art to creating headlines, as I learned in my previous job covering the news cycle, and most headlines are expertly packed with relevant info, enough for you to get an idea of things just at a glance.

I also added features for sending drinks/orders to another table, to facilitate social interaction within the bar.  Trivia can be played as well, though it wasn’t built into a central system where scores are kept.  Right now it just tests a user’s response against the correct answer and then generates a random question.  Another feature added was to flirt with other tables and send them messages.

I used Flowroute, which was super easy to set up in my sip.conf and extensions.conf for Asterisk, using Flowroute’s web-based cheatsheets for config settings unique to my account.  Very nice set-up screens there.

emailjs and Twilio

To process orders (when someone wishes to buy a beer, but he hasn’t received it yet) and tabs (for delivered food/drinks), I took advantage of node.js’s awesome modules and found emailjs, which lets you package up a JS object and send it as an email via SMTP to, say, gmail.  So when a customer places an order in Hermes, the order is sent via email to the company for later verification.  Easy, piece of cake.  Can be used with any SMTP server you have an account on and that has permissions.

Then Prof. Kairalla mentioned that it would be great if a customer received a text message thanking them after they close their tab.  So I bought a phone number on Twilio ($1/mo) and used the Twilio SMS API to package up another JS object with the tab details, and then have it again email the company but also text msg the caller with his closed tab details.  I actually had some problems with this and didn’t like the available Node.js modules (because they didn’t include examples for SMS), but luckily I found Dustin McQuay’s godsend blog post in which he posts some easy node.js code as a sendSMS() function, which I used to get my Twilio SMSs working.  I then had further problems but I found out I had pasted in the wrong Twilio auth token, so once I re-checked that, it then worked!  I feel as though the auth token changed because I funded my Twilio account, changing it from a free account to a paid one, and changing the token.  I assume?  Anyway, too much time wasted on that…

I also got a fraud alert from my credit card after trying to fund my Twilio.  Apparently they get a lot of fraudulent credit card funds, which makes sense since I’m pretty sure telephony and stuff related to it are havens for people trying to commit fraud, fake identities, and game systems.  But my credit card company cleared my purchase and I was fine within minutes.  Just thought it was worth mentioning.

Conclusion

I demo’d this in class and had 4 people call in.  They quickly broke it, but it was mostly the display of each person’s menu on the page.  That’s an easy UI fix.  I also found that I would need to make each person’s number more clearly visible so he’d know which interface he’d be working on.  But I felt like people were very quickly navigating through the menus and would learn it fairly quickly once they figured out it was just using a phone dialpad.  One thing that broke the demo was that the bottom bar (telling you how to use ‘*’, ’0′, and ‘#’) got pushed down so people couldn’t see it.  Big problem there!

This app works hand in hand, I think, with my other app, Karaoke Flow.  I would love to create products to make the bar/restaurant/club/concert/dance party/rave/big gathering experience more enjoyable for people looking to have a kickass time and more profitable for the businesses providing it to them.

And I’m blown away with what is possible now with socket.io and Node.js.  All these projects I’ve wanted to do, like a web-based MUD to hook into Galapag.us, real-time chat, real-time flowing data, it’s now possible.  Love it.  And Redial…what a great class.  It’s recaptured the mystique of phones before they went smartphone, the weirdness and coolness of the phonebooth which has become a portal in pop culture (Doctor Who, The Matrix, Danger Mouse), and the fun of messing with somewhat quirky and buggy technology after it’s fallen out of vogue.  And to see how easy it is to set up a Vonage-like system!

 
 

Nature of Code Final: Genetic Crossings

03 May

Professor Daniel Shiffman’s Nature of Code is outstanding.  Just check out the syllabus. And play with the Nature of Code repo Processing sketches hosted on Github. And be sure to get his book when it comes out! We covered some basic algorithms for simulating inside the Processing environment vectors and forces/repellers, genetical algorithms, Wolfram cellular automata, neural networks, autonomous agents, flocking behavior, particle systems.

Background

For me, the pull towards genetic algorithms, heredity, fitness, evolution, Punnett squares, etc. was great, so my project for my first intro to computational media class turned into my Nature of Code final.

My "EUDAIMONIA" Tattoo

My Genetic Crossings project attempts to create a simulated environment where people exist within a world connected to God, the peoples’ religions, their nationalities, and each other.  They produce offspring based on characteristic attraction rules (for my demo I only used “appearance”, “money”, and “religion”, but only to demonstrate what was possible –I would like to create a more fully-formed algorithm for my personal reputation/identity ecosystem Galapag.us to approximate and adjust to the infinite ways that people become attracted to each other and become married or have children or devote themselves to the other), and they can die.  Their well-being or happiness (what in Galapag.us will be eudaimonia) is dependent on their quality of living within their religions and nations.

Map View

A video from an older version:

YouTube Preview Image

See previous documentation on this project:

 

Here are the initial characteristics I created for each person.  There are so many more yet to add! Strength, intelligence, wisdom, charisma, stamina, wit, humor, education, creativity, responsibility, discipline, honesty, religiosity, entrepreneurialism, appearance, money, gracefulness, stress, health, luck, talent_math, talent_art, talent_sports.

Initial nationalities/regions: USA, China, EU, Africa, South America.  Characteristics of security, innovation, job opportunity, immigration policy, life expectancy, education, sanitation, standard of living, pollution, biodiversity, crime, political freedom, and nutrition.  By no means comprehensive.

Initial religions/spiritualities: Christianity, Judaism, Islam, Taoism, Confucianism, Hinduism, Buddhism.  With characteristics of commercialism, morality, hierarchy, portability.  Obviously these need some tightening up/additions/discarding.

Final Project

So in my midterm I managed to add Verlet 2D physics to the sketch so that people, nations, and religions have connections to each other which make them bounce around like they’re on springs, relative to their attractions and strength of ties to each other.

In my final proposal, I sought to add the following:

  1. Wolfram cellular automata
  2. Connect to external database
  3. A selection algorithm to choose certain parts from parents based on mutation rate and fitness to pass along to new offspring
  4. Interaction sliders to change variables
  5. Macro events that affect well-being of all objects in the world, such as earthquakes or war
  6. Micro events that affect individual well-being, like rites of passage
  7. Discrete clusters of people, mostly based on familial strength of ties, instead of one big clump of people in the middle like in my midterm

 

I managed to get most of this done.

I enjoyed adding Wolfram CA.  I wrote a node.js app for express which would act as a JSON middleman between my main genetic crossings sketch and a wolfram sketch.  Basically, when viewing the chromosomal stainings (genotypes), you can click on the CA button to the left of a person’s staining, and this will pass a JSON object (using Prof. John Schimmel’s Processing-Nodejs code) to the node server, which is detected within 5 seconds by a polling timer within the wolfram sketch.  The wolfram sketch then uses the JSON object as its data to apply rules to to construct a pattern unique to the selected person’s genetic characteristic code.

1) I added a third parameter to the rules which would display as either black or aqua, depending on the CA rules.  Prof. Shiffman’s code used base-2 groups of 3, which had 2^3, or 8 total possible combinations (using only the digits 0 and 1), but I used base-3 (0 = white, 1 = black, 2 = aqua), so it became 3^3, or 27 possible combinations.  For this ruleset, I duplicated Wolfram rule 90 three times, then added a few extra codes.  The triangular look seemed the most visually interesting for what I was doing.  Anyway, what was cool about Prof. Shiffman’s code was that it keeps streaming the pattern from bottom to top.  So when a new person is clicked on, that person’s signature is integrated into the flow seamlessly once the sketch loads the JSON off the node server.  I don’t know that any of this actually is useful except that it looks cool and uses principles from class and maybe, just maybe, shows someone’s digital characteristic “signature”.

Streaming Wolfram CA on top of Processing sketch code. Console of Processing shows a passed JSON object.

YouTube Preview Image

2) I’m happy I was able to set up a MongoDB to be accessed via node as well as by my Processing sketches.  When I build out Galapag.us, I’ll be able to pump out JSON objects of actual users into these sketches for data visualization.  I’d been wanting to do this since my first semester and now it’s done.  Most credit goes to John Schimmel though for writing the hook into node though!

node.js instance output including passed JSON object

3) I realized that I already had some mutation within my matingDance.sex() function, once the two parents’ characteristics were passed to a matingDance.punnettSquare() function.  Before, the function would just average the two parents’ characteristic values together and then add or subtract a random amount from them for mutation.  What I changed was making the function choose randomly from either parent’s base characteristic.  So if one parent had 10, and the other had 1, the result would not be 5 (rough average) but either 1 or 10.  Then I would offset a random amount (hardcoded as 4) if mutation kicked in (if a random number between 0 and 50 was less than 2, for approximately a 1 in 25 chance of mutation per characteristic).  What this ended up doing was increase the diversity within the genepool and more accurately reflect reproduction.  I still need to tweak these numbers to get more consistent levels of variety but the algorithm is mostly there.

Here’s a view of the chromosomal stainings before I changed the algorithm — here it averaged the parents’ traits, which, in the case of this sketch’s iteration’s octomom, created many extremely similar offspring:

Before

And here’s the view after picking from either parent and allowing for a slim chance of mutation:

After

I feel as though the end result has a more diversified population with more variability between generations and individuals.  I need to tweak this so that if the value from a parent is at 1 or 10, it may mutate in only one direction, but here’s the matingDance.punnettSquare() function:

int punnettSquare(int comp1, int comp2) {
    int mutation = (int)random(0, 50);
    int dominance = floor(random(0, 1.99));
    int crossover = 0;
    if (dominance == 0) {
      crossover = comp1;
    }
    else {
      crossover = comp2;
    }
    if (mutation < 2) {
      crossover += (int)random(-4, 4);
    }
    // don't want it to be out of bounds
    // TODO: fix so it can mutate only one way if parent is 1 or 10
    if (crossover < 1) { crossover = 1; } else if (crossover > 10) { crossover = 10; }
    return crossover;
  }

4) I didn’t add sliders to change variables mid-sketch — at this point I can use variables pre-set in the main class but I’d like to make the interface more user-friendly and interactive later.

5 and 6) I didn’t do macro and micro events because I figured they’d just require making a button that, when pressed, would cause particles’ values to change.  What would be interesting would be to have random events happen based on their likelihood to occur and then some events would have permanent effects (damage to peoples’ personalities) or temporary effects (nationalities’ well-being that would later recover).  This kind of introduces the possibility for individual peoples’ health and whether they have injuries/disabilities/diseases/gifts/talents.

I did add a Ritual class though, which only includes right now a funeral function.  When funerals are recognized by a culture (by pressing ‘f’), the dead are removed from view on the map and their attraction springs are removed as well.  What this is supposed to represent is that funerals are a way for the living to remember the dead and then put them to rest so that the living can move on and create new ties with the living.  I do like the idea that we retain our ties to the past, which can sometimes become weaker in death and sometimes become even stronger.  I didn’t model that yet.

public class Rituals {

  Rituals() {
  }

  void funeral(boolean funeralsRecognized) {
    println(funeralsRecognized);
    for (int i=0; i<numPeople; i++) {
      if (person[i].parent1 != -1 && person[i].parent2 != -1 && person[i].alive == false) {
        if (funeralsRecognized == true) {
          physics.removeSpring(parentSpringArray.get(person[i].parent1Spring));
          physics.removeSpring(parentSpringArray.get(person[i].parent2Spring));
          physics.removeSpring(parentMinDistanceSpringArray.get(person[i].parent1MinDistanceSpring));
          physics.removeSpring(parentMinDistanceSpringArray.get(person[i].parent2MinDistanceSpring));
          person[i].lock();
          person[i].display(0);
        }
        else { // TODO: re-reference spring after it's recreated?
          parentSpringArray.add(new VerletConstrainedSpring2D(person[i], person[person[i].parent1], person[i].parent1RL, random(parentGravity1, parentGravity2)));
          person[i].parent1Spring = parentSpringArray.size()-1;
          physics.addSpring(parentSpringArray.get(parentSpringArray.size()-1));
          parentSpringArray.add(new VerletConstrainedSpring2D(person[i], person[person[i].parent2], person[i].parent2RL, random(parentGravity1, parentGravity2)));
          person[i].parent2Spring = parentSpringArray.size()-1;
          physics.addSpring(parentSpringArray.get(parentSpringArray.size()-1));
          parentMinDistanceSpringArray.add(new VerletMinDistanceSpring2D(person[i], person[person[i].parent1], random(parentMinDistanceRL1, parentMinDistanceRL2), random(parentGravity1, parentGravity2)));
          physics.addSpring(parentMinDistanceSpringArray.get(parentMinDistanceSpringArray.size()-1));
          parentMinDistanceSpringArray.add(new VerletMinDistanceSpring2D(person[i], person[person[i].parent2], random(parentMinDistanceRL1, parentMinDistanceRL2), random(parentGravity1, parentGravity2)));
          physics.addSpring(parentMinDistanceSpringArray.get(parentMinDistanceSpringArray.size()-1));
          person[i].unlock();
          person[i].display(1);
        }
      }
    }
  }
}

7) Discrete clusters.  I ended up adding relationships between people and their parents from just constrained springs to a combination of constrained springs and minimum distance springs.  What this would change is that a person’s distance from his parents is both constrained to no more than a certain length but also more than a minimum length, so that they can both be more visible instead of overlapping visually, and also be more clustered together.  I found that this makes certain groups on the map appear more clustered instead of forming a big ball in the middle.  I still need to do more work on this though because as there are more people in the sketch, the big clusterfuck returns (because there are too many connections between everything and I can’t zoom in closer to see the gaps and relative spacing between different networks).

I converted a lot of my arrays of spring connections over to one large ArrayList, which I think was easier to deal with in the end in terms of manipulating them after they were initiated into the environment.  I did find, however, that I had to pass a reference to the spring’s number (since it was just an ArrayList entry) to the person’s class instance so it could refer to it later.  A problem with this though, as I realize just now, is that if I remove springs (as I do in the funeral ritual), I’ll lose the correct references.  So I have to make sure that when the springs are added again, when funerals are disabled, that a pass a new reference to the ArrayList.

I also found that there tends to be super-breeders every time I run the sketch, with certain people tending to produce tons of offspring while others produce none.  I’m talking like 1 or 2 people will produce 10 kids, which tends to make the sketch appear too tightly clustered because everyone is closely linked.  Perhaps this is a feature, rather than a bug, of reproduction?

Code

You can download the code from Github.  You’ll probably want to start up a node instance and then start the genetic crossings sketch, then finally the wolfram sketch.  Instructions are in the README.md.

Github: https://github.com/Xeus/Genetic-Crossing

Conclusion

And this leads me to some closing notes. I shied away from adding fitness yet again to my reproduction algorithms because I felt like “fitness” in the short-term was too much like large-scale evolution theory and autonomous agent simulation.  In my sketch there wasn’t really an ideal fitness state, with no limitations or rules imposed on the larger scale.  What I wanted was to break into modeling some culture into the simulation, so that choices were made between sexual partners based on cultural norms and not as much on randomized reproduction. Obviously modeling culture would work best if it were overlaid on top of basic biological reproductive theory such as choosing the fittest partner and whatnot, but I felt that was too much for the scope of this simulation, which I wanted mainly to focus on social networks.

JavaScript has come a long way.  It’s now the same on the backend and the frontend.  Processing can be exported to JavaScript in some capacity, and dataviz libraries such as D3 are taking off.  Soon we will be able to introduce more fluid, data, physics, and particle system simulations within a browser.  It’s too early for my sketch yet (ToxicLibs takes some finagling) but this is a glimpse of the web to come.

As I begin to do more serious work on the internal mechanics of Galapag.us, it’s stuff like this Processing project that makes me appreciate how careful I’ll have to be with positioning different factors against each other so that people can create their own formulae/evolutions to weight different priorities how they deem fit.

Looks like this book out of the Harvard Berkman Center, “Interop: The Promise and Perils of Highly Interconnected Systems”, by John Palfrey and Urs Gasser, is a must-read.

What I do feel is that current online social networks have not really tried to map out the complex interweaving, competing, variable connections and attractions we have between ourselves and others, between the different identities we all have, between the things we care about more or less at different times in our lives, etc.  To facilitate something like this, I can’t help but feel there needs to be a massive API that allows people to access all this data (if privacy settings allow it) so that we can take advantage of the multi-dimensional nature of our species.

You can think of someone’s identity as a meshed web that is being pulled apart by the external world and people and ideas and being pulled together by muscle and ligament and cartilage and sense of self and personality and such.  You can think of a community as a bunch of these springy people pulling on and apart from each other constantly, but at a stronger tension than from other communities.  Communities form religions and nations and cultures, again with that same network of relationships and competing identities. I hope that’s the dynamic I was able to capture in doing this project.

Credit

Special thanks to:

  • Prof. Dan Shiffman for all his documentation and code from Nature of Code, particularly his chapters on forces, genetic algorithms, ToxicLibs, and cellular automata
  • Prof. John Schimmel for his Processing-Nodejs code
 

Dynamic Web Dev Final: Karaoke Flow

03 May

My NYU-ITP Dynamic Web Dev class ended up being fantastic.  We moved to Node.js Express, incorporated AJAX, MongoDB, Heroku, and Amazon S3, built a JSONic API, and toyed with socket.io and even some Processing + HTTP POST.  You can read the class notes and fork/view the github class code from Professor John Schimmel’s repositories online.

Karaoke Flow

My final project ended up being a party game.  People hit the site, probably best with a keyboard, and start creating “rhymes” based on a prompt of two topics, such as “yo momma” and “swag”, or “basketball” and “Maybach music”.

You start off with three choices: 1) start a new “flow” (an individual song) which 2) you can join into with the second choice (using autocomplete JavaScript to parse a list of open flows from the database), and 3) skip all the rhyme creation part and go right to performing a randomized flow.

If you work on an open flow, all the participants have five minutes (using a JavaScript countdown script) to come up with as many rhymes as you can.  When five minutes is up, everyone can submit one more rhyme before they’re sent to the performance page.

On the performance page, the next person up will (eventually) be able to grab a mic, start the random beat (so far I have random beats from Wiz Khalifa’s “Star of the Show”, Three Six Mafia’s “Hard Out Here for a Pimp”, and Drake’s “I’m on One”), and move up and down through the lyrics using the ‘j’ and ‘k’ keys.

 

 

 

I’m hoping eventually it can be recorded and people can vote on the best rendition of the performance.  People are judged (though this isn’t captured through the site yet) on how well they deliver their spontaneous flow.

I wanted to do a project related to music and parties, hence the project; hopefully at some point in my life, I’ll get to work on projects that make parties more kickass through technological integration with human party impulses.

Karaoke Flow was also my entrée into Node.js and Express, which I now love and will rewrite Galapag.us into it over the summer in preparation for my thesis next spring.

Online Presence

A demo of the site is up at Heroku: http://karaokeflow.herokuapp.com/

I have instructions on how to clone the code and install it so you can run a node.js instance at github: https://github.com/Xeus/Karaoke-Flow

Previous documentation from my blog: post #1, post #2.

Things Learned for the Future

I think what I got most out of this was an appreciation for JavaScript objects.  To be able to package up variables and containers and clone objects or pass them along into JSON, it was like what I was missing in web sites.  I’m still on the road down to something more like Backbone.js, which will allow for even more use of objects and static templating filled in with data.  Definitely enjoying being able to JSONify data into something that I can use throughout the site or offer to others.  I’m sold.

Our professor showed us passport, which is a brilliant module for handling users and security.  I was missing something similar when I was using Ruby + Sinatra.

Conclusion

If anyone’s interested in taking this further with me, let me know.  I definitely think some combination of karaoke, rhyme-writing, parties, and randomness would be a huge hit.

 

Final Proposal for Redial: Hermes

09 Apr

My Redial class is awesome.  We’ve set up Rackspace servers with Asterisk telephony software and now we’re executing shell/ruby/php scripts through phonecalls which are now interacting with node.js servers to execute web site interfaces, Arduino RC car controls, etc.

I really want to focus on using node.js and socket.io with Asterisk/phonecalls for my final project.  So here’s what I propose:

Hermes

Hermes is an ordering interface for bars and restaurants.  When you sit down and order food, or when you’re standing at the bar trying to get a drink, you dial in with your phone to the establishment’s screen/s to place an order.

Say you sit down at a table and the table either has a built-in screen (like those old Pizza Hut arcade games where you could play Pac-Man using a joystick and buttons underneath the table surface), or it has a monitor or projection on the wall.  It will have a phone number for you to dial.  When you call in, it begins to interact in real-time with you both by voice and with on-screen instructions.  By pressing phone keys, you can place simple orders from simplified menus displayed on-screen.

Multiple people can dial in to the same line at the same table.  The screen will split depending on the number of people, allowing people to tie their orders to their phone number and to order independently of each other.

At the bar, when it’s packed, a projection above the bartender area will have a number to place calls.  The bartender can then cue drinks in the order they’re received in a fair way.  People can auto-order favorites or have drinks set to order every x minutes.  Complex group orders are handled digitally.

Multiple screens can be installed around the establishment so people don’t have to wander too far to place an order.

The screens can also be used for entertainment, as people could play phone trivia or mini-games via their phones, browse the news, change TV/music stations (handled via weak FM signal?), etc.

YouTube Preview Image

Why Hermes?

Hermes was recognized as the God of commerce and social interaction, and patron god to diplomats, messengers, and heralds:

Due to his constant mobility, he was considered the god of commerce and social intercourse, the wealth brought in business, especially sudden or unexpected enrichment, travel, roads and crossroads, borders and boundary conditions or transient, the changes from the threshold, agreements and contracts, friendship, hospitality, sexual intercourse, games, data, the draw, good luck, the sacrifices and the sacrificial animals, flocks and shepherds and the fertility of land and cattle. [Wikipedia]

Problems of a Hermes-Less World

  • Ordering food and drink is still a primitive process.  McDonalds has figured out how to move a lot of customers through quickly and efficiently with minimal job training.  But most restaurants and bars suffer from bad image and service because overworked waiters, waitresses, and bartenders can’t keep up with everyone’s needs 100% of the time, particularly when customers are fickle, intentionally hard to please at times, etc.  Streamlining the ordering process so that people can order as much food and drink as they would like, without inconveniencing themselves or waiting for some attention from an employee would increase business and increase consumer satisfaction.  There’s a problem when people discuss strategies to elbow their way into a bar just to maybe get a drink in 15 minutes, 15 minutes spent away from the party they came to attend.

Problems of a Hermes World

Hermes is not without its limitations.

  • Screen readability is limited by the size of the monitor, the customer’s ability to see clearly, the design of the interface, and how much text can be displayed at once.
  • There is also a problem linking orders to phones.  While something like Google Wallet, where one could pay via phone, would be preferable, at this point the phone number would only be an identity link to the customer and his order, and for reaching the customer afterwards for non-payment.  There are most likely large security/spoofing vulnerabilities in this approach unless a credit card number is somehow associated with the phone number.
  • Why would one find that dialing on a phone is a superior interface to asking a person, or using a touchscreen, or even using a custom web-app or mobile site to order?

Benefits

  • Tests with digital ordering systems seem to indicate people will order more food and drink if they can do it quickly, digitally, and without pause.  The systems seem to increase efficiency and overcome social shyness.
  • People strongly and affectionately associate with any actions involving their own phones, so using their phones as an ordering device empowers them.  It also is a potential bridge to have “preferences” that people can set and save with their “account”, linked through their phone number as identity.
  • Digital ordering produces a digital record, which is better for book-keeping and for validation of records in the event of disagreement between employees, customers, and management later.
  • Projections could be expanded upon — when people aren’t ordering food, they could be consuming news, shows, art installations, using Kinect-ish hands-free interfaces, messaging other tables, etc.  There is an exciting potential for linking different tables and screens with each other, via competition, flirting, or just networking or social lubrication.
  • Client interface consists of normal 1-0/*/# phone pad, can work with installed phones or smartphones or even simple cellphones, while all the customized, complex work can be handled server-side

Technology

  • Flowroute number linked to an Asterisk server installed on Rackspace
  • Asterisk dialplan forwarding to a ruby-agi script that sends data to a node.js instance
  • Node.js instance that takes incoming phone commands and passes instructions via socket.io (real-time, no polling) to the client that is installed on the projection/screen
  • jQuery/UI/AJAX/node.js client interface that handles order entry and routing, and can run multiple instances via the node.js cluster module, and can also forward to other instances for video, news, chat, etc. while keeping order entry instance CPU/memory load available just for order entry/processing

Long-Term

  • Tie-in to payment system/gateway?
  • Data saved into MongoDB
  • Employee and management interfaces to see stats on sales, database analysis, modify orders on the fly

Research Links

 
 

Nature of Code: Final Proposal

07 Apr

For my Nature of Code final, I plan to continue the Genetic Crossings Processing sketch project and incorporate some of the concepts from the second half of the course.

Previous documentation for this project: Nature of Code & Intro to Computational Media

Specifically, I want to do the following:

  • Use each person’s characteristics (rated from 1-10, and numbering a total of about 20 characteristics per person) as a ruleset for the Wolfram Cellular Automata structures.  I will have to adapt the code by remapping the 1-10 scale either to a binary state or by making more complex rules (perhaps using color instead of white/black or on/off).  I don’t know that there’s any benefit to the overall project from implementing Wolfram CA here, but perhaps it might give each person within the sketch a unique signature or fractal pattern.

  • Of the three characteristics of genetic algorithms — heredity, variation, and selection — I have implemented my own versions for heredity and variation, but have not really introduced much selection.  The only selection that seems to take place is that, because I have more heavily weighted religion, appearance, and money in the sex() algorithm, those with high stats in those areas will probably reproduce easier.  But this is not equivalent to having an actual fitness algorithm that determines “ideal” environmental success.  As Professor Shiffman writes in his notes, “There must be a mechanism by which some members of a population have the opportunity to be parents and pass down their genetic information and some do not. This is typically referred to as “survival of the fittest.””  I might also try to implement a mutate() function as used in example code, since all I do at the moment is take the average of the parents’ characteristics and then randomize an offset to come up with “mutation”.  Very hacky.
  • System variables and sliders: I liked the Processing sketch “flocking_sliders.pde” from the Shiffman’s chapter 6, “Autonomous Agents” because it let you play with variables on the fly to see how it would affect the simulation: how would you get boids to fly together, but not too close together, and could you enforce more solo or flocking behavior easily?  So I think I would like to use the God person or perhaps a fake country or religion to simulate how wild changes in traits or characteristics of a larger group-level entity could markedly affect individual persons linked to them.  Could I even have individuals leave group-level entities in search of more favorable ones?  What I picture is the person objects bouncing around the environment as the strengths of their relationships change between others, their parents, religions, and countries.  This also introduces the idea of migration patterns.
  • Similarly, I would like to be able to introduce world-level events such as earthquakes, global warming, war, Renaissance, etc. which add or subtract from multiple entities all at once, or even over iterations/time.
  • On an individual level, I wonder if I could implement rites of passage, liminal events in persons’ lives such as turning 21, getting married, having children, etc. that affect their relationships to their communities and increase/decrease their stats.  Would this necessitate perception of stats as opposed to actual stats?  In my Galapag.us project, I’m trying to study the multi-dimensional nature of our presence in the world — what we think of ourselves, what we actually are (objective truth/science?), and what others think about us. Reputation within a community is not often of one mind — one can hold various degrees of influence and respect among different components of the same community.  How does one code this?
  • Visually, I am hoping to make the networks a little more discrete.  For my midterm, the sketch ended up looking mostly like a hub (God) and spokes as more persons were introduced.  What it should be, though, are clusters of parents and offspring, dispersed between different group-level clusters.

 

Other influences:

  •  Joshua Epstein’s “Growing Artificial Societies: Social Science from the Bottom Up”, loaned to me by my classmate James Borda.
  • Prof. Shiffman posted this video of a talk by Bret Victor, which argues for real-time feedback for coding, so we can visualize the results of our code and experiment with unintended changes or extremes testing or rapid prototyping for artistic-based projects such as building animations.  Blew my mind.  Seriously, I don’t watch many long lecture vids anymore, but this was awesome:
 

Mobile Web Final: StreetEyes

09 Mar

Phil Groman and I presented our mobile web app, StreetEyes, for our NYU-ITP mobile web class.  StreetEyes is intended to be a way for a web viewer to look at a map of broadcasters and ask them to collect information on a desired event, protest, or location.  The app allows a web user to view a map of broadcasters, select one, and make a view request to him to start collecting data from the ground and reporting it to the news “stream” that the viewer made from the web.  The viewer and broadcaster (or multiple viewers) could chat in real-time to assign tasks for info collection or to take more photos or to get more descriptive updates.

We feel a good application of this would be for documenting a quick-moving protest, or for getting eyes on a line at a supermarket or at the DMV.  Traditionally, news is collected by sifting through peoples’ random Twitter updates, or more crafted news stories that come later.  If some investigative curator or someone who knows which details are pertinent in an emergency (say, a first-responder), then there is not much way to contact people on the ground to gather data.  We rely on people on the ground to be knowledgable enough to get the right data, but this is the wrong way to go about things.

Why not have curators direct people to breaking news or emergencies?

 

TODO:

  • Make the camera work, submit photo to a stream.
  • Fix display bugs in Google Map dynamic view.
  • Much better styling for the stream page.
  • Video-streaming?
  • User authentication and multi-user potential.

 

Final note.  We feel as though video-streaming apps are stuck on just getting the video up.  Ustream has a nice Android app that very quickly allows you to view a full-screen stream, or start your own.  But it does not function well in disseminating information, particularly on a directed topic.  We would like to be able to embed the video into a stream so that the end result is like a curated Reuters news feed, which differentiates between admins, editors, and random commenters.  Those last commenters are very important though, as they may actually be on-site and have a lot of info to share.  It is a curator’s role to promote that info and demote the chaff.

Another thing.  We found prezi very useful for our presentation, as well as the app Droid@Screen, which is a Java file that goes in your Android SDK folder containing adb.  That app allows you to display what’s going on on your phone’s display onto the monitor, which can then be projected onto a wall or large screen.

 
 

Redial Midterm: Gotta Take This

07 Mar

For my Redial midterm, I did something functionally pretty straight-forward.  Ever been in a situation where you’re talking to someone and you want to get out of it, like when that person is one of those folks who just keeps going and going and you haven’t said a word in ten minutes because they wouldn’t you talk?  Or if the conversation is so forced and awkward that you can’t stand it?

I’ve got an app for you.

It’s called Gotta Take This, although I think I pitched it originally as Panic Button.  I think I chose the former because it sounded a little less alarmist but still conveying the purpose.

What the app does is, upon opening it on your phone, it shows you a life preserver.  Tap on the preserver and casually exit to something else on your phone, like checking email.

Five minutes later (I set this to 1 minute for the demo), you’ll get an “Urgent Call” from a pre-set number.  When you answer it, an Asterisk dialplan takes over and plays, for my demo anyway, a long recorded message that gives you plenty of cover to have a quick conversation.

This gives you multiple opportunities to tell your present company, “Hey, uhh, I gotta take this…  It’s urgent/important/just a quick call/getting information.”

Now, once you’ve moved away with the call, you’re free to slink out of the place, or distractedly fall into a conversation with other people.

The app is made for Android with PhoneGap.  I got the icon from iconmaker.com.  The PhoneGap app’s button triggers jQuery Mobile to go to a ruby script I set up on ITP’s server, which generates a callfile with pre-set call information to be executed at a certain time in the future.

My ruby script, running via Sinatra:

require "rubygems"
require "sinatra"

# Main route  - this is the form where we take the input
get '/gottatakethis' do
  minutes = 1
  t = Time.now + (60 * minutes)
  # %H-%M-%S-%m-%d-%Y == 09-09-03-07-24-2006
  timeCallBack = t.strftime("%H-%M-%S-%m-%d-%Y")
  numbertocall = 15555555
  senderNum = 15555555

  # set the temp dir & filename & destination path to write from/save to
  temp_dir = "/tmp/"
  callfile = "call_" + timeCallBack + ".call"
  startcallfile = temp_dir + callfile
  end_dir = "/var/spool/asterisk/outgoing/"
  endcallfile = end_dir + callfile

  #write file to disk
  file = File.open(startcallfile,"w")
  file.puts("Channel: SIP/itp_jnctn/#{numbertocall}\n")
  file.puts("MaxRetries: 2\n")
  file.puts("RetryTime: 60\n")
  file.puts("WaitTime: 30\n")
  file.puts("Context: vt520_gtt\n")
  file.puts("Extension: 1\n")
  file.puts("CallerID: Urgent Call ")
  file.close

  #change file permission
  File.chmod(0777, startcallfile)
  FileUtils.chown(ENV['USER'],'asterisk',startcallfile)

  #move file to /var/spool/outgoing
  if (timeCallBack != "")
	timesplit = timeCallBack.split('-')
	ctime = Time.local(timesplit[5],timesplit[3],timesplit[4],timesplit[0],timesplit[1],timesplit[2])
	File.utime(ctime,ctime,startcallfile) #change file time to future date
  end
  FileUtils.mv(startcallfile,endcallfile)

  body = "Sent."
  body

And the relevant dialplan:

[vt520_gtt]
exten => s,1,Answer()
   same => n,Wait(3)
   same => n,Playback(/home/vt520/asterisk_sounds/soundfile)
   same => n,Hangup()
 
No Comments

Posted in ITP, Redial

 

Nature of Code Midterm: Genetic Crossing with Verlet Physics

07 Mar

For my Nature of Code midterm, I added a physics world to my genetic crossing project from last semester.

A short video, sped up quite a bit because my MacBook Air + QuickTime screencap choked on it:

YouTube Preview Image

Here’s some past posts on the project: http://blog.benturner.com/category/itp/icm/

Professor Shiffman‘s notes from his Nature of Code book were invaluable in understanding vector- and particle- based systems, so by the time we got to Box2D and ToxicLibs, understanding the underlying framework needed to make a world that reacts to physical forces was far easier.

My genetic crossing project, which allowed for people to reproduce and carry characteristics from their parents and their religious and national environments, was a perfect project for last semester but also a perfect transition project for a physics system, because I was trying to study the natural flow and connection between many different objects with differing characteristics.

I chose to use ToxicLibs’ VerletPhysics2D library because all I had to do was have my Person, Nation, and Religion objects to inherit the VerletParticle2D class, and then be added as particles with connecting springs in order to have them react to each other.

class Person extends VerletParticle2D {
  Hashtable trait = new Hashtable();
  String namePerson, gender;
  int parent1, parent2, uniqueID, pWeight, pHeight, age, mbti, lastBaby,
  nationality, religion, children,strength,intelligence,wisdom,charisma,stamina,wit,
  humor,education,creativity,responsibility,discipline,honesty,religiosity,entrepreneurialism,
  appearance,money,gracefulness,stress,health,luck,talentMath,talentArt,talentSports, happiness, employed;
  int[] colorBaseArray = new int[3]; // need base colors for each person
  float[][] traitPosArray = new float[numCharacteristics][2]; // save x,y for all characteristics
  float[][] traitPosArray_orig = new float[numCharacteristics][2]; // original copy of coords
  boolean alive;

  // constructor
  Person(int _uniqueID, int _mbti, int _stress, int _health, int _gracefulness, int _luck, int _talentMath, int _talentArt, int _talentSports, int _strength,
  int _intelligence, int _wisdom, int _charisma, int _stamina, int _wit, int _humor, int _pWeight, int _pHeight,
  int _education, int _age, int _creativity, int _responsibility, int _discipline, int _honesty, int _religiosity,
  int _entrepreneurialism, int _appearance, int _money, String _namePerson, String _gender, int _parent1,
  int _parent2, int _nationality, int lastBaby, int _religion, int _children, int _employed, float x, float y) {
    super(x, y);

Two things I found out pretty quickly.  First, I made this project with arrays and a hashtable but had I known better, I would have used ArrayList and no hashtables (just variables with integer values.  The other?  I had to rewrite my class xPos, yPos variables as x,y and include them as direct variables instead of references to new variables, in order for the objects to be recognized in the physics world.  Basically, my objects would drop like a stone in a pond because they were not connected to the system but still were “particles” in a world with gravity.

I still have a problem with bizarre array counting for adding the large amount of springs that connect every person, nation, and religion to each other, and more added as each new person is born into the world.  I’m probably wasting tons of memory and overwriting certain springs because I didn’t make entirely unique arrays.

But the simulation is now operating within a 2D world and now I can go through the process of tweaking the relationships between the objects to more clearly match up with the characteristics/heredity/uniqueness that I coded into the simulation last semester.  God is located in the center now, instead of in the bottom right, so he is a fixture within the world, with the nations and religions along the periphery of the map (no meaning behind that!) to space out the particles which are tethered by their springs.

Relevant code:

  physics.addParticle(god);
  god.lock();

  // #PeopleChange init all person objects & nations
  for (int i=0;i<numPeople;i++) {
    physics.addParticle(person[i]);
  }

  for (int k=0;k<numPeople;k++) {
    springArray[k] = new VerletConstrainedSpring2D(god, person[k], godRL, godGravity);
    physics.addSpring(springArray[k]);
  }

  int z=0;
  for (int k=0;k<numPeople-1;k++) {
    if (z < numPeople) {
      for (int l=0;l<numPeople;l++) {
        newPersonSpringArray[z] = new VerletConstrainedSpring2D(person[l], person[k], int(random(250, 650)), random(0.001, 0.003));
        physics.addSpring(newPersonSpringArray[z]);
        z++;
      }
    }
  }

Code is on Github.  I recommend running this in Processing since I have it set to something like 1200×700 pixels.

 

Mobile Web: 2 Classes Left

01 Mar

With a couple classes to go, here is the status of StreetEyes, the app made by Phil and me:

Mainly what we have left to do is add some markers of some dummy users so that we can do a view request from them, and then have that data passed on via database so that they can see it, and then accept it.  We need to make sure the HTML forms passing along the broadcaster’s submission as well as the view request’s submission are linked up.

Perhaps the most work needs to be done on making the beacon page viewable so that you can easily scroll down a list of updates sent by various people, with new updates added dynamically.

 
1 Comment

Posted in ITP, Mobile Web