Nature of Code: Forces & Physics

Our homework this week was pretty wild, after going over some pretty epic notes on forces, physics, Newton’s laws, etc.  Here were the suggested exercises for homework:

  • Rework your motion sketch from week 1 using PVector. Try incorporating the concept of forces into the environment by affecting only the acceleration. Create a formula for calculating a dynamic acceleration, one that changes over time based on any number of factors. What happens if you make more than one object via an array.
  • Using forces, simulate a helium-filled balloon floating upward (and bouncing off the top of a window). Can you add a wind force which changes over time, perhaps according to Perlin noise?
  • Create an example where instead of objects bouncing off the edge of the wall, an invisible force pushes back on the objects to keep them in the window. Can you weight the force according to how far the object is from an edge, i.e. the closer it is, the stronger the force?
  • Create pockets of air resistance / friction in a Processing sketch. Try using circles instead of rectangles, i.e. pockets of mud (or ice). What if you vary the strength (drag / friction coefficient) of each circle? What if you make some of them the opposite of drag—i.e., when you enter a given pocket you actually speed up instead of slow down?
  • Can you create an example where all of the Mover objects are attracted to the mouse, but repel each other? Think about how you need to balance the relative strength of the forces and how to most effectively use distance in your force calculations.
  • Research a force not covered in class and implement it as a vector.
  • Use the concept of forces to visualize some input (could be data, literal example would be get windspeed online and translate to a wind force in Processing, but feel free to think more abstractly)
  • Build a sketch that has both “Movers” and “Attractors”. What if you make the Attractors invisible? Can you create a pattern / design from the trails of objects moving around attractors? See the Metropop Denim project by Clayton Cubitt and Tom Carden for an example.


The above link is pretty cool.  It shows the possibilities for working with forces, attractors, and particles, combined with the more organic, natural shapes and motions that we’re learning in Nature of Code.  I think I want to start incorporating something like this into my 2D designs.

Prof. Shiffman’s notes from his upcoming Nature of Code book are outstanding.  We’re currently learning how to affect objects using added forces which affect location, acceleration, and velocity with vectors.  So, just this type of code starts to create a more realistic physical environment: [code clipped for brevity]

PVector wind = new PVector(0.001,0);
PVector gravity = new PVector(0,0.1);

void applyForce(PVector force) {
  PVector f = PVector.div(force,mass);

I had already converted my first homework assignment into an array of objects and added some extra forces and reactions for the penguins.  But I also wanted to try some other forces, without delving into some of the homework suggestions that seemed a little too complex right now for me (still need to play with orbits, motion in liquid, etc.).  The sketch I made is just a simple balloon with a random walk floating up, bouncing off the top of the screen.

Sketch is running at, and code is at Github and below the jump:

Read More »

DWD: Karaoke Flow

For my week #2 homework in Dynamic Web Dev, my assignment was to play a bit with JavaScript and CSS in forms, to basically build a front-end prototype for a project for class.

I decided to use this as an opportunity to do a simpler project (at least initially), called Karaoke Flow.  It could also be called Rap Libs (like Mad Libs, RIP the creator of Mad Libs :( ), as suggested by one of my classmates.

Basically what Karaoke Flow is is a chance for me to use puns and wordplay (in the tradition of my Turner family and my dad’s poetry expertise) to create dope rhymes.  I also wanted to create a cool music project and learn how to DJ and make digital music possibly while at ITP.

Karaoke Flow is a party game.  Everyone gets a certain amount of time to create 2-4 lines of rap lyrics based on randomized prompts for two topics.  So each person will write some lyrics on something like “basketball” and “women”.  After, say, 5 minutes, the rhyme creation is over.  Then whoever’s got the mic next will get up and perform the randomly selected lyrics.

The emcee gets a mic, a random beat, and the random lyrics.  That’s it.  It’s his or her job to create the flow, matching lyrics to the beat, and possibly freestyling if confident enough.  It can be recorded, it can be based on just one set of two topics, or it could just be all sorts of randoms.

I was inspired by this on my long runs where I’d listen to Drake, Lil’ Wayne, and Kanye.  Check out some of their winners:

Drake, “Fancy”:

Jason had this girl Tammy with a purple Bentley
How she got it I ain’t never get to ask
I just knew that she was fine like a ticket on the dash

Kanye West, “Hell of a Life”:

One day I’m gon’ marry a porn star
We’ll have a big ass crib and a long yard
We’ll have a mansion and some fly maids
Nothin’ to hide, we both screwed the bridesmaid
She wanna role play, ‘til I roll over
I’mma need a whole day, at least rolled doja
What party is we goin’ to on Oscar day
‘Specially if she can’t get that dress from Oscar de
La Renta, they wouldn’t rent her, they couldn’t take the shame
Snatched the dress off her back and told her, “Get away.”
How could you say they live they life wrong?
When you never fuck with the lights on

Kelly Rowland, Lil’ Wayne, “Motivation”:

Uh, girl I turn that thing into a rainforest
Rain on my head, call that brainstorming

By the way, rapgenius is a great site.  It has highlighted lyrics with popups that explain all the references within each line of the song.  Helps you appreciate just how much cleverness goes into rap lyrics.

Right now the JS functionality is basically limited to a click() event for submitting, and a click() event for a popup for instructions and one for adding new text input boxes for more rap lyrics.

I’m assuming I can use this front-end to interact with node.js, which will sync clients with the server and end a timer clock at a sync’d time.  I’m also hoping to use MongoDB to save the lyrics and to add more lyrics from current rap songs.

Other features I’d like to have: ability to record and playback peoples’ performances, remixing like Reggie Watts does on the fly.

There’s not much at Karaoke Flow yet, but you can already go visit the site to see the interface.

I am maintaining the code publicly on github. And here’s the JSFiddle:

Nature of Code: Random Walks

For my first homework assignment in Nature of Code, I had to create a random walk of my choosing.  I found Mark Kleback’s self-avoiding walk code (github) to be helpful for having a good example of a clean, easy-to-view walker.

I wanted to practice using the classes and constructors for the movers, so I created my own, using Prof. Shiffman’s examples as guidance.  I also wanted to create multiple movers, so I put them into an array of Mover objects.  For my Movers, I decided to use the Socially-Awkward Penguin from meme-lore.

The thing about SAP is that it lives out all of our insecurities and attempts to avoid looking silly, stupid, or foolish in front of others, often making us resort to ridiculously absurd avoidances of interaction.  So I wanted to see if I could recreate this social awkwardness as part of my Movers.

I think I partly succeeded, though I can tell there’s bugginess in the avoidOthers() function of the constructor because sometimes the penguins get trapped along the sides (probably their velocities have them collide against the walls at a greater speed than they’re pushing off the wall, or something).  I also don’t think the penguins perfectly avoid each other in order to get to the most distant space from each other.  They just reverse their direction whenever they get too close to other penguins.  Still I think the effect worked.

Code and demo at OpenProcessing and code at github, as well as posted below the jump:

Read More »

Dynamic Web Dev & Mobile Web: Final Project Proposals?

For my Dynamic Web Development class (DWD) (syllabus), my first homework assignment was to lay out a proposal for a final project.  Here is the class description:

“The class will cover server-side and client-side web development topics using JavaScript. On the client-side, we will cover traditional JavaScript and the jQuery library to manipulate browser content, create and trigger page events and make AJAX data requests. Developing with NodeJS on the server-side, we will explore receiving input from a user then querying and saving that data to a database, and finally, returning the appropriate content to the client, i.e. HTML or JSON. The websites we use today are rarely on a single database, we will focus on consuming data APIs from websites like Foursquare (for location information), Facebook (for social graph) and Twilio (for SMS and telephony). Going further, we will create custom data APIs for use at ITP and open to the public.”

I’m looking forward to using node and also Twilio (I’ve dabbled a bit in both).  I think Twilio interaction may overlap a bit with my Redial class, which uses the open-source phone comms software Asterisk.

I’ve been working through some codecademy exercises, as instructed on the homework assignment.

I think this class will also dovetail nicely with the mobile web class I’m taking.

For these reasons, I wasn’t entirely sure which idea I wanted to do for my final project just yet.  It could be that I build the back-end for an app for my DWD class but then do a front-end for an Android phone in mobile web class.

Final Project Ideas

Moment Quests:

Part scavenger hunt, part walking tour, part questing/geocaching.  Say you send your girlfriend on a moment quest by sending an invite to her on her mobile phone or browser.  She can accept the quest or delay it or do another quest instead.  Rewards are important — you might not want to do a quest if the payoff is too low!  An instruction will tell her what to do next, where to go, etc.  Once she’s there, she has to offer proof that she’s completed the step: a photo of a receipt, a photo of a landmark, a description of a sign at the exact point, etc.  Then the next stage is unlocked, either automatically or manually by you upon verification.Once she completes all the necessary steps in the quest, a reward is unlocked, or the final step in the quest takes her to her award (e.g. you’re waiting there for her, a gift is given by someone at the location, a secret GPS coordinate is unlocked, etc.).

What’s great is that the infrastructure is flexible — it would just require some GPS checks or a way to approve submitted proof of completing tasks.  You could also make public moment quests.  Companies or promotional events could do one-day quests which pit people against each other to be the first ones to finish, or to find something.Part of what inspired me to do this was Daniel Suarez’s book Daemon, in which the AI software chooses its chief real-world henchman, Loki, after he completes its quest: he’s an avid Wolfenstein gamer who comes across a unique server with an original map which is nearly impossible to beat.  Loki figures out how to beat it though, and then he is initiated into the AI’s recruiting process, where he has to drive out into the middle of nowhere and find his way into an unmarked building.  Once he passes these stages, he’s given a meshnet of killer motorbike drones and other special equipment.  Pretty wicked.

The app will probably require a mobile component, which might use the internal GPS as well as the camera for verification.  A backend will have to be built to store details about the moment quests and what stage of completion a person is through them.  Personal details will need to be saved as well to save info on awards, unlocks, communications between the quester and the dungeonmaster, etc.


I worked on probablyGonna last semester for my comm lab web class, writing it in Ruby/Sinatra. I still need to make it more robust and useful, so it could be a good project for DWD.  It involves the idea that you may know you want to go out dancing Saturday night, but you don’t know who else wants to go or who else is already going.  So you put out an general invite and see if anyone else wants to go.  Or say you’re at school and you’re heading out for lunch; you put out an immediate alert for anyone who’s hungry to come join you at this or that place, and so it facilitates future event planning on the fly, unlike Google Calendar which is fairly regimented, or FourSquare, which only seems to capture peoples’ presences at locations after they’re about ready to leave that place.


Another classmate of mine, Phil, had the idea to create an app that lets an online social media curator tap into a network of available cell phone reporters.  So say there’s a breaking news event occurring at Zuccotti Park, and a web journalist looks at a location map of nearby reporters who could go to the site and film it or record it.  LiveBeam would allow the curator to ping a reporter and see if he could head over and cover the event.

What follows is my interpretation of his idea — he may have something different in mind!

The reporter would be selected based on proximity to the event, the reporter’s reputation for producing a certain type of content (liberal, conservative, streaming video, professional photos, etc.), and availability.  I found that, in my previous job doing social media emergency management, sometimes reporters didn’t know where the action was, or maybe the reporters were screaming at their editors or bosses that the action would be here instead of over there.  Sometimes the best information on something like a remote-area wildfire in New Mexico or a passport fraud bust in Anchorage would never make it to the mainstream news, or maybe one or two regular joes or local reporters would cover the news.  You can’t always rely on the “best” news sources to deliver all the news and information promptly, particularly if a client is looking for more specific, targeted news that the broader outlets ignore.

There is often information asymmetry in emerging crises, and sometimes the best journalist will not be at the proper location, so there needs to be a way to reallocate reporters to proper sites, or signal the best reporter for a given scenario as the one to follow.  You see this on Twitter during a crisis when the top journos tell everyone to Twitter-follow certain people who seem to be producing the best content possible.

People who continuously deliver the best content after being pinged on LiveBeam could have a higher reputation on a site and would become the people who’d be pushed to head on-site.  But there’d still be other options for redirecting traffic towards the best-positioned journo/reporter in any given crisis.  The other part of this is that there is not really enough recognition online for the role of the curator, whose job it is to filter through all of the noise generated on the internet every day and pick only the most important or under-covered stories, adding his or her own editorial take on why the issue is important relative to others.

LiveBeam is likely to need, at the least, backend storage of how to link the curator to the reporter, and GPS capability to place the reporter on a map so s/he can be notified of directions by the curator.  S/he will also probably want the ability to request a curator turn his eye of Mordor onto another event if that event is deemed more important by a reporter.  Or perhaps votes can be tallied by the top emergency management people to raise awareness of an issue.

Mobile Web Homework

Finally, for mobile web we had to create a quick initial app using some buttons, images, and text.  Below’s a screenshot from the Android emulator (running 2.2):

We’re going to be using some PhoneGap for this class, and I added in some jQuery Mobile to play with what they have to offer.  Download the .zip source. Source of assets/www/index.html below:

Redial: First Class

My Redial class looks to be awesome.  A description:

New technologies, such as Voice over IP, and open source telephony applications, such as Asterisk, have opened the door for the development of interactive applications that use telephony for it’s traditional purpose — voice communications. This course explores the use of the telephone in interactive art, performance, social networking, and multimedia applications. Asterisk and low cost VoIP service are used to develop applications that can work over both telephone networks and the internet. Topics include: history of telephony, plain old telephone service (POTS), voice over IP (VoIP), interactive voice response systems (IVR), audio user interfaces, voice messaging systems (voicemail), text to speech and speech recognition, phreaking (telephone hacking), VoiceXML, conferencing and more.

What’s great about it is that it takes what used to be the standard technology when I was growing up (when I tied up the phone line by being online 24/7), and which has since cooled off so much that a lot of people hardly do voice calls except to narrow down to the exact location when meeting up, and has reappropriated the technology again towards a kind of underground hackerish playground.  Almost the way it used to be.  It also takes into account my past in the Army when I was doing communications interception stuff for military intelligence.

Phone rituals and usage have changed dramatically.  Cellphones have privatized and insulated communications from something that used a shared resource (payphones, house phones, party lines) and made it intimately individual (your phone is your digital you).  But there used to be a public phone infrastructure that you would share with other people on the street, in establishments, etc.  The Matrix reminded us of the metaphor.  You could use cellphones within the Matrix, but no infrastructure existed outside of it.  Cellphones within the Matrix only let you communicate with other people, but you needed a “physical” hardline in order to actually leave the Matrix back to the real world.

What’s more, my classmate Phil, who is an international development sort along with myself (but he’s done way more in the field), pointed out that mobiles and the phone market are HUGE, in developing nations.  They are the premiere infrastructure for trading minutes, passing along money, talking with families.  It’s still the best way for diaspora families to stay in contact.  But for a first-world white society, the world of prepaid calling cards, throwaway burner phones, and international cost/minute plans are completely foreign.

Some poignant examples that came to mind when I thought of phone/PBX projects:

QuestionBox: A service in India where someone in a rural village without reliable phone or internet would press the button on a box, paging an operator in a city.  The villager can ask the operator to look up something, like raw good market prices, bus schedules, cricket scores, or, uh, I don’t know, googling Wikipedia for nyan cats.  What I like about it is it’s kind of like a 411 service for disconnected regions.  It also works well for areas where illiteracy is high, because it doesn’t require any reading to interpret the interface, the query, or the results.  Just requires one phone line of some sort, a power source, and a place to house the button and its equipment.  Some limitations may be on whether the operators speak the dialect of those who call in.

QB TED edit from Mike Paterson on Vimeo.

Nokia 100 & 101: Nokia just released a phone that’s about $30 for developing markets that is loaded with Nokia Life Tools.  As best as I can understand it (some of their documentation and marketing is pretty poor), the interface uses icons and pictures to convey meaning instead of using text, which makes it more useful for those who can’t read.

The above two projects I learned about as a result of the senior Yahoo!/Institute for the Study of Diplomacy researcher my year (when I was a junior researcher), Gaurav Mishra.  See his slides for the panel he had with Evgeny Morozov, Ivan Sigal, and Trebor Scholz:

The phone is said to have 25 days of standby power, and has a built-in flashlight.

More details on the Nokia phones, from Nokia’s site: link 1 & link 2.  And from another site: link 3.

Thus voice still has a valuable role in communication, despite the internet moving to a world of textual sharing and chat, and video consumption.  Until we can video chat each other with the same degree of ease that we transmit text, voice comms will have tons of sleeper applications.  And now that the server-end is available to mess with, perhaps we can get some more interesting backends that bring new uses for voice phones to the public, and to those who don’t have access to rich applications and data that we’re beginning to take for granted.

It also brings back the hacker mentality.  Free hacks that benefit the clever and creative?  The potential to serve a public good?  Sounds ripe for hacking!

Kevin Mitnick’s recent autobiography, Ghost in the Wires: My Adventures as the World’s Most-Wanted Hacker, was all about how he managed to social engineer access into internal networks so he could steal source code for cell phones, call routing software, etc.  He figured out how to clone cell phones and re-route calls long before even the engineers did, and certainly before the government was able to co-opt national communications.

My interest in this is primarily how servers are no longer just in the hands of specific companies, but now in those of anyone who can download Asterisk, maintain it, and write dialplans for it.  In the class, I’m looking forward to making some fun apps as well as learning how to secure my system against trolling.  I wonder if the class could become one where all the students are trying to punk each other?

So here’s a test dialplan I made to play with the ITP Asterisk server.  I took Prof. Kairalla’s default script but added a SayDigits() for my personal phone #, so someone dialing in to my extension could get my actual phone number (for class purposes).  I didn’t know which sound file to use because all there is is a list of sound filenames, not descriptions of what they mean.

exten => s,1,Wait(1)
exten => s,n,SayDigits(${CALLERID(num)})
same => n,Playback(vm-num-i-have)
same => n,SayDigits(5555550001)
; use Archer’s joke voicemail sound
;exten => s,n,Playback(demo-echotest)
;exten => s,n,Echo()
;exten => s,n,Playback(demo-echodone)
same => n,Hangup()

I had trouble finding a good web summary of what Applications were available and what they did.  Same for sound filenames.  Any help pointing me to the right locations for this?

My ITP Spring 2012 Course Load

I’m taking 18 credits for my spring 2012 semester at NYU-ITP.  That’s 4 4-credit courses and 1 2-credit course (which lasts 7 weeks only).  I guess this is somewhat subject to change, though I doubt any of the other courses (particularly Clay Shirky’s) are likely to become un-waitlisted. :(  But I will prioritize those next year!

From ITP’s course guide:

Constructing Generative Systems (H79.2534) – Todd Holoubek

[note: Prof. Holoubek is a badass.  He founded The State, that comedy show that a lot of people my age remember from MTV at one point, and now a lot of the people from that show are on Reno 911.  He’s a key NYC person for helping improve great art installations, so it’ll be an honor.  Combined with my internship at The Colbert Report, I’ve already been influenced a ton by some of the city’s greatest comedy personalities.]

“Generative Art Generative Art creates a process of evolution, where most art imitates life, generative art has a life of it’s own Artists, designers, architects have use generative methods for creating many times without knowing. How is it that we can create something that resonates with the user on a level that cannot be quanti?ed. It is by providing the work with the means to have a life of it own. These are the generative methods. Techniques that are subtle, yet have the greatest effect: simple rules that dictate the shape or function of a work adding to it an inherent complexity that is both beautiful and intelligent. In this class we will cover the generative methods and use them as tools for creating.”

Dynamic Web Development (H79.2296) – John Schimmel

“If you ever had a need to collect information from users on the web or use external data in your project, understanding web development will make your life much easier. The class will explore interaction between server-side and client-side of web development using JavaScript. On the client-side, we will cover traditional JavaScript and the jQuery library to manipulate browser content, create and trigger page events and make AJAX data requests. Developing with NodeJS on the server-side, we will explore receiving input from a user then querying and saving that data to a database, and finally, returning the appropriate content to the client, i.e. HTML or JSON. The websites we use today are rarely on a single database, we will focus on consuming data APIs from websites like Foursquare (for location information), Facebook (for social graph) and Twilio (for SMS and telephony). Going further, we will create custom data APIs for use at ITP and open to the public.”

Mobile Web (H79.2938) – Staff

“The miracle of mobile computing has arrived. Exceedingly powerful computers, seamlessly networked and with a variety of in-built sensors… all right in your pocket. This course will be a fast-paced, project-focused course to learn mobile programming in 7 weeks. We’ll use the cross-platform compatible, html/javascript-based PhoneGap libraries to program Android phones. While the course will exclusively use Android as an example platform, the skills acquired will be broadly transferable to other platforms, including iOS. Topics will include: Using HTML / CSS / Javascript to write apps Accessing device events and notifications Monitoring built-in sensors (accelerometer, GPS, compass) Local file storage Media capture and playback Extending PhoneGap with plugins (SMS, Bluetooth, etc.) Students will complete weekly exercises and a final project of their devising. Bring your computer and your Android phone if you have one. A limited supply of Android handsets will be available for students to work with.”

Redial: Interactive Telephony (H79.2574) – Christopher Kairalla

“New technologies, such as Voice over IP, and open source telephony applications, such as Asterisk, have opened the door for the development of interactive applications that use telephony for it’s traditional purpose — voice communications. This course explores the use of the telephone in interactive art, performance, social networking, and multimedia applications. Asterisk and low cost VoIP service are used to develop applications that can work over both telephone networks and the internet. Topics include: history of telephony, plain old telephone service (POTS), voice over IP (VoIP), interactive voice response systems (IVR), audio user interfaces, voice messaging systems (voicemail), text to speech and speech recognition, phreaking (telephone hacking), VoiceXML, conferencing and more. This course involves programming with PHP, Perl or Java.”

The Nature of Code (H79.2480) – Daniel Shiffman

[note: Prof. Shiffman used Kickstarter to fund his book “The Nature of Code”, raising $31,575 after a requested amount of just $5k]

“Can we capture the unpredictable evolutionary and emergent properties of nature in software? Can understanding the mathematical principles behind our physical world world help us to create digital worlds? This class focuses on the programming strategies and techniques behind computer simulations of natural systems. We explore topics ranging from basic mathematics and physics concepts to more advanced simulations of complex systems. Subjects covered include forces, trigonometry, fractals, cellular automata, self-organization, and genetic algorithms. Examples are demonstrated using the Processing ( environment with a focus on object oriented programming.”
Filed Under: ITP

Comm Lab Web: probablyGonna

For my comm lab web class, we finished the course working exclusively with Ruby and Sinatra.  The learning curve was particularly high, and I spent a lot of time wrestling with getting my apps working on Heroku and on my MacBook Air, since there were a lot of subtle changes that had to be made to get the apps working on each.  But I got my Ruby, Sinatra, Postgres, and permissions straightened out on my laptop, and now I can do Shotgun development, which is fantastic because it’s pretty much real-time building of code.  Heroku takes some interpretation of cryptic error messages and symptoms to diagnose how to get things going, but it’s so nice to operate from the console — they have some hotshit engineers there.

So here was my pitch for my final project, probablyGonna.

Like, you might be, “I’m probably gonna go dancing this Saturday in Adams Morgan, so if anyone’s in the area…”  Or, “I’m probably gonna go hiking some weekend, is anyone possibly down?”  The person who opens the ProbablyGonna item is the pioneer of fun.  But the pioneer always needs the validators, the next few who make the event a “go”.  Then everyone else piles on.  But you need the initial sparks, and you need to nurture the kindling until it catches fire.

The thing is, with events, most people don’t plan well in advance.  Facebook has events and our email gets spammed with e-vites, but really, don’t you just end up at 4PM on Friday or Saturday wondering what the hell you really want to do?

Most plans happen at the last minute.  Some even happen on the fly, when you’re in the area.  Who has enough active friends on Foursquare to use it to locate a place nearby to go?  Who checks in regularly on Foursquare?

It’d be nice if someone puts out an open invite for friends (or even strangers) to converge on one spot — at their own leisure.  This also gives context to a location’s events during a specific time.  Look, there are these parties going on at this venue; once you get there of course, the parties dissolve into one mass of people enjoying the location. (it would be nice to have a site where you could do wrap-ups of how cool a party was the night before and what cool stories happened that you just HAVE to tell)

I want to do this because I hate when people blow their Friday and Saturday nights not knowing where the fun is.  I want to do this because I think it’d be cool to have a job where you just ensure that people attend one kickass party that they’ll talk about forever.

So with ProbablyGonna, you just need to enter in a rough when/where/activity entry, and see if others will join.

I’m also thinking there’ll be reputations, developed over time, with how reliable someone is for actually making an event happen after declaring it on ProbablyGonna.  That is, if someone posts 5 invites but bails on all 5, he’ll get a 0% reputation, whereas someone who’s solid will signal to others that it’s safe to make the trek to that venue because the host is definitely going to have made it happen.

The problem with my app was that my physical computing project ended up dominating my life, and I also ran into some last-minute deployment issues.  For instance, I found a great gem, Chronic, that does interpretation of human time (this Friday, next weekend, etc.) into database-readable time.  But on Heroku, they use the latest version of Ruby, 1.9.2, and Chronic was only compatible with Ruby 1.8.7, which was what I used for local development.  So I learned how to deploy to an older version of Ruby on Heroku.  I also had some problems setting up a one-to-many or many-to-many relationship in my database.  I wasted a lot of time on that.  I also couldn’t figure out how to build a proper authentication system for users when they log in — it’s one of the weakest points of my knowledge for web site development, making sure users are who they say they are and making sure their passwords are safe.

The result was that I gave what I thought was a horrible demo of the app in class.  A lot of features didn’t work, and there was far less to show than I had hoped in terms of what the idea could do.  I built it out so that you could easily create an event, for people to probably attend, and then you could easily browse different time scales or events for what you wanted.  But that was about it.  Sure, that’s all the idea is, but I could tell the demo did not resonate as well as it did when I explained the concept behind it.  So I really dropped the ball in executing the simplicity of the idea.

That really troubled me, particularly since I spent the rest of the night all-nighting an attempt to save my failed phys-comp project.  I felt like I was having major problems condensing a simple idea into simple execution, something that would really grab a hold of people instantly.  I’m hoping I just didn’t get enough time to spend on it, and that some mending later will make it more appealing, and my familiarity with it will help me reduce extraneous elements.

Anyway, you can demo the probablyGonna site if you like, over at Heroku.

Here are some screenshots.  I’m taking a break from coding over the Christmas holiday, and am hoping I can implement the site better in my spare time next semester.  I’m also probably gonna work with classmates Phil and Federico on something very similar, matching people to learn their respective skills over coffee, on the NYU campus.

I got some good feedback during the presentation, which indicated that people really liked the idea.  People did not like the name probablyGonna, because they felt it was too uncertain.  Would the originator of an event actually show up if he organized it?  What if you could set a threshold for whether an event will happen, like if it gets over 5 people?  I responded that I felt almost any originator will actually attend his own event, but I guess I could see that if people just started throwing out events onto the site, maybe it’d just get spammy but not deliver.  I think my original idea for this, however, was that people would earn reputations.  Did the person bail on events, particularly his own?  Did people show up when they said they would?  Did someone’s events really pack a punch and get good after-action reviews?  Reputation here, as will be for most sites in the future, will be key towards making the site efficient and usable.  I guess what I wanted to be wary of was making the site too ordered and structured — that product already exists, and it’s called Google Calendar.  But when we’re not in offices and not planning well in advance, how do we actually decide what we’re going to do?  We wait until almost the day of, or the morning of, to weed out the worse options and then settle on the best one.  We also might just want to grab lunch with whomever’s around, and probablyGonna can do that, too.

Comm Lab Web Poll Homework: Favorite Sexual Position

For my comm lab web homework, I had to build a simple poll using Sinatra and Ruby.  I decided to do something a little more interesting, a variant of my favorite Halloween candy app that I posted up on github.

This poll asks people to choose their favorite between two sexual positions.  The choices: missionary, doggystyle, giving oral, receiving oral, giving anal, receiving anal, 69, scissoring, over the table, on the table, cowgirl, reverse cowgirl, dry humping, making out, public sex, mutual masturbation, mammary sex, standing sex, and spooning sex.  The great thing about this type of poll is that it still gives you plenty of options, but since it compares two of the options, it encourages voting multiple times instead of just once.  From there you can approximate peoples’ favorites by seeing how the choices were weighed against each other.  (I wish presidential elections were this way too)

I had a lot of problems with this poll’s development but that was mainly because I’d never coded in Ruby or set up views for an app before.  I also had problems configuring my MacBook Air for shotgun and Sinatra.  But I got those installed correctly after doing a git clone of sinatra and then getting the appropriate Ruby gems.  I also had to adjust my .profile path.  But then it worked after all the clean installations and it was beautiful making changes to my code without restarting Sinatra!  What a lovely development environment!

I tried to deploy my app to heroku because the ITP server runs like garbage (edit: turns out there were some runaway scripts on the server), but I couldn’t get it to run and my heroku logs weren’t very helpful.  I’m sure it was a newbie mistake related to using the right and Gemfile files, along with using the right database adapter configuration line for DataMapper.  Eventually I got it all working — I switched over to Postgres after also figuring out how to install Postgres on my MacBook Air.  This was a lot of front-loading on my Mac but it’s going to be sweet to use for development from here on out.  The comm lab web class has been great for this reason alone, getting my Mac in order, but I’ve also completely crash-coursed in Ruby and Sinatra and I love it.

I also learned you can’t do incrementers like “i++” in Ruby.  But += will work fine.  I’m not a fan of strict casting and whatnot (being a lazy PHP loser).

At any rate, it looks like the old traditional positions are the running favorites (Not Safe For Work, NSFW).  Doggystyle and cowgirl came in at the top.  Results seemed fairly consistent across genders.  I got 925+ votes on this thing in just a week or two.  I didn’t spot any abnormal results really, although it looks like almost all men preferred receiving oral to other things, whereas for women it was split.  Women were more receptive to doggystyle and reverse cowgirl than I might have thought.

Again, here’s the poll.  There’s also a great chart of the data, broken down by men, women, and unknown, further split into which of their choices won or lost.  I made this using Ruby pulling from YAML into HighCharts, which is a great library online.

Genetic Crossings (ICM Final Project Presentation)

[see more documentation: proposal, part 2, part 1]


For Heather Dewey-Hagborg’s Intro to Computational Media class at NYU’s Interactive Telecommunications Program, I decided my final project would involve creating a simulation incorporating the traits of people, nations, and religions, creating offspring who are summations of their genetics and environments.

Processing is a great language for easily visualizing data.  I early on realized I wanted to make a visualization as a study for, my eventual thesis for developing a reputation and identity system that centralizes all the data you’ve ever created about yourself and what others say about you so that you can develop algorithms and formulas for evaluating and comparing your results with others.


Visually, I was interested in karyograms, Punnett squares, chromosome stainings, and representations of solar systems.



The sketch initializes a world and fills it with 5 people to start off with, Albert Einstein and Gisele Bundchen, and 3 random individuals.  Time begins, with each pass of the draw() loop aggregated and calculated into a rough approximation of years in time.

People have innate traits and characteristics saved into variables: strength, intelligence, wisdom, charisma, stamina, wit, humor, education, creativity, responsibility, discipline, honesty, religiosity, entrepreneurialism, appearance, money, gracefulness, stress, health, luck, talent at math, talent at art, talent at sports, whether employed, happiness, nationality, religion.  They are on a scale from 1-10, with 1 implying the most negative state and 10 being the best. (e.g. poor health vs. superb health, ugly vs. gorgeous, a stressed-out person vs. a carefree one, etc.)

They are born into nationalities/regions: USA, UK, Africa, China, South America, with the traits security, innovation, job opportunity, immigration policy, life expectancy, education, sanitation, standard of living, pollution, biodiversity, crime, political freedom, and nutrition.

They have religions/ways of life: Christianity, Catholicism, Judaism, Islam, Taoism, Buddhism, Confucianism, with the traits commercial, morality, hierarchy, and portability.

You can already see the terminology isn’t precise (nations vs. regions), and I’m missing tons of variables.  Had I more time to code in more negative effects, I would add personality traits like deception, violence, libido, etc.

God is in the sketch.  All people are connected with him.  He also has baller stats:

// who art in Heaven
  god = new Person(-1, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
    0, 0, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, "God", "null", -2, -2, -1, 0, -1, 0, 1, 1100, 600);

Every pass through draw(), it’s determined whether 1) there’s a potential match (via the flirt() function), matching a male and a female (sorry, I didn’t have time to code in adoption et al), 2) there’s chemistry, and 3) if so, then sex().  Chemistry() requires a degree of likeness in appearance, money, religiosity, and some other superficial requirements. Then again, there’s also the function, which I’m particularly proud of:

else if (, flirter2)) {}

Social lubrication — some of the basic requirements for chemistry are, um, degraded, leading to easier baby-making.  This is also good for preventing my sketch from not having enough chemistry to produce offspring between the people.

Women between ages 18 and 50-ish are fertile (I had to adjust the numbers so that the sketch would work throughout its duration instead of the whole civilization losing an ability to breed by becoming too old) and need at least 5 “years” or something between babies before they can have another child.

boolean checkFertile(int _flirter1, int _flirter2) {
    int female = 0;
    boolean fertile = false;
    if (person[_flirter1].gender == "female" && person[_flirter1].alive == true) {
      female = 1;
      if ((currentYear - person[_flirter1].lastBaby > gestationRate) &&
       (person[_flirter1].age >= 18) && (person[_flirter1].age = 18)) {
        fertile = true;
    else if (person[_flirter2].gender == "female" && person[_flirter1].alive == true) {
      female = 2;
      if ((currentYear - person[_flirter2].lastBaby > gestationRate) &&
       (person[_flirter2].age >= 18) && (person[_flirter2].age = 18)) {
        fertile = true;
    return fertile;

Children are created through matingDance.punnettSquare() of their parents.  The parents’ traits are averaged together and then some mutation is introduced for variability in the children.  I think I coded it so some traits change more than others, and some don’t change at all.

People can reach somewhere around 65-ish before death becomes a regular reality.  Once people die, they are removed from the population size, which is capped at 40 — allowing another child to be born somewhere if there’s less than 40 people alive.  The maximum number for the duration of the sketch is 90 people, so if 40 people are dead, up to 50 others can be alive.  The sketch starts to slow down once there’s more and more computation via people objects.

The orange-yellow buttons toggle between the main universe-like view and another view, which contains system stats and karyogram-like views of each person’s traits.  The traits are displayed as circles, with their sizes representing the size of the traits.

I made some formulas (or evolutions, as I call them) for actual vs. potential well-being.  This computes someone’s traits as he is born with, and after they are adjusted for quality of the nation and his religion.  This is then divided by the maximum well-being one could have in the same religion and nation.  Thus you get a ratio of actual vs. potential.  The goal is to bring these numbers as close together as possible, to see if a society is running at full efficiency.

In my fairly generous, unscientific, unsystematic world, people are STILL running far below efficiency.  The best of human achievement is squandered daily, not just by peoples’ own personalities and time constraints, but by poor maximization policy and by inflexible religious traditions.

I also coded in a happiness evolution:

int happiness(int i) {
    int happiness = person[i].health + person[i].money + person[i].stress + person[i].creativity + person[i].religiosity +
    round(nation[person[i].nationality].standardOfLiving / 10) + round(nation[person[i].nationality].pollution / 10) +
    round(nation[person[i].nationality].security / 10) + round(nation[person[i].nationality].crime / 10) + person[i].employed * 10;
    return happiness;

This computes someone’s happiness based on personal health, stress levels, creativity, religiosity, and his nation’s standard of living, pollution levels, national security, crime levels, etc.  It also relies on whether someone is employed or not.  Obviously this evolution needs a ton of work and far more variables.


The happiness metric and the actual/potential well-being ratio are key metrics that I want to spend more time nailing down.  I think these metrics are chasing Aristotle’s concept of eudaimonia, which I also have tattooed on my arm.  There’s more to life than money.  There’s all these other variables.  It could be said we are happiest (in a bigger sense) when we feel we are running at our maximum potential and can contribute to the world.  We need to be able to measure this and push it down to the individual level, so people can make better choices towards bettering themselves, and up to government level, so policymakers can make better policy to maximize a nation’s human and social capital.


The code is too long to post here, but here’s a direct .txt link to the source .pde (w/ combined classes).  You can go see the sketch running at!  Only thing about that is that it will run in a reduced-size window.  You can try to view the Mac .app version or the Windows .exe version, too.

The code is also now at Github.

Difficulties and Lessons Learned

I used a Hashtable at first, to try it out, but I quickly ran into limitations I didn’t know how to get around.  I would use pretty length functions to recast strings as integers and vice versa, and so on.  Eventually I got so pissed that I rewrote a lot of the code and Person classes so that everything was saved as an integer and then I could look up its “name” in a table via a function.  So the nations are coded as 0-5 or whatever, with 1 equaling the UK, etc.  Much easier to manipulate.  It also meant I could use the ID integer with arrays.

My code got long and complex quickly, so I had to split everything up into classes, just for organization’s sake:  Death, DrawFuncs, Evolutions, GetFuncs, MatingDance, Nation, Person, Religion.   I don’t think at this level of sophistication, I could really build more objects into the sketch.  I wanted to practice inheritance and polymorphism stuff but it didn’t come up.  Any ideas for refactoring?

I really hated recasting strings and integers.

I want to spend more time coding on happiness and actuality vs. potentiality.  What I learned was that you have to build a really large system sandbox before you can begin to tackle those metrics.  This includes modeling and simulating an environment to such a degree that it can begin to calculate and visualize your concept of what happiness is, since it pulls from so many dimensions of one’s life. (not just money, but also charity, family life, employment, etc.)

Ways to Expand

Still want to use real-time data from, fed in from its database into Processing.  Too much to do right now though.  I’d have to redesign my database as well as fix the sketch variables!

The algorithms and equations need a lot of tweaking to be more realistic.  For, I’m hoping to crowdsource algorithms for the most accurate ways to calculate somewhat qualitative figures.

I wanted to be able to introduce outside shocks (natural disasters, etc.) into the system, to see how it would affect various nations and personality types, to see who would be more resilient.

I would like to give random people innate superpowers or traits that are unique or very rare.  So that maybe when they turn 30, something is unlocked within them.  I guess I could also give them random diseases and genetic predispositions.


This project helped me get pretty solid on classes and functions and how to organize a sketch.  If I were to rewrite this, it would be far cleaner and more compact.  Mostly I’m appreciative of how much work it takes just to get to a level where you can start doing interesting network effects on large systems.  I barely scratched the surface, in about 1,590 lines of code, but I did manage to achieve perhaps 90% of the infrastructure that I hoped to build.  All of this helps me build a better reputation and identity system for and for my thesis.  I’m hoping the more solid I get on the infrastructure, the bigger breakthroughs I will have on the algorithms and crowdsourcing enablers that will be at the heart of

8-Bit DNA

My ITP classmate Matthew Epler did his intro to computational media midterm on turning poetry into RGB colors, after playing with the concept of digital characters as ASCII values (see the ASCII Table).

“This project is the beginning of what I suspect will be an ongoing investigation of the relationship between language and code. In “Color of Language,” poems are translated into color via Processing, and then passed through a series of iterations involving one simple mathematical equation.”

This made me think about our example sketches where we could break down GIF images into pixels and then display each pixel differently (turn the pixels into ellipses, or search/sort them by brightness).

As I’ve been playing with the look of karyograms and DNA in other projects, I wanted to visually display 8-bit Nintendo characters as their representative digital DNA.  This brief Processing sketch reads in every pixel of the .gif image and outputs it all on one line instead of as an image with width and height, to give it a unique linear signature. Here is the result:

It would be pretty hard to guess the characters just from this representation, but each one definitely has its own digital signature.

The characters:

 = Link (Legend of Zelda)

 = Samus Aran (Metroid)

 = Mario (Super Mario Bros.)

 = Kid Icarus

 = Scrooge McDuck (Duck Tales)

size(1400, 500);

PImage thisImg;

int numImgs = 5;
thisImg = loadImage("link.gif"); // filler

for (int i=0; i < numImgs; i++) { 
  switch (i) {
  case 0:
    thisImg = loadImage("link.gif");
  case 1:
    thisImg = loadImage("samus.gif");
  case 2:
    thisImg = loadImage("mario.gif");
  case 3:
    thisImg = loadImage("kidicarus.gif");
  case 4:
    thisImg = loadImage("scrooge.gif");

  // displays 1 pixel x 20 pixel DNA lines for each Nintendo character

  color[] imgPixels = thisImg.pixels;
  int z = 0;
  for (int x = 0; x < thisImg.width; x++) {
    for (int y = 0; y < thisImg.height; y++) {
      color c = imgPixels[x + y * thisImg.width];
      rect(z*1, 25*i, 1, 20);